From b2471667e1377df998ec50a6f952f3d164e73e3d Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周三, 27 12月 2023 04:21:30 +0800 Subject: [PATCH] Add style option back --- src/core/CMakeLists.txt | 7 ++++++- examples/mainwindow/mainwindow.h | 2 -- src/CMakeLists.txt | 3 +++ CMakeLists.txt | 1 + examples/mainwindow/mainwindow.cpp | 10 ---------- src/core/style/styleagent.cpp | 4 ++++ 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 001d00c..1c67f13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ option(QWINDOWKIT_ENABLE_QT_WINDOW_CONTEXT "Enable Qt Window Context anyway" OFF) option(QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS "Enable system borders on Windows" ON) +option(QWINDOWKIT_ENABLE_STYLE_AGENT "Enable building style agent" ON) # ---------------------------------- # CMake Settings diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp index b445ce3..206b7f2 100644 --- a/examples/mainwindow/mainwindow.cpp +++ b/examples/mainwindow/mainwindow.cpp @@ -14,7 +14,6 @@ # include <QtWidgets/QActionGroup> #endif -#include <QWKCore/styleagent.h> #include <QWKWidgets/widgetwindowagent.h> #include <widgetframe/windowbar.h> @@ -37,7 +36,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { installWindowAgent(); - installStyleAgent(); auto clockWidget = new ClockWidget(); clockWidget->setObjectName(QStringLiteral("clock-widget")); @@ -288,14 +286,6 @@ }); connect(windowBar, &QWK::WindowBar::closeRequested, this, &QWidget::close); #endif -} - -void MainWindow::installStyleAgent() { - styleAgent = new QWK::StyleAgent(this); - - connect(styleAgent, &QWK::StyleAgent::systemThemeChanged, this, [this]() { - qDebug() << "System style changed:" << styleAgent->systemTheme(); // - }); } void MainWindow::loadStyleSheet(Theme theme) { diff --git a/examples/mainwindow/mainwindow.h b/examples/mainwindow/mainwindow.h index a0f7671..e7b601d 100644 --- a/examples/mainwindow/mainwindow.h +++ b/examples/mainwindow/mainwindow.h @@ -28,13 +28,11 @@ private: void installWindowAgent(); - void installStyleAgent(); void loadStyleSheet(Theme theme); Theme currentTheme{}; QWK::WidgetWindowAgent *windowAgent; - QWK::StyleAgent *styleAgent; }; #endif // MAINWINDOW_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d847a76..760c5c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,6 +17,9 @@ qm_add_definition(QWINDOWKIT_ENABLE_QT_WINDOW_CONTEXT CONDITION QWINDOWKIT_ENABLE_QT_WINDOW_CONTEXT ) +qm_add_definition(QWINDOWKIT_ENABLE_STYLE_AGENT + CONDITION QWINDOWKIT_ENABLE_STYLE_AGENT +) qm_add_definition(QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS CONDITION QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS ) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c00cea0..ddede41 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -65,7 +65,9 @@ endif() endif() -if(TRUE) +set(_sync_include_options) + +if(QWINDOWKIT_ENABLE_STYLE_AGENT) list(APPEND _src style/styleagent.h style/styleagent_p.h @@ -79,6 +81,8 @@ else() list(APPEND _src style/styleagent_linux.cpp) endif() +else() + list(APPEND _sync_include_options EXCLUDE "style/\\.+") endif() qwk_add_library(${PROJECT_NAME} AUTOGEN @@ -89,6 +93,7 @@ QT_INCLUDE_PRIVATE Core Gui INCLUDE_PRIVATE kernel contexts shared PREFIX QWK_CORE + SYNC_INCLUDE_OPTIONS ${_sync_include_options} ) set_target_properties(${PROJECT_NAME} PROPERTIES diff --git a/src/core/style/styleagent.cpp b/src/core/style/styleagent.cpp index 11d1adc..192995b 100644 --- a/src/core/style/styleagent.cpp +++ b/src/core/style/styleagent.cpp @@ -8,6 +8,10 @@ /*! \class StyleAgent \brief StyleAgent provides some features related to system theme. + + Qt6.6 started to support system theme detection, this class is intended as an auxiliary + support for lower versions of Qt. If your Qt already supports it, it is recommended that + you don't include this class in your build system. */ StyleAgentPrivate::StyleAgentPrivate() { -- Gitblit v1.9.1