Skip to content

Commit

Permalink
简化importPath
Browse files Browse the repository at this point in the history
# Conflicts:
#	cmake/taoQuick.cmake
  • Loading branch information
jared2020 committed May 11, 2023
1 parent b871b67 commit ae2453f
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 20 deletions.
6 changes: 1 addition & 5 deletions cmake/taoQuick.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ set(TaoQuickPath ${CMAKE_SOURCE_DIR}/src)
if (CMAKE_BUILD_TYPE MATCHES "Release")
set(TaoQuickRes ${TaoQuickPath}/TaoQuick/TaoQuick.qrc CACHE STRING "tao quick res path")
set(TaoQuickImport "qrc:///" CACHE STRING "tao quick import path")
set(TaoQuickImage "qrc:/TaoQuick/Images/" CACHE STRING "tao quick image path")

else()
set(TaoQuickImport "file:///${TaoQuickPath}/" CACHE STRING "tao quick import path")
set(TaoQuickImage "file:///${TaoQuickPath}/TaoQuick/Images/" CACHE STRING "tao quick image path")
set(TaoQuickImport "file:///${TaoQuickPath}/" CACHE STRING "tao quick import path")
endif()

add_compile_definitions(TaoQuickImport="${TaoQuickImport}")
add_compile_definitions(TaoQuickImage="${TaoQuickImage}")

add_compile_definitions(TaoQuickImportPath="${TaoQuickImport}")
add_compile_definitions(TaoQuickImagePath="${TaoQuickImage}")

#add_compile_definitions(QML_IMPORT_PATH="${TaoQuickPath}")
#add_compile_definitions(QML2_IMPORT_PATH="${TaoQuickPath}")
Expand Down
2 changes: 1 addition & 1 deletion examples/HelloTaoQuick1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main(int argc, char** argv)
QGuiApplication app(argc, argv);
QQuickView view;
view.engine()->addImportPath(TaoQuickImportPath);
view.rootContext()->setContextProperty("taoQuickImagePath", TaoQuickImagePath);
view.rootContext()->setContextProperty("taoQuickImportPath", TaoQuickImportPath);

view.setSource(QUrl("qrc:/main.qml"));
view.show();
Expand Down
2 changes: 1 addition & 1 deletion examples/HelloTaoQuick2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(int argc, char* argv[])

QQmlApplicationEngine engine;
engine.addImportPath(TaoQuickImportPath);
engine.rootContext()->setContextProperty("taoQuickImagePath", TaoQuickImagePath);
engine.rootContext()->setContextProperty("taoQuickImportPath", TaoQuickImportPath);
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(
&engine,
Expand Down
4 changes: 0 additions & 4 deletions examples/HelloTaoQuick2/taoQuick.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ set(TaoQuickPath ${CMAKE_SOURCE_DIR}/../../src/TaoQuick/imports)
if (CMAKE_BUILD_TYPE MATCHES "Release")
set(TaoQuickRes ${TaoQuickPath}/TaoQuick/TaoQuick.qrc CACHE STRING "tao quick res path")
set(TaoQuickImportPath "qrc:///" CACHE STRING "tao quick import path")
set(TaoQuickImagePath "qrc:/TaoQuick/Images/" CACHE STRING "tao quick image path")

else()
set(TaoQuickImportPath "file:///${TaoQuickPath}" CACHE STRING "tao quick import path")
set(TaoQuickImagePath "file:///${TaoQuickPath}/TaoQuick/Images/" CACHE STRING "tao quick image path")
endif()
add_compile_definitions(TaoQuickImportPath="${TaoQuickImportPath}")
add_compile_definitions(TaoQuickImagePath="${TaoQuickImagePath}")

add_compile_definitions(QML_IMPORT_PATH="${TaoQuickPath}")
add_compile_definitions(QML2_IMPORT_PATH="${TaoQuickPath}")
Expand Down
4 changes: 0 additions & 4 deletions examples/TaoQuickShow/Src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ int main(int argc, char** argv)
qWarning() << "TaoQuickImportPath " << TaoQuickImport;
#endif

#ifdef TaoQuickImage
view.rootContext()->setContextProperty("taoQuickImagePath", TaoQuickImage);
#endif

#ifdef TAODEBUG
view.rootContext()->setContextProperty("isDebug", true);
#else
Expand Down
1 change: 0 additions & 1 deletion examples/TaoQuickShow/TaoQuickShow.pro
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ DEFINES += QMAKE_GEN_TAOMACRO
headerContents = \
"$${LITERAL_HASH}pragma once" \
"$${LITERAL_HASH}define TaoQuickImport $${TaoQuickImport}" \
"$${LITERAL_HASH}define TaoQuickImage $${TaoQuickImage}" \
"$${LITERAL_HASH}define qmlPath $${qmlPath}" \
"$${LITERAL_HASH}define contentsPath $${contentsPath}" \
"$${LITERAL_HASH}define imgPath $${imgPath}" \
Expand Down
2 changes: 0 additions & 2 deletions src/TaoQuick.pri
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ CONFIG(debug,debug|release){
TaoQuickImport=\"file:///$$path/\"
TaoQuickImage=\"file:///$$path/TaoQuick/Images/\"
DEFINES += TaoQuickImportPath=\\\"file:///$${path}/\\\"
DEFINES += TaoQuickImagePath=\\\"file:///$${path}/TaoQuick/Images/\\\"

OTHER_FILES += $$files($$path/TaoQuick/Qml/*.qml, true)

Expand All @@ -20,7 +19,6 @@ CONFIG(debug,debug|release){
TaoQuickImport=\"qrc:/\"
TaoQuickImage=\"qrc:/TaoQuick/Images/\"
DEFINES += TaoQuickImportPath=\\\"qrc:///\\\"
DEFINES += TaoQuickImagePath=\\\"qrc:/TaoQuick/Images/\\\"
}

# Additional import path used to resolve QML modules in Qt Creator's code model
Expand Down
4 changes: 2 additions & 2 deletions src/TaoQuick/Qml/CusConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ QtObject {

property string imagePathPrefix: "file:///./../Images/"
Component.onCompleted: {
if (typeof (taoQuickImagePath) != "undefined" && taoQuickImagePath !== null && taoQuickImagePath.length > 0) {
imagePathPrefix = taoQuickImagePath
if (typeof (taoQuickImportPath) != "undefined" && taoQuickImportPath !== null && taoQuickImportPath.length > 0) {
imagePathPrefix = taoQuickImportPath + "TaoQuick/Images/"
}
currentTheme = 0
}
Expand Down

0 comments on commit ae2453f

Please sign in to comment.