Skip to content

Commit

Permalink
simple import path
Browse files Browse the repository at this point in the history
  • Loading branch information
jared2020 committed May 12, 2023
1 parent 816d570 commit 0ee5648
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 75 deletions.
10 changes: 2 additions & 8 deletions examples/TaoQuickShow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,15 @@ if (CMAKE_BUILD_TYPE MATCHES "Release")
${TaoQuickRes}
)
endif()
add_compile_definitions(qmlPath="qrc:/Qml/")
add_compile_definitions(contentsPath="qrc:/Contents/")
add_compile_definitions(imgPath="qrc:/Image/")
add_compile_definitions(transDir=":/Trans/")
add_compile_definitions(TaoQuickShowPath="qrc:/")
else()
add_executable(${TargetName}
${SRC1}
${SRC2}
${TaoCommonFiles}
)
add_compile_definitions(TAODEBUG)
add_compile_definitions(qmlPath="file:///${CMAKE_CURRENT_SOURCE_DIR}/Qml/")
add_compile_definitions(contentsPath="file:///${CMAKE_CURRENT_SOURCE_DIR}/Contents/")
add_compile_definitions(imgPath="file:///${CMAKE_CURRENT_SOURCE_DIR}/Image/")
add_compile_definitions(transDir="${CMAKE_CURRENT_SOURCE_DIR}/Trans/")
add_compile_definitions(TaoQuickShowPath="file:///${CMAKE_CURRENT_SOURCE_DIR}/")
endif()

target_include_directories(${TargetName} PUBLIC . ./Src ${TaoCommonPath})
Expand Down
26 changes: 21 additions & 5 deletions examples/TaoQuickShow/Src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include "AppInfo.h"
#include "DeviceAddTable/DeviceAddModel.h"
#include "Frameless/TaoFrameLessView.h"

#ifndef TAODEBUG
#include "Logger/Logger.h"
#endif

#include "QuickTool/QuickTool.h"
#include "Trans/Trans.h"
#include <QDir>
Expand All @@ -11,10 +15,6 @@
#include <QQuickItem>
#include <QUrl>

#ifdef QMAKE_GEN_TAOMACRO
#include "taoMacro.h"
#endif

static void prepareApp()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Expand Down Expand Up @@ -42,6 +42,22 @@ int main(int argc, char** argv)
const auto appPath = QDir::cleanPath(app.applicationDirPath());
qWarning() << "appPath" << appPath;

QString taoQuickShowPath = TaoQuickShowPath;
QString transDir = taoQuickShowPath + "Trans/";
if (transDir.startsWith("file:///"))
{
transDir = transDir.remove("file:///");
}
if (transDir.startsWith("qrc:/"))
{
transDir = transDir.remove("qrc");
}
QString qmlPath = taoQuickShowPath + "Qml/";
QString imgPath = taoQuickShowPath + "Image/";
QString contentsPath = taoQuickShowPath + "Contents/";
qWarning() << "qmlPath" << qmlPath;
qWarning() << "imgPath" << imgPath;
qWarning() << "contentsPath" << contentsPath;
Trans trans;
AppInfo appInfo;
QuickTool quickTool;
Expand Down Expand Up @@ -83,10 +99,10 @@ int main(int argc, char** argv)
view.rootContext()->setContextProperty("scrollBarHasMinimumSize", false);
#endif

view.rootContext()->setContextProperty("appPath", appPath);
view.rootContext()->setContextProperty("qmlPath", qmlPath);
view.rootContext()->setContextProperty("imgPath", imgPath);
view.rootContext()->setContextProperty("contentsPath", contentsPath);
view.rootContext()->setContextProperty("appPath", appPath);
view.rootContext()->setContextProperty("view", &view);
view.rootContext()->setContextProperty("quickTool", &quickTool);

Expand Down
27 changes: 3 additions & 24 deletions examples/TaoQuickShow/TaoQuickShow.pri
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,17 @@ CONFIG(debug, debug|release) {
} else {
path=$$system("pwd")
}
qmlPath = \"file:///$${path}/Qml/\"
contentsPath = \"file:///$${path}/Contents/\"
imgPath = \"file:///$${path}/Image/\"
transDir=\"$${path}/Trans/\"
DEFINES +=TaoQuickShowPath=\\\"file:///$${path}/\\\"

OTHER_FILES += $$files($$path/Qml/*.qml, true)
OTHER_FILES += $$files($$path/Contents/*.qml, true)
# DEFINES += qmlPath=\\\"file:///$$PWD/Qml/\\\"
# DEFINES += contentsPath=\\\"file:///$$PWD/Contents/\\\"
# DEFINES += imgPath=\\\"file:///$$PWD/Image/\\\"

} else {
#release模式用qrc、走资源文件。这样发布不会携带源码。
RESOURCES += \
$$PWD/Qml.qrc \
$$PWD/Image.qrc \
$$PWD/Contents.qrc

qmlPath = \"qrc:/Qml/\"
contentsPath = \"qrc:/Contents/\"
imgPath = \"qrc:/Image/\"
transDir= \":/Trans/\"
# DEFINES += qmlPath=\\\"qrc:/Qml/\\\"
# DEFINES += contentsPath=\\\"qrc:/Contents/\\\"
# DEFINES += imgPath=\\\"qrc:/Image/\\\"
DEFINES +=TaoQuickShowPath=\\\"qrc:/\\\"
}

#!android:!ios {

# CONFIG += file_copies

# trans.files = $$PWD/Trans/language_zh.json
# trans.path = $$DESTDIR/Trans
# COPIES += trans
#}
#OTHER_FILES += $$PWD/Trans/language_zh.json
13 changes: 0 additions & 13 deletions examples/TaoQuickShow/TaoQuickShow.pro
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ CONFIG(debug,debug|release) {
include($${TaoQuick_3RDPARTY_TREE}/TaoCommon/src/TaoCommon/TaoCommon.pri)
include($${TaoQuick_SOURCE_TREE}/src/TaoQuick.pri)
include(TaoQuickShow.pri)
DEFINES += QMAKE_GEN_TAOMACRO
!build_pass {
headerContents = \
"$${LITERAL_HASH}pragma once" \
"$${LITERAL_HASH}define TaoQuickImportPath $${TaoQuickImportPath}" \
"$${LITERAL_HASH}define qmlPath $${qmlPath}" \
"$${LITERAL_HASH}define contentsPath $${contentsPath}" \
"$${LITERAL_HASH}define imgPath $${imgPath}" \
"$${LITERAL_HASH}define transDir $${transDir}"

write_file(taoMacro.h, headerContents)
}


win32:!mingw {
RC_FILE = App.rc
Expand Down
33 changes: 8 additions & 25 deletions mkspecs/features/taoVersion.prf
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,15 @@ defineTest(setTaoVersion) {
VER_PAT = $${PAT}
VERSION = $${Ver}
}
TaoREVISION=$${REVISION}
TaoREVISIONSTR=\"$${REVISION}\"
TaoVer=\"$${Ver}\"
TaoMAJ=$${MAJ}
TaoMIN=$${MIN}
TaoPAT=$${PAT}
TaoDATETIME=\"$${_DATE_}\"
CXX_COMPILER_ID=\"$${QMAKE_COMPILER}\"

export(TaoREVISION)
export(TaoREVISIONSTR)
export(TaoVer)
export(TaoMAJ)
export(TaoMIN)
export(TaoPAT)
export(TaoDATETIME)
export(CXX_COMPILER_ID)

DEFINES += TaoREVISION=$${REVISION}
DEFINES += TaoREVISIONSTR=\"\\\"$${REVISION}\\\"\"
DEFINES += TaoVer=\"\\\"$${Ver}\\\"\"
DEFINES += TaoMAJ=$${MAJ}
DEFINES += TaoMIN=$${MIN}
DEFINES += TaoPAT=$${PAT}
DEFINES += TaoDATETIME=\"\\\"$${_DATE_}\\\"\"
DEFINES += CXX_COMPILER_ID=\"\\\"$${QMAKE_COMPILER}\\\"\"
DEFINES *= TaoREVISION=$${REVISION}
DEFINES *= TaoREVISIONSTR=\"\\\"$${REVISION}\\\"\"
DEFINES *= TaoVer=\"\\\"$${Ver}\\\"\"
DEFINES *= TaoMAJ=$${MAJ}
DEFINES *= TaoMIN=$${MIN}
DEFINES *= TaoPAT=$${PAT}
DEFINES *= TaoDATETIME=\"\\\"$${_DATE_}\\\"\"
DEFINES *= CXX_COMPILER_ID=\"\\\"$${QMAKE_COMPILER}\\\"\"

export(CONFIG)
export(VER_MAJ)
Expand Down

0 comments on commit 0ee5648

Please sign in to comment.