diff --git a/CMake/xToolsCommon.cmake b/CMake/xToolsCommon.cmake index f77fa499..3941ab57 100644 --- a/CMake/xToolsCommon.cmake +++ b/CMake/xToolsCommon.cmake @@ -1,6 +1,6 @@ add_compile_definitions(X_TOOLS_AUTHOR="x-tools-author") add_compile_definitions(X_TOOLS_EDITION="beta1") -add_compile_definitions(X_TOOLS_VERSION="5.0.0") +add_compile_definitions(X_TOOLS_VERSION="6.0.0") add_compile_definitions(X_TOOLS_DEFAULT_APP_STYLE="Fusion") add_compile_definitions(X_TOOLS_CLEAR_MESSAGE_INTERVAL=8000) add_compile_definitions(X_TOOLS_AUTHOR_EMAIL="x-tools@outlook.com") diff --git a/Source/Common/CommonUI/xTools.h b/Source/Common/CommonUI/xTools.h index 04430950..6ae3ad0a 100644 --- a/Source/Common/CommonUI/xTools.h +++ b/Source/Common/CommonUI/xTools.h @@ -25,6 +25,9 @@ #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) #include "xToolsDataStructure.h" #endif +#ifdef X_TOOLS_ENABLE_ADVANCED_STYLESHEET +#include "xToolsStyleSheetManager.h" +#endif #ifdef X_TOOLS_IMPORT_MODULE_GLOG static void xToolsInitGoogleLogging(char *argv0) @@ -194,7 +197,16 @@ int xToolsExec(int argc, char *argv[], const QString &appName) AppT app(argc, argv); const QString dtStr = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"); xToolsSettings::instance()->setValue("startUpTime", dtStr); + +#ifdef X_TOOLS_ENABLE_ADVANCED_STYLESHEET + auto &styleSheetManager = xToolsStyleSheetManager::instance(); + const QString styleSheet = styleSheetManager.styleSheet(); + if (!styleSheet.isEmpty() && !styleSheetManager.currentTheme().isEmpty()) { + app.setStyleSheet(styleSheet); + } +#else xToolsInitAppStyle(); +#endif QWidget *ui; if (xToolsIsSameType()) { diff --git a/Source/Common/CommonUI/xToolsMainWindow.cpp b/Source/Common/CommonUI/xToolsMainWindow.cpp index 51424522..730d44bf 100644 --- a/Source/Common/CommonUI/xToolsMainWindow.cpp +++ b/Source/Common/CommonUI/xToolsMainWindow.cpp @@ -43,11 +43,6 @@ xToolsMainWindow::xToolsMainWindow(QWidget* parent) m_xToolsApp = dynamic_cast(qApp); Q_ASSERT_X(m_xToolsApp, Q_FUNC_INFO, "The application is not xToolsApplication."); -#ifdef X_TOOLS_ENABLE_ADVANCED_STYLESHEET - auto& styleSheetManager = xToolsStyleSheetManager::instance(); - styleSheetManager.setThemeName(styleSheetManager.themeName()); -#endif - m_appStyleActionGroup = new QActionGroup(this); m_languageActionGroup = new QActionGroup(this); m_appPaletteActionGroup = new QActionGroup(this); @@ -56,6 +51,12 @@ xToolsMainWindow::xToolsMainWindow(QWidget* parent) initMenuOption(); initMenuLanguage(); initMenuHelp(); +#ifdef X_TOOLS_ENABLE_ADVANCED_STYLESHEET + connect(&xToolsStyleSheetManager::instance(), + &xToolsStyleSheetManager::stylesheetChanged, + this, + [=]() { tryToReboot(); }); +#endif } QString xToolsMainWindow::qtConfFileName() diff --git a/Source/Optional/xToolsStyleSheetManager.cpp b/Source/Optional/xToolsStyleSheetManager.cpp index 11bbca87..ce2c7f10 100644 --- a/Source/Optional/xToolsStyleSheetManager.cpp +++ b/Source/Optional/xToolsStyleSheetManager.cpp @@ -56,13 +56,11 @@ QString xToolsStyleSheetManager::themeName() void xToolsStyleSheetManager::setThemeName(const QString& themeName) { - qInfo() << "The stylesheet is setting to: " << themeName; setCurrentTheme(themeName); - qInfo() << "The stylesheet is updating..."; updateStylesheet(); - qInfo() << "The stylesheet is setting to the application..."; +#if 0 qApp->setStyleSheet(styleSheet()); - xToolsSettings::instance()->setValue("themeName", themeName); +#endif qInfo() << "The stylesheet has been changed: " << this->currentTheme(); } @@ -105,4 +103,4 @@ void xToolsStyleSheetManager::loadThemes() setupActions(m_darkThemes, m_darkThemeMenu, m_darkThemeActionGroup); setupActions(m_lightThemes, m_lightThemeMenu, m_lightThemeActionGroup); -} \ No newline at end of file +} diff --git a/xTools.pro b/xTools.pro index 44ac92d1..c77bac33 100644 --- a/xTools.pro +++ b/xTools.pro @@ -21,7 +21,7 @@ X_TOOLS_ORG_NAME = "xTools" X_TOOLS_ORG_DOMAIN = "IT" X_TOOLS_APP_DESCRIPTION = "xTools Studio" X_TOOLS_APP_COPYRIGHT = "Copyright 2018-2024 x-tools-author(x-tools@outlook.com). All rights reserved." -X_TOOLS_VERSION = "5.0.0" +X_TOOLS_VERSION = "6.0.0" win32 { QMAKE_TARGET_COMPANY = "$${X_TOOLS_ORG_NAME}"