Skip to content

Commit d9255c3

Browse files
Merge pull request #394 from FlyAndNotDown/master
Feat: Misc Update
2 parents c923e37 + a9b2bec commit d9255c3

File tree

15 files changed

+174
-23
lines changed

15 files changed

+174
-23
lines changed

Editor/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ set(EDITOR_RESOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Qml/Resource)
5454
get_filename_component(EDITOR_RESOURCE_ROOT_ABSOLUTE ${EDITOR_RESOURCE_ROOT} ABSOLUTE)
5555

5656
file(GLOB QML_SOURCES ${EDITOR_QML_ROOT}/*.qml)
57-
file(GLOB_RECURSE RESOURCES ${EDITOR_RESOURCE_ROOT}/*)
5857

5958
list(
6059
APPEND SINGLETON_QML_SOURCES
@@ -70,17 +69,16 @@ foreach (QML_SOURCE ${QML_SOURCES})
7069
endif ()
7170
endforeach ()
7271

73-
foreach (RESOURCE ${RESOURCES})
74-
string(REPLACE ${EDITOR_RESOURCE_ROOT_ABSOLUTE} "Resource" ALIAS ${RESOURCE})
75-
set_source_files_properties(${RESOURCE} PROPERTIES QT_RESOURCE_ALIAS ${ALIAS})
76-
endforeach ()
72+
add_custom_command(
73+
TARGET Editor POST_BUILD
74+
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${EDITOR_RESOURCE_ROOT_ABSOLUTE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../Resource
75+
)
7776

7877
qt_add_qml_module(
7978
Editor
8079
NO_CACHEGEN
8180
URI editor
8281
QML_FILES ${QML_SOURCES}
83-
RESOURCES ${RESOURCES}
8482
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Generated/QmlModule
8583
)
8684
# ---- end qml ---------------------------------------------------------------------------------------

Editor/Qml/EFloatInput.qml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,27 @@ import QtQuick
22
import QtQuick.Controls
33
import QtQuick.Controls.Basic
44

5-
ETextField {
5+
Item {
6+
property double value: Number(textField.text)
67
property double from: 0.0
78
property double to: 1.0
89

910
id: root
10-
implicitWidth: 100
11+
implicitWidth: textField.implicitWidth
12+
implicitHeight: textField.implicitHeight
1113

12-
validator: DoubleValidator {
13-
bottom: root.from
14-
top: root.to
14+
ETextField {
15+
id: textField
16+
implicitWidth: 100
17+
text: value
18+
19+
onAccepted: {
20+
root.value = Number(displayText)
21+
}
22+
23+
validator: DoubleValidator {
24+
bottom: root.from
25+
top: root.to
26+
}
1527
}
1628
}

Editor/Qml/EIcon.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Item {
1111

1212
Image {
1313
id: imageWidget
14-
source: root.name === '' ? '' : 'Resource/Icon/%1.svg'.arg(root.name)
14+
source: root.name === '' ? '' : 'file:../Resource/Icon/%1.svg'.arg(root.name)
1515
sourceSize.width: root.size
1616
sourceSize.height: root.size
1717
layer.enabled: true

Editor/Qml/ETheme.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ QtObject {
1818
property color placeHolderFontColor: Qt.color('#c0c3c4')
1919
property color linkFontColor: Qt.color('#91b9c4')
2020

21-
property FontLoader normalFont: FontLoader { source: Qt.url('Resource/Font/MiSans-Medium.ttf') }
22-
property FontLoader boldFont: FontLoader { source: Qt.url('Resource/Font/MiSans-Semibold.ttf') }
21+
property FontLoader normalFont: FontLoader { source: 'file:%1/Font/MiSans-Medium.ttf'.arg(appResDir) }
22+
property FontLoader boldFont: FontLoader { source: 'file:%1/Font/MiSans-Semibold.ttf'.arg(appResDir) }
2323
property int tiele1FontSize: 20
2424
property int title2FontSize: 18
2525
property int title3FontSize: 16

Editor/Qml/EWidgetSamples.qml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,7 @@ Rectangle {
449449
Layout.margins: 5
450450

451451
RowLayout {
452-
EFloatInput {
453-
onAccepted: {
454-
console.log('value accepted, value=' + text)
455-
}
456-
}
452+
EFloatInput {}
457453

458454
EText {
459455
Layout.leftMargin: 5

Editor/Src/Widget/QmlWidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Created by Kindem on 2024/12/31.
33
//
44

5+
#include <QQmlContext>
56
#include <QVBoxLayout>
67

78
#include <Editor/Widget/QmlWidget.h>
@@ -15,6 +16,9 @@ namespace Editor {
1516
, url(QmlEngine::Get().GetUrlFromShort(shortQmlFileName))
1617
, quickView(new QQuickView)
1718
{
19+
20+
const Common::Path resDir = Core::Paths::EngineResDir();
21+
quickView->rootContext()->setContextProperty("appResDir", QString::fromStdString(resDir.String()));
1822
quickView->setResizeMode(QQuickView::SizeRootObjectToView);
1923
quickView->setSource(url);
2024

Engine/Shader/BasePassPS.esl

Whitespace-only changes.

Engine/Shader/BasePassVS.esl

Whitespace-only changes.

Engine/Source/Common/Include/Common/File.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Common {
1212
class FileUtils {
1313
public:
1414
static std::string ReadTextFile(const std::string& inFileName);
15+
static void WriteTextFile(const std::string& inFileName, const std::string& inContent);
1516
static rapidjson::Document ReadJsonFile(const std::string& inFileName);
1617
static void WriteJsonFile(const std::string& inFileName, const rapidjson::Document& inJsonDocument, bool inPretty = true);
1718
};

Engine/Source/Common/Src/File.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ namespace Common {
3030
return result;
3131
}
3232

33+
void FileUtils::WriteTextFile(const std::string& inFileName, const std::string& inContent)
34+
{
35+
const Path path(inFileName);
36+
if (const Path parentPath = path.Parent();
37+
!parentPath.Exists()) {
38+
parentPath.MakeDir();
39+
}
40+
41+
std::ofstream file(inFileName, std::ios::out | std::ios::binary | std::ios::trunc);
42+
Assert(file.is_open());
43+
file.write(inContent.data(), static_cast<std::streamsize>(inContent.size()));
44+
file.close();
45+
}
46+
3347
rapidjson::Document FileUtils::ReadJsonFile(const std::string& inFileName)
3448
{
3549
char buffer[65536];

0 commit comments

Comments
 (0)