From f17f098376cca6558a6c4743eff7c3ec3cf9a47e Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Mon, 13 Oct 2025 02:37:41 +0000 Subject: [PATCH] sync: from linuxdeepin/dtkgui Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: https://github.com/linuxdeepin/dtkgui/pull/345 --- dtkgui.cmake | 14 +++++---- src/CMakeLists.txt | 7 ++++- src/kernel/dguiapplicationhelper.cpp | 29 +++++++++++-------- .../config.tests/treeland_test/CMakeLists.txt | 5 ++++ tests/CMakeLists.txt | 13 +++++++-- 5 files changed, 47 insertions(+), 21 deletions(-) diff --git a/dtkgui.cmake b/dtkgui.cmake index c721fff..92be3af 100644 --- a/dtkgui.cmake +++ b/dtkgui.cmake @@ -18,11 +18,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Set build option option(DTK_DISABLE_LIBXDG "Disable libxdg" OFF) -find_package(Qt${QT_VERSION_MAJOR}XdgIconLoader) -if (NOT Qt${QT_VERSION_MAJOR}XdgIconLoader_FOUND) - message(WARNING " XdgIconLoader Not Found, DISABLE LIBXDG !") - set (DTK_DISABLE_LIBXDG ON) -endif() option(DTK_DISABLE_LIBRSVG "Disable librsvg" OFF) option(DTK_DISABLE_EX_IMAGE_FORMAT "Disable libraw and freeimage" OFF) @@ -120,6 +115,15 @@ find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED Core) find_package(DtkBuildHelper REQUIRED) pkg_check_modules(librsvg REQUIRED IMPORTED_TARGET librsvg-2.0) +# Only use libxdg under Qt5 +if(NOT DTK_DISABLE_LIBXDG AND ${QT_VERSION_MAJOR} STREQUAL "5") + find_package(Qt5XdgIconLoader REQUIRED) + if (NOT Qt5XdgIconLoader_FOUND) + message(WARNING " XdgIconLoader Not Found, DISABLE LIBXDG !") + set (DTK_DISABLE_LIBXDG ON) + endif() +endif() + # Check optional image handler dependencies. find_package(FreeImage) pkg_check_modules(libraw IMPORTED_TARGET libraw) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 71086b0..e663d1f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,10 @@ if("${QT_VERSION_MAJOR}" STREQUAL "6") - find_package(Qt6 REQUIRED COMPONENTS Core Widgets WaylandClient) + find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets WaylandClient) + + if (${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0") + set(QT_NO_PRIVATE_MODULE_WARNING ON) + find_package(Qt6 REQUIRED COMPONENTS CorePrivate GuiPrivate WaylandClientPrivate) + endif() else() find_package(Qt5 REQUIRED COMPONENTS WaylandClient XkbCommonSupport) endif() diff --git a/src/kernel/dguiapplicationhelper.cpp b/src/kernel/dguiapplicationhelper.cpp index abf55ce..03298c3 100644 --- a/src/kernel/dguiapplicationhelper.cpp +++ b/src/kernel/dguiapplicationhelper.cpp @@ -392,7 +392,12 @@ void DGuiApplicationHelperPrivate::notifyAppThemeChanged() void DGuiApplicationHelperPrivate::notifyAppThemeChangedByEvent() { + // https://github.com/qt/qtbase/commit/68a9c5fe513e147e4cffd29b50a4714813df411e +#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0) + QWindowSystemInterfacePrivate::ThemeChangeEvent event; +#else QWindowSystemInterfacePrivate::ThemeChangeEvent event(nullptr); +#endif // 此事件会促使QGuiApplication重新从QPlatformTheme中获取系统级别的QPalette. // 而在deepin平台下, 系统级别的QPalette来源自 \a applicationPalette() QGuiApplicationPrivate::processThemeChanged(&event); @@ -509,13 +514,13 @@ DGuiApplicationHelper::SizeMode DGuiApplicationHelperPrivate::fetchSizeMode(bool /*! \enum DGuiApplicationHelper::ColorType DGuiApplicationHelper::ColorType 定义了主题类型. - + \var DGuiApplicationHelper::ColorType DGuiApplicationHelper::UnknownType 未知主题(浅色主题或深色主题) - + \var DGuiApplicationHelper::ColorType DGuiApplicationHelper::LightType 浅色主题 - + \var DGuiApplicationHelper::ColorType DGuiApplicationHelper::DarkType 深色主题 */ @@ -523,28 +528,28 @@ DGuiApplicationHelper::SizeMode DGuiApplicationHelperPrivate::fetchSizeMode(bool /*! \enum DGuiApplicationHelper::Attribute DGuiApplicationHelper::Attribute 定义了功能属性 - + \var DGuiApplicationHelper::Attribute DGuiApplicationHelper::UseInactiveColorGroup 如果开启,当窗口处于Inactive状态时就会使用QPalette::Inactive的颜色,否则窗口将没有任何颜色变化。 - + \var DGuiApplicationHelper::Attribute DGuiApplicationHelper::ColorCompositing 是否采用半透明样式的调色板。 - + \var DGuiApplicationHelper::Attribute DGuiApplicationHelper::ReadOnlyLimit 区分只读枚举。 - + \var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsDeepinPlatformTheme 获取当前是否使用deepin的platformtheme插件,platformtheme插件可以为Qt程序提供特定的控件样式,默认使用chameleon主题。 - + \var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsDXcbPlatform 获取当前使用的是不是dtk的xcb窗口插件,dxcb插件提供了窗口圆角和阴影功能。 - + \var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsXWindowPlatform 获取当前是否运行在X11环境中。 - + \var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsTableEnvironment 获取当前是否运行在deepin平板环境中,检测XDG_CURRENT_DESKTOP环境变量是不是tablet结尾。 - + \var DGuiApplicationHelper::Attribute DGuiApplicationHelper::IsDeepinEnvironment 获取当前是否运行在deepin桌面环境中,检测XDG_CURRENT_DESKTOP环境变量是不是deepin。 */ @@ -1723,7 +1728,7 @@ bool DGuiApplicationHelper::loadTranslator(const QString &fileName, const QList< if (locale.language() != QLocale::English) // English does not need translation localeNames << locale.name(); } - + if (!localeNames.isEmpty()) { qWarning() << fileName << "can not find qm files for locales" << localeNames; } diff --git a/src/plugins/platform/config.tests/treeland_test/CMakeLists.txt b/src/plugins/platform/config.tests/treeland_test/CMakeLists.txt index 4c12e76..862e858 100644 --- a/src/plugins/platform/config.tests/treeland_test/CMakeLists.txt +++ b/src/plugins/platform/config.tests/treeland_test/CMakeLists.txt @@ -28,6 +28,11 @@ if("${QT_VERSION_MAJOR}" STREQUAL "6") qt6_generate_wayland_protocol_client_sources(${PROJECT_NAME} FILES ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-personalization-manager-v1.xml ) + + if (${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0") + set(QT_NO_PRIVATE_MODULE_WARNING ON) + find_package(Qt6 REQUIRED COMPONENTS GuiPrivate CorePrivate WaylandClientPrivate) + endif() else() # ECM setup include(FeatureSummary) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0782182..bbe6815 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,13 @@ set(BIN_NAME ut-DtkGui) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Test) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets DBus Network Test) +if ("${QT_VERSION_MAJOR}" STREQUAL "6") + if (${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0") + set(QT_NO_PRIVATE_MODULE_WARNING ON) + find_package(Qt6 REQUIRED COMPONENTS CorePrivate GuiPrivate WaylandClientPrivate) + endif() +endif() + find_package(GTest REQUIRED) file(GLOB test_SRC @@ -44,7 +51,7 @@ target_link_libraries(${BIN_NAME} PRIVATE m ) -if(NOT DTK_DISABLE_EX_IMAGE_FORMAT AND EX_IMAGE_FORMAT_LIBS_FOUND) +if(NOT DTK_DISABLE_EX_IMAGE_FORMAT AND EX_IMAGE_FORMAT_LIBS_FOUND) target_link_libraries(${BIN_NAME} PRIVATE PkgConfig::libraw FreeImage::FreeImage @@ -52,7 +59,7 @@ target_link_libraries(${BIN_NAME} PRIVATE endif() if(NOT DTK_DISABLE_LIBXDG) - target_link_libraries(${BIN_NAME} PRIVATE + target_link_libraries(${BIN_NAME} PRIVATE Qt${QT_VERSION_MAJOR}XdgIconLoader ) endif()