From: Boyuan Yang Date: Mon, 5 Aug 2019 20:11:20 +0000 (-0400) Subject: New upstream version 2.1.1 X-Git-Tag: archive/raspbian/5.7.12-2+rpi1^2~3^2~19 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=cc3c45e9234cb6ef7308120bb7319f1de28bf324;p=dtkcore.git New upstream version 2.1.1 --- diff --git a/.gitignore b/.gitignore index ed3c17f..a49eb98 100644 --- a/.gitignore +++ b/.gitignore @@ -19,11 +19,11 @@ build*/ # executeable files *.qm -src/DtkCore +src/DtkCores src/dtkcore_config.h cmake/DtkCore/DtkCoreConfig.cmake src/qt_lib_d*.pri bin/ .qmake* -tools/deepin-os-release/Makefile \ No newline at end of file +Makefile diff --git a/.qmake.conf b/.qmake.conf index c33dce5..924d996 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1 +1,2 @@ isEmpty(DTK_VERSION):DTK_VERSION=2.0.6 +DTK_MODULE_NAME=dtkcore diff --git a/debian/control b/debian/control index da2b555..5bbd5a0 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: Deepin Packages Builder Build-Depends: debhelper (>= 9), pkg-config, qttools5-dev-tools, qtbase5-private-dev, - libgsettings-qt-dev, deepin-desktop-base + libgsettings-qt-dev Standards-Version: 3.9.8 Package: libdtkcore2 diff --git a/debian/libdtkcore-bin.install b/debian/libdtkcore-bin.install index a0739b8..0ca22cc 100644 --- a/debian/libdtkcore-bin.install +++ b/debian/libdtkcore-bin.install @@ -1,2 +1 @@ -usr/lib/dtk2/* usr/lib/*/*/DCore/bin/* diff --git a/debian/libdtkcore2.symbols b/debian/libdtkcore2.symbols index ab79bd4..d366820 100644 --- a/debian/libdtkcore2.symbols +++ b/debian/libdtkcore2.symbols @@ -371,17 +371,14 @@ libdtkcore.so.2 libdtkcore2 #MINVER# (optional=templinst)_ZN4QMapIi7QStringED1Ev@Base 2.0.11 (optional=templinst)_ZN4QMapIi7QStringED2Ev@Base 2.0.11 (optional=templinst)_ZN5QHashI7QStringiE11deleteNode2EPN9QHashData4NodeE@Base 2.0.11 - (optional=templinst)_ZN5QHashI7QStringiE13detach_helperEv@Base 2.0.11 (optional=templinst)_ZN5QHashI7QStringiE13duplicateNodeEPN9QHashData4NodeEPv@Base 2.0.11 (optional=templinst)_ZN5QHashIPN3Dtk4Core16AbstractAppenderE15QHashDummyValueE11deleteNode2EPN9QHashData4NodeE@Base 2.0.11 - (optional=templinst)_ZN5QHashIPN3Dtk4Core16AbstractAppenderE15QHashDummyValueE13detach_helperEv@Base 2.0.11 (optional=templinst)_ZN5QHashIPN3Dtk4Core16AbstractAppenderE15QHashDummyValueE13duplicateNodeEPN9QHashData4NodeEPv@Base 2.0.11 (optional=templinst)_ZN5QHashIPN3Dtk4Core16AbstractAppenderE15QHashDummyValueED1Ev@Base 2.0.11 (optional=templinst)_ZN5QHashIPN3Dtk4Core16AbstractAppenderE15QHashDummyValueED2Ev@Base 2.0.11 (optional=templinst)_ZN5QHashIi15QHashDummyValueE11deleteNode2EPN9QHashData4NodeE@Base 2.0.11 (optional=templinst)_ZN5QHashIi15QHashDummyValueE13duplicateNodeEPN9QHashData4NodeEPv@Base 2.0.11 (optional=templinst)_ZN5QHashIi7QStringE11deleteNode2EPN9QHashData4NodeE@Base 2.0.11 - (optional=templinst)_ZN5QHashIi7QStringE13detach_helperEv@Base 2.0.11 (optional=templinst)_ZN5QHashIi7QStringE13duplicateNodeEPN9QHashData4NodeEPv@Base 2.0.11 (optional=templinst)_ZN5QHashIi7QStringED1Ev@Base 2.0.11 (optional=templinst)_ZN5QHashIi7QStringED2Ev@Base 2.0.11 @@ -591,7 +588,6 @@ libdtkcore.so.2 libdtkcore2 #MINVER# _ZTIN3Dtk4Core9LogDeviceE@Base 2.0.11 _ZTISt11_Mutex_baseILN9__gnu_cxx12_Lock_policyE2EE@Base 2.0.11 _ZTISt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE@Base 2.0.11 - _ZTISt19_Sp_make_shared_tag@Base 2.0.11 _ZTISt23_Sp_counted_ptr_inplaceI9DDBusDataSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE@Base 2.0.11 _ZTISt23_Sp_counted_ptr_inplaceIN3Dtk4Core5DUtil11DNotifyDataESaIS3_ELN9__gnu_cxx12_Lock_policyE2EE@Base 2.0.11 _ZTSN3Dtk4Core12DFileWatcherE@Base 2.0.11 diff --git a/dtk_build_config.prf b/dtk_build_config.prf new file mode 100644 index 0000000..6610cd5 --- /dev/null +++ b/dtk_build_config.prf @@ -0,0 +1,77 @@ +isEmpty(DTK_MODULE_NAME): error(set DTK_MODULE_NAME first) +!contains(DTK_MODULE_NAME, ^dtk[a-z0-9]+$): error(The format of the value of DTK_MODULE_NAME is incorrect. eg: dtk[a-z0-9]+) +!isEqual(DTK_MODULE_NAME, dtkcore):!contains(QT, dtkcore): error(QT += dtkcore first) + +#将首字母改为大写 +defineReplace(capitalizingString) { + RAW=$$1 + FIRST = $$upper($$section(RAW, "", 1, 1)) + OTHERS = $$section(RAW, "", 2, -1) + return($$FIRST$$OTHERS) +} + +defineTest(checkDtkVersion) { + isEmpty(VERSION) { + !isEqual(TARGET, dtkcore) { + VERSION = $${QT.dtkcore.VERSION} + } + + # TODO: failed in windows + isEmpty(VERSION): VERSION = $$system(git describe --tags --abbrev=0) + isEmpty(VERSION): VERSION = $$DTK_VERSION + isEmpty(VERSION): return(false) + VERSION = $$replace(VERSION, [^0-9.],) + } + + export(VERSION) + return(true) +} + +!checkDtkVersion():error("check dtk version failed") + +message("build dtk with version $$VERSION") +ver_list = $$split(VERSION, .) + +isEmpty(VER_MAJ) { + VER_MAJ = $$first(ver_list) +} +isEmpty(VER_MIN) { + VER_MIN = $$member(ver_list, 1, 1) + isEmpty(VER_MIN):VER_MIN = 0 +} +isEmpty(VER_PAT) { + VER_PAT = $$member(ver_list, 2, 2) + isEmpty(VER_PAT):VER_PAT = 0 +} +isEmpty(VER_BUI) { + VER_BUI = $$member(ver_list, 3, 3) + isEmpty(VER_BUI):VER_BUI = 0 +} + +isEmpty(PREFIX){ + PREFIX = /usr +} + +isEmpty(LIB_INSTALL_DIR) { + isEqual(TARGET, dtkcore) { + LIB_INSTALL_DIR=$$PREFIX/lib + } else { + LIB_INSTALL_DIR=$${QT.dtkcore.libs} + } +} + +LIB_VERSION_NAME = libdtk-$${VER_MAJ}.$${VER_MIN}.$${VER_PAT} +MODULE_NAME = $$upper($$member($$list($$split(DTK_MODULE_NAME,)), 3, 3))$$join($$list($$member($$list($$split(DTK_MODULE_NAME,)), 4, -1))) +DMODULE_NAME = D$${MODULE_NAME} + +isEmpty(TOOL_INSTALL_DIR) { + TOOL_INSTALL_DIR=$$LIB_INSTALL_DIR/$$LIB_VERSION_NAME/$$DMODULE_NAME/bin +} + +isEmpty(INCLUDE_INSTALL_DIR) { + isEqual(DTK_MODULE_NAME, dtkcore) { + INCLUDE_INSTALL_DIR = $$PREFIX/include/$$LIB_VERSION_NAME/$$DMODULE_NAME + } else { + INCLUDE_INSTALL_DIR = $${QT.dtkcore.includes}/../$$DMODULE_NAME + } +} diff --git a/src/dtk_build.prf b/src/dtk_build.prf index 70bbf07..4543eff 100644 --- a/src/dtk_build.prf +++ b/src/dtk_build.prf @@ -1,87 +1,98 @@ -isEmpty(TARGET): error(set TARGET first) -!contains(TARGET, ^dtk[a-z0-9]+$): error(The format of the value of TARGET is incorrect. eg: dtk[a-z0-9]+) -!isEqual(TARGET, dtkcore):!contains(QT, dtkcore): error(QT += dtkcore first) - -defineTest(checkDtkVersion) { - isEmpty(VERSION) { - !isEqual(TARGET, dtkcore) { - VERSION = $${QT.dtkcore.VERSION} - } +exists(../dtk_build_config.prf) { + include(../dtk_build_config.prf) +} else { + load(dtk_build_config) +} - # TODO: failed in windows - isEmpty(VERSION): VERSION = $$system(git describe --tags --abbrev=0) - isEmpty(VERSION): VERSION = $$DTK_VERSION - isEmpty(VERSION): return(false) - VERSION = $$replace(VERSION, [^0-9.],) - } +#标记已经加载了dtk_build.prf +DTK_BUILD=1 +TEMPLATE = lib - export(VERSION) - return(true) -} +CONFIG += c++11 create_pc create_prl no_install_prl +CONFIG += no_keywords -!checkDtkVersion():error("check dtk version failed") +DEFINES += QT_MESSAGELOGCONTEXT +DEFINES += LIB$$upper($$DTK_MODULE_NAME)_LIBRARY +DEFINES += DTK_LIB_DIR_NAME=\\\"$$LIB_VERSION_NAME\\\" -message("build dtk with version $$VERSION") -ver_list = $$split(VERSION, .) +isEmpty(target.path): target.path = $$LIB_INSTALL_DIR +isEmpty(includes.path): includes.path = $$quote($$INCLUDE_INSTALL_DIR) -isEmpty(VER_MAJ) { - VER_MAJ = $$first(ver_list) -} -isEmpty(VER_MIN) { - VER_MIN = $$member(ver_list, 1, 1) - isEmpty(VER_MIN):VER_MIN = 0 -} -isEmpty(VER_PAT) { - VER_PAT = $$member(ver_list, 2, 2) - isEmpty(VER_PAT):VER_PAT = 0 +!isEmpty(DTK_STATIC_LIB) { + DEFINES += DTK_STATIC_LIB + CONFIG += staticlib } -isEmpty(VER_BUI) { - VER_BUI = $$member(ver_list, 3, 3) - isEmpty(VER_BUI):VER_BUI = 0 + +!isEmpty(DTK_STATIC_TRANSLATION) { + DEFINES += DTK_STATIC_TRANSLATION } -TEMPLATE = lib +defineTest(containIncludeFiles) { + header = $$absolute_path($$ARGS) + header_dir = $$quote($$dirname(header)) -CONFIG += c++11 create_pc create_prl no_install_prl -CONFIG += no_keywords + for (file, includes.files) { + file_ap = $$absolute_path($$file) + file_dir = $$quote($$dirname(file_ap)) -DEFINES += QT_MESSAGELOGCONTEXT -DEFINES += LIB$$upper($$TARGET)_LIBRARY + isEqual(file_dir, $$header_dir):return(true) + } -isEmpty(PREFIX){ - PREFIX = /usr + return(false) } -isEmpty(LIB_INSTALL_DIR) { - isEqual(TARGET, dtkcore) { - LIB_INSTALL_DIR=$$PREFIX/lib - } else { - LIB_INSTALL_DIR=$${QT.dtkcore.libs} +ALL_HEADER_FILE_NAME=Dtk$${MODULE_NAME}s + +#添加一个include模块提供的所有头文件的总的头文件 +defineTest(updateDtkHeaderFile) { + include_files = $$HEADERS + file_content = $$quote($${LITERAL_HASH}ifndef DTK_$$upper($$MODULE_NAME)_MODULE_H) + file_content += $$quote($${LITERAL_HASH}define DTK_$$upper($$MODULE_NAME)_MODULE_H) + + for(header, include_files) { + #排除私有头文件,以 _p.h 结尾的认为是私有头文件 + suffix = $$str_member($$header, -4, -1) + !isEqual(suffix, "_p.h"): containIncludeFiles($$header) { + file_content += $$quote($${LITERAL_HASH}include \"$$basename(header)\") + } } -} -isEmpty(BIN_INSTALL_DIR) { - TOOL_INSTALL_DIR=$$LIB_INSTALL_DIR/libdtk-$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}/D$$upper($$member($$list($$split(TARGET,)), 3, 3))$$join($$list($$member($$list($$split(TARGET,)), 4, -1)))/bin + file_content += $$quote($${LITERAL_HASH}endif) + !write_file($$_PRO_FILE_PWD_/$$ALL_HEADER_FILE_NAME, file_content):return(false) + + return(true) } -isEmpty(target.path): target.path = $$LIB_INSTALL_DIR +!updateDtkHeaderFile():warning(Cannot create "$${ALL_HEADER_FILE_NAME}" header file) + +# create dtkxxx_config.h file +defineTest(updateDtkConfigFile) { + isEqual(DTK_MODULE_NAME, dtkcore) { + config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_MAJOR $$VER_MAJ) + config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_MINOR $$VER_MIN) + config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_PATCH $$VER_PAT) + config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_BUILD $$VER_BUI) + config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_STR \"$$VERSION\") + config_content += $$quote(//) + } -isEmpty(INCLUDE_INSTALL_DIR) { - isEqual(TARGET, dtkcore) { - INCLUDE_INSTALL_DIR = $$PREFIX/include/libdtk-$${VER_MAJ}.$${VER_MIN}.$${VER_PAT} - } else { - INCLUDE_INSTALL_DIR = $${QT.dtkcore.includes}/.. + for(file, includes.files) { + file = $$quote($$basename(file)) + + !isEqual(file, $$ALL_HEADER_FILE_NAME):contains(file, D[A-Za-z0-9_]+) { + config_content += $$quote($${LITERAL_HASH}define $$upper($$DTK_MODULE_NAME)_CLASS_$$file) + } } -} -DTK_INCLUDEPATH = $$INCLUDE_INSTALL_DIR -isEmpty(includes.path): includes.path = $$quote($$DTK_INCLUDEPATH/D$$upper($$member($$list($$split(TARGET,)), 3, 3))$$join($$list($$member($$list($$split(TARGET,)), 4, -1))),) + !write_file($$_PRO_FILE_PWD_/$${DTK_MODULE_NAME}_config.h, config_content):return(false) -!isEmpty(DTK_STATIC_LIB) { - DEFINES += DTK_STATIC_LIB - CONFIG += staticlib + return(true) } -!isEmpty(DTK_STATIC_TRANSLATION) { - DEFINES += DTK_STATIC_TRANSLATION +!updateDtkConfigFile():warning(Cannot create "$${DTK_MODULE_NAME}_config.h" header file) + +exists($$PWD/dtk_translation.prf) { + include($$PWD/dtk_translation.prf) +} else { + load(dtk_translation) } diff --git a/src/dtk_cmake.prf b/src/dtk_cmake.prf index 601289d..ecc91ac 100644 --- a/src/dtk_cmake.prf +++ b/src/dtk_cmake.prf @@ -2,19 +2,10 @@ #TODO: check cmake exist -defineReplace(capitalizingString) { - RAW=$$1 - FIRST = $$upper($$section(RAW, "", 1, 1)) - OTHERS = $$section(RAW, "", 2, -1) - return($$FIRST$$OTHERS) -} - !win*: { MODULE_DEPENDS=$$find(QT, dtk*) CMAKE_MODULE_DEPENDS=$$replace(MODULE_DEPENDS,"dtk","") -MODULE_NAME=$$replace(TARGET,"dtk","") -MODULE_NAME=$$capitalizingString($$MODULE_NAME) CMAKE_MODULE=Dtk$$MODULE_NAME WORK_DIR=$$_PRO_FILE_PWD_ @@ -30,7 +21,7 @@ for(MODULE_DEPEND, CMAKE_MODULE_DEPENDS) { } CMAKE_MODULE_INCLUDE_DIR=$$upper($${CMAKE_MODULE})_INCLUDE_DIR -INC_DIR = $$replace(includes.path, "/", "/") +INC_DIR = $$replace(INCLUDE_INSTALL_DIR, "/", "/") CMAKE_MODULE_TOO_DIR=$$upper($${CMAKE_MODULE})_TOOL_DIR TOOL_DIR = $$TOOL_INSTALL_DIR diff --git a/src/dtk_lib.prf b/src/dtk_lib.prf index b57d004..047643e 100644 --- a/src/dtk_lib.prf +++ b/src/dtk_lib.prf @@ -1,9 +1,3 @@ -exists($$_PRO_FILE_PWD_/src/dtk_translation.prf) { - include($$_PRO_FILE_PWD_/src/dtk_translation.prf) -} else { - load(dtk_translation) -} - TEMPLATE = subdirs CONFIG += ordered diff --git a/src/dtk_module.prf b/src/dtk_module.prf index 9b5108c..1774a4b 100644 --- a/src/dtk_module.prf +++ b/src/dtk_module.prf @@ -1,17 +1,14 @@ -isEmpty(DTK_MODULE): DTK_MODULE=$$TARGET -isEmpty(DTK_MODULE): error("DTK_MODULE must not empty") -isEmpty(includes.path): error("includes.path must not empty, please load(dtk_build) first!") -isEmpty(target.path): error("target.path must not empty, , please load(dtk_build) first!") +isEmpty(DTK_BUILD): error("Please load(dtk_build) first!") # ----------------------- # Config Qt module -MODULE_ID=$$DTK_MODULE +MODULE_ID=$$DTK_MODULE_NAME mod_inst_pfx=$$_PRO_FILE_PWD_ MODULE_PRI = $$mod_inst_pfx/qt_lib_$${MODULE_ID}.pri -module_libs = $$target.path +module_libs = $$LIB_INSTALL_DIR module_tools = $$TOOL_INSTALL_DIR -MODULE_INCLUDES = $$includes.path -DTK_MODULE_DEPENDS=$$find(QT, dtk*) +MODULE_INCLUDES = $$INCLUDE_INSTALL_DIR +MODULE_DEPENDS=$$find(QT, dtk*) message("config qt module: $$MODULE_ID") message("write $$MODULE_PRI to: $$mod_inst_pfx") @@ -22,7 +19,7 @@ else: \ MODULE_DEPENDS = $$replace(QT, -private$, ) MODULE_DEPENDS = $$unique(MODULE_DEPENDS) contains(MODULE_DEPENDS, $$MODULE): \ - error("$$TARGET depends on itself.") + error("$$MODULE_ID depends on itself.") # Create a module .pri file module_libs=$$LIB_INSTALL_DIR @@ -32,9 +29,7 @@ host_build: \ else: \ module_libs = "\$\$QT_MODULE_LIB_BASE" } -isEmpty(module_tools) { - module_tools=$$module_libs/libdtk-$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}/D$$upper($$member($$list($$split(TARGET,)), 3, 3))$$join($$list($$member($$list($$split(TARGET,)), 4, -1)))/bin -} + # In addition to the library's private deps, the private module's deps # are logically runtime deps of the public module. runtime_deps = $$QT_PRIVATE $$QT_FOR_PRIVATE @@ -55,7 +50,7 @@ ltcg: \ module_build_type += ltcg module_module = !equals(TEMPLATE, aux) { - module_module = $$TARGET$$QT_LIBINFIX + module_module = $$MODULE_ID$$QT_LIBINFIX !lib_bundle: module_module ~= s,^Qt,Qt$$QT_MAJOR_VERSION, } !isEmpty(MODULE_CONFIG): \ @@ -73,11 +68,11 @@ else: \ MODULE_PRI_CONT = \ "QT.$${MODULE_ID}.VERSION = $${VERSION}" \ - "QT.$${MODULE_ID}.MAJOR_VERSION = $$section(VERSION, ., 0, 0)" \ - "QT.$${MODULE_ID}.MINOR_VERSION = $$section(VERSION, ., 1, 1)" \ - "QT.$${MODULE_ID}.PATCH_VERSION = $$section(VERSION, ., 2, 2)" \ + "QT.$${MODULE_ID}.MAJOR_VERSION = $${VER_MAJ}" \ + "QT.$${MODULE_ID}.MINOR_VERSION = $${VER_MIN}" \ + "QT.$${MODULE_ID}.PATCH_VERSION = $${VER_PAT}" \ "" \ - "QT.$${MODULE_ID}.name = $${TARGET}" \ + "QT.$${MODULE_ID}.name = $${MODULE_ID}" \ "QT.$${MODULE_ID}.module = $$module_module" \ "QT.$${MODULE_ID}.tools = $$module_tools" \ "QT.$${MODULE_ID}.libs = $$module_libs" \ @@ -105,28 +100,28 @@ qt_module.path = $${MKSPECS_INSTALL_DIR}/modules INSTALLS += qt_module +PKG_MODULE_DEPENDS=$$find(QT, dtk*) + +#不能添加Qt包的依赖,无法单纯的从Qt模块名称获取其pkgconfig的pc文件名 +#for (qt_module, QT) { +# #DBus模块需要特殊处理 +# isEqual(qt_module, "dbus") { +# PKG_MODULE_DEPENDS+=Qt5DBus +# } else { +# suffix = $$str_member($$qt_module, -7, -1) +# #排除以private结尾的模块 +# !isEqual(suffix, "private"): PKG_MODULE_DEPENDS+=Qt5$$capitalizingString($$qt_module) +# } +#} + +PKG_MODULE_DEPENDS = $$unique(PKG_MODULE_DEPENDS) # ----------------------- # Config pkg-config QMAKE_PKGCONFIG_VERSION = $$VERSION QMAKE_PKGCONFIG_DESTDIR = pkgconfig -QMAKE_PKGCONFIG_NAME = DTK_$$upper($$replace(TARGET, "dtk", "")) -QMAKE_PKGCONFIG_DESCRIPTION = Deepin Tool Kit $$TARGET header files -QMAKE_PKGCONFIG_REQUIRES += $$DTK_MODULE_DEPENDS +QMAKE_PKGCONFIG_NAME = DTK_$$upper($$MODULE_ID) +QMAKE_PKGCONFIG_DESCRIPTION = Deepin Tool Kit $$MODULE_ID header files +QMAKE_PKGCONFIG_REQUIRES += $$PKG_MODULE_DEPENDS QMAKE_PKGCONFIG_INCDIR = $$includes.path QMAKE_PKGCONFIG_LIBDIR = $$target.path - - -# ----------------------- -# Config translations -!isEmpty(DTK_STATIC_TRANSLATION) { - QRC_PATH = $$mod_inst_pfx/../translations/$${TARGET}_translations.qrc - RESOURCES += $$QRC_PATH -} - -TRANSLATIONS += $$mod_inst_pfx/.../translations/* - -dtk_translations.path = $$PREFIX/share/$${TARGET}/translations -dtk_translations.files = $$mod_inst_pfx/../translations/*.qm - -INSTALLS += dtk_translations diff --git a/src/dtk_translation.prf b/src/dtk_translation.prf index 4d4efa0..76a75dc 100644 --- a/src/dtk_translation.prf +++ b/src/dtk_translation.prf @@ -24,9 +24,9 @@ isEmpty(DTK_NO_TRANSLATION) { # qrc template # # - # dtkwidget2_am_ET.qm - # dtkwidget2_ar.qm - # dtkwidget2_ast.qm + # dtkwidget_am_ET.qm + # dtkwidget_ar.qm + # dtkwidget_ast.qm # # QRC_PATH = $$ROOT_DIR/translations/$${BASENAME}_translations.qrc @@ -44,3 +44,20 @@ isEmpty(DTK_NO_TRANSLATION) { write_file($$QRC_PATH, QRC_CONTENT) | error("Aborting.") } } + +!isEmpty(DTK_STATIC_TRANSLATION) { + QRC_PATH = $$ROOT_DIR/translations/$${TARGET}_translations.qrc + RESOURCES += $$QRC_PATH +} + +TRANSLATIONS += $$ROOT_DIR/translations/* + +TRANSLATIONS_DIR = $$LIB_VERSION_NAME/$$DMODULE_NAME/translations +TRANSLATIONS_PATH = $$PREFIX/share/$$TRANSLATIONS_DIR +DEFINES += $$upper($$DMODULE_NAME)_TRANSLATIONS_PATH=\\\"$$TRANSLATIONS_PATH\\\" +DEFINES += $$upper($$DMODULE_NAME)_TRANSLATIONS_DIR=\\\"$$TRANSLATIONS_DIR\\\" + +dtk_translations.path = $$TRANSLATIONS_PATH +dtk_translations.files = $$ROOT_DIR/translations/*.qm + +INSTALLS += dtk_translations diff --git a/src/settings/backend/gsettingsbackend.cpp b/src/settings/backend/gsettingsbackend.cpp index 0b076bc..56795ef 100644 --- a/src/settings/backend/gsettingsbackend.cpp +++ b/src/settings/backend/gsettingsbackend.cpp @@ -48,9 +48,9 @@ public: * \class GSettingsBackend * \brief Storage backend of DSettings use gsettings. * - * You should generate gsetting schema with /usr/lib/dtk2/dtk-settings. + * You should generate gsetting schema with /usr/lib/x86_64-linux-gnu/libdtk-$$VERSION/DCore/bin/dtk-settings. * - * You can find this tool from libdtkcore-bin. use /usr/lib/dtk2/dtk-settings -h for help. + * You can find this tool from libdtkcore-bin. use /usr/lib/x86_64-linux-gnu/libdtk-$$VERSION/DCore/bin/dtk-settings -h for help. */ GSettingsBackend::GSettingsBackend(DSettings *settings, QObject *parent) : diff --git a/src/src.pro b/src/src.pro index 0a5c0ad..00e8fbd 100644 --- a/src/src.pro +++ b/src/src.pro @@ -4,8 +4,6 @@ QT += xml CONFIG += link_pkgconfig TARGET = dtkcore -include(dtk_build.prf) - INCLUDEPATH += $$PWD HEADERS += $$PWD/dtkcore_global.h \ dsysinfo.h @@ -19,72 +17,15 @@ include($$PWD/log/log.pri) include($$PWD/filesystem/filesystem.pri) include($$PWD/settings/settings.pri) -# create DtkCore file -defineTest(containIncludeFiles) { - header = $$absolute_path($$ARGS) - header_dir = $$quote($$dirname(header)) - - for (file, includes.files) { - file_ap = $$absolute_path($$file) - file_dir = $$quote($$dirname(file_ap)) - - isEqual(file_dir, $$header_dir) { - return(true) - } - } - - return(false) -} - -defineTest(updateDtkCoreFile) { - include_files = $$HEADERS - file_content = $$quote($${LITERAL_HASH}ifndef DTK_CORE_MODULE_H) - file_content += $$quote($${LITERAL_HASH}define DTK_CORE_MODULE_H) - - for(header, include_files) { - containIncludeFiles($$header) { - file_content += $$quote($${LITERAL_HASH}include \"$$basename(header)\") - } - } - - file_content += $$quote($${LITERAL_HASH}endif) - !write_file($$PWD/DtkCore, file_content):return(false) - - return(true) -} - -!updateDtkCoreFile():warning(Cannot create "DtkCore" header file) - -# create dtkwidget_config.h file -defineTest(updateDtkCoreConfigFile) { - config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_MAJOR $$VER_MAJ) - config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_MINOR $$VER_MIN) - config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_PATCH $$VER_PAT) - config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_BUILD $$VER_BUI) - config_content += $$quote($${LITERAL_HASH}define DTK_VERSION_STR \"$$VERSION\") - config_content += $$quote(//) - - for(file, includes.files) { - file = $$quote($$basename(file)) - - !isEqual(file, DtkCore):contains(file, D[A-Za-z0-9_]+) { - config_content += $$quote($${LITERAL_HASH}define DTKCORE_CLASS_$$file) - } - } - - !write_file($$PWD/dtkcore_config.h, config_content):return(false) - - return(true) -} - -!updateDtkCoreConfigFile():warning(Cannot create "dtkcore_config.h" header file) +DTK_MODULE_NAME = $$TARGET +include(dtk_build.prf) # ---------------------------------------------- # install config includes.files += \ $$PWD/*.h \ $$PWD/dtkcore_config.h \ - $$PWD/DtkCore \ + $$PWD/DtkCores \ $$PWD/DSysInfo INSTALLS += includes target @@ -101,22 +42,14 @@ include(dtk_cmake.prf) #qt module include(dtk_module.prf) -prf.files+= $$PWD/*.prf +prf.files+= $$PWD/*.prf ../dtk_build_config.prf isEmpty(MKSPECS_INSTALL_DIR) { MKSPECS_INSTALL_DIR=$$[QT_INSTALL_ARCHDATA]/mkspecs } prf.path = $${MKSPECS_INSTALL_DIR}/features -linux { - # dtk for qmake - include(dtk_qmake.prf) - - deepin_os_release_tool.files=$$PWD/../bin/deepin-os-release - deepin_os_release_tool.path=$$TOOL_INSTALL_DIR - - INSTALLS += deepin_os_release_tool -} else { +!linux { prf.files-=$$PWD/dtk_qmake.prf } diff --git a/tools/deepin-os-release/deepin-os-release.pro b/tools/deepin-os-release/deepin-os-release.pro index f56dd76..ba7d1d3 100644 --- a/tools/deepin-os-release/deepin-os-release.pro +++ b/tools/deepin-os-release/deepin-os-release.pro @@ -10,3 +10,9 @@ SOURCES += \ INCLUDEPATH += ../../src DESTDIR = $$_PRO_FILE_PWD_/../../bin + +DTK_MODULE_NAME=dtkcore +include(../../dtk_build_config.prf) +target.path = $$TOOL_INSTALL_DIR + +INSTALLS += target diff --git a/tools/settings/main.cpp b/tools/settings/main.cpp index afe939e..52970c7 100644 --- a/tools/settings/main.cpp +++ b/tools/settings/main.cpp @@ -33,7 +33,13 @@ #include +#ifndef DTK_SETTINGS_TOOLS_VERSION +#define DTK_SETTINGS_TOOLS_VERSION "0.1.2" +#endif // DTK_SETTINGS_TOOLS_VERSION + static QString CppTemplate = + "// This file was generated by dtk-settings-tools version " DTK_SETTINGS_TOOLS_VERSION " \n" + "\n" "#include \n" "\n" "void GenerateSettingTranslate()\n" @@ -185,7 +191,7 @@ int main(int argc, char *argv[]) QCoreApplication app(argc, argv); app.setOrganizationName("deepin"); app.setApplicationName("dtk-settings-tools"); - app.setApplicationVersion("0.1.2"); + app.setApplicationVersion(DTK_SETTINGS_TOOLS_VERSION); QCommandLineParser parser; parser.setApplicationDescription("Generate translation of dtksetting."); @@ -238,18 +244,24 @@ int main(int argc, char *argv[]) auto codeKey = QString(key).replace(".", "_"); auto opt = settings->option(key); + QStringList skipI18nKeys = opt->data("i18n_skip_keys").toStringList(); + + if (skipI18nKeys.contains("all")) { + continue; + } + // add Name - if (!opt->name().isEmpty()) { + if (!opt->name().isEmpty() && !skipI18nKeys.contains("name")) { transtaleMaps.insert(codeKey + "Name", opt->name()); } // add text - if (!opt->data("text").toString().isEmpty()) { + if (!opt->data("text").toString().isEmpty() && !skipI18nKeys.contains("text")) { transtaleMaps.insert(codeKey + "Text", opt->data("text").toString()); } // add items - if (!opt->data("items").toStringList().isEmpty()) { + if (!opt->data("items").toStringList().isEmpty() && !skipI18nKeys.contains("items")) { auto items = opt->data("items").toStringList(); for (int i = 0; i < items.length(); ++i) { transtaleMaps.insert(codeKey + QString("Text%1").arg(i), items.value(i)); @@ -257,8 +269,6 @@ int main(int argc, char *argv[]) } } - transtaleMaps.insert("reset_button_name", "Restore Defaults"); - QString cppCode; for (auto key : transtaleMaps.keys()) { auto stringCode = QString(" auto %1 = QObject::tr(\"%2\");\n").arg(key).arg(transtaleMaps.value(key)); diff --git a/tools/settings/settings.pro b/tools/settings/settings.pro index d51c2ea..ed623f0 100644 --- a/tools/settings/settings.pro +++ b/tools/settings/settings.pro @@ -12,26 +12,23 @@ TEMPLATE = app SOURCES += main.cpp -isEmpty(PREFIX){ - PREFIX = /usr -} -isEmpty(BIN_INSTALL_DIR) { - BIN_INSTALL_DIR=$${PREFIX}/lib/dtk2 -} !isEmpty(DTK_STATIC_LIB){ DEFINES += DTK_STATIC_LIB } -target.path = $${BIN_INSTALL_DIR} - -script.files += $${PWD}/../script/*.py -script.path = $${BIN_INSTALL_DIR} - -INSTALLS += target script - win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../src/release/ -ldtkcore else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../src/debug/ -ldtkcore else:unix: LIBS += -L$$OUT_PWD/../../src/ -ldtkcore INCLUDEPATH += $$PWD/../../src DEPENDPATH += $$PWD/../../src +DESTDIR = $$_PRO_FILE_PWD_/../../bin + +DTK_MODULE_NAME=dtkcore +include(../../dtk_build_config.prf) +target.path = $$TOOL_INSTALL_DIR + +scripts.files += ../script/*.py +scripts.path = $$TOOL_INSTALL_DIR + +INSTALLS += target scripts