diff --git a/Source/GUI/GUICommon.cpp b/Source/GUI/GUICommon.cpp index a0fcf89..7376393 100644 --- a/Source/GUI/GUICommon.cpp +++ b/Source/GUI/GUICommon.cpp @@ -2,7 +2,9 @@ #include #include +#include #include +#include namespace GUICommon { @@ -71,15 +73,188 @@ QString getNameFromBase(const Common::MemBase base) } } -void changeApplicationStyle(int index) +void changeApplicationStyle(const ApplicationStyle style) { - if (index == 0) + QApplication::setStyle(QStringLiteral("fusion")); + + if (style == ApplicationStyle::System) + { + qApp->setPalette({}); + QToolTip::setPalette({}); + qApp->setStyleSheet({}); + return; + } + + if (style == ApplicationStyle::Light) + { + QPalette palette; + palette.setColor(QPalette::All, QPalette::Window, QColor(239, 239, 239)); + palette.setColor(QPalette::Disabled, QPalette::Window, QColor(239, 239, 239)); + palette.setColor(QPalette::All, QPalette::WindowText, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(190, 190, 190)); + palette.setColor(QPalette::All, QPalette::Base, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::Base, QColor(239, 239, 239)); + palette.setColor(QPalette::All, QPalette::AlternateBase, QColor(247, 247, 247)); + palette.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(247, 247, 247)); + palette.setColor(QPalette::All, QPalette::ToolTipBase, QColor(255, 255, 220)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(255, 255, 220)); + palette.setColor(QPalette::All, QPalette::ToolTipText, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(0, 0, 0)); + palette.setColor(QPalette::All, QPalette::PlaceholderText, QColor(119, 119, 119)); + palette.setColor(QPalette::Disabled, QPalette::PlaceholderText, QColor(119, 119, 119)); + palette.setColor(QPalette::All, QPalette::Text, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::Text, QColor(190, 190, 190)); + palette.setColor(QPalette::All, QPalette::Button, QColor(239, 239, 239)); + palette.setColor(QPalette::Disabled, QPalette::Button, QColor(239, 239, 239)); + palette.setColor(QPalette::All, QPalette::ButtonText, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(190, 190, 190)); + palette.setColor(QPalette::All, QPalette::BrightText, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Light, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::Light, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Midlight, QColor(202, 202, 202)); + palette.setColor(QPalette::Disabled, QPalette::Midlight, QColor(202, 202, 202)); + palette.setColor(QPalette::All, QPalette::Dark, QColor(159, 159, 159)); + palette.setColor(QPalette::Disabled, QPalette::Dark, QColor(190, 190, 190)); + palette.setColor(QPalette::All, QPalette::Mid, QColor(184, 184, 184)); + palette.setColor(QPalette::Disabled, QPalette::Mid, QColor(184, 184, 184)); + palette.setColor(QPalette::All, QPalette::Shadow, QColor(118, 118, 118)); + palette.setColor(QPalette::Disabled, QPalette::Shadow, QColor(177, 177, 177)); + palette.setColor(QPalette::All, QPalette::Highlight, QColor(48, 140, 198)); + palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145)); + palette.setColor(QPalette::All, QPalette::HighlightedText, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Link, QColor(0, 0, 255)); + palette.setColor(QPalette::Disabled, QPalette::Link, QColor(0, 0, 255)); + palette.setColor(QPalette::All, QPalette::LinkVisited, QColor(255, 0, 255)); + palette.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(255, 0, 255)); + + qApp->setPalette(palette); + QToolTip::setPalette(palette); + + const int padding{QFontMetrics(QFont()).height() / 2}; + qApp->setStyleSheet(QString(R"( + QToolTip { + padding: %1px; + border: 1px solid rgb(239, 239, 239); + background: rgb(255, 255, 255); + } + )") + .arg(padding)); + } + else if (style == ApplicationStyle::DarkGray) { - QApplication::setStyle(QStringLiteral("fusion")); + QPalette palette; + palette.setColor(QPalette::All, QPalette::Window, QColor(50, 50, 50)); + palette.setColor(QPalette::Disabled, QPalette::Window, QColor(55, 55, 55)); + palette.setColor(QPalette::All, QPalette::WindowText, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(108, 108, 108)); + palette.setColor(QPalette::All, QPalette::Base, QColor(25, 25, 25)); + palette.setColor(QPalette::Disabled, QPalette::Base, QColor(30, 30, 30)); + palette.setColor(QPalette::All, QPalette::AlternateBase, QColor(38, 38, 38)); + palette.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(42, 42, 42)); + palette.setColor(QPalette::All, QPalette::ToolTipBase, QColor(45, 45, 45)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(45, 45, 45)); + palette.setColor(QPalette::All, QPalette::ToolTipText, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(200, 200, 200)); + palette.setColor(QPalette::All, QPalette::PlaceholderText, QColor(90, 90, 90)); + palette.setColor(QPalette::Disabled, QPalette::PlaceholderText, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::Text, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::Text, QColor(108, 108, 108)); + palette.setColor(QPalette::All, QPalette::Button, QColor(54, 54, 54)); + palette.setColor(QPalette::Disabled, QPalette::Button, QColor(54, 54, 54)); + palette.setColor(QPalette::All, QPalette::ButtonText, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(108, 108, 108)); + palette.setColor(QPalette::All, QPalette::BrightText, QColor(75, 75, 75)); + palette.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Light, QColor(26, 26, 26)); + palette.setColor(QPalette::Disabled, QPalette::Light, QColor(26, 26, 26)); + palette.setColor(QPalette::All, QPalette::Midlight, QColor(40, 40, 40)); + palette.setColor(QPalette::Disabled, QPalette::Midlight, QColor(40, 40, 40)); + palette.setColor(QPalette::All, QPalette::Dark, QColor(108, 108, 108)); + palette.setColor(QPalette::Disabled, QPalette::Dark, QColor(108, 108, 108)); + palette.setColor(QPalette::All, QPalette::Mid, QColor(71, 71, 71)); + palette.setColor(QPalette::Disabled, QPalette::Mid, QColor(71, 71, 71)); + palette.setColor(QPalette::All, QPalette::Shadow, QColor(25, 25, 25)); + palette.setColor(QPalette::Disabled, QPalette::Shadow, QColor(37, 37, 37)); + palette.setColor(QPalette::All, QPalette::Highlight, QColor(45, 140, 225)); + palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(45, 140, 225).darker()); + palette.setColor(QPalette::All, QPalette::HighlightedText, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(40, 40, 40)); + palette.setColor(QPalette::All, QPalette::Link, QColor(40, 130, 220)); + palette.setColor(QPalette::Disabled, QPalette::Link, QColor(40, 130, 220).darker()); + palette.setColor(QPalette::All, QPalette::LinkVisited, QColor(110, 70, 150)); + palette.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(110, 70, 150).darker()); + + qApp->setPalette(palette); + QToolTip::setPalette(palette); + + const int padding{QFontMetrics(QFont()).height() / 2}; + qApp->setStyleSheet(QString(R"( + QToolTip { + padding: %1px; + border: 1px solid rgb(30, 30, 30); + background: rgb(45, 45, 45); + } + )") + .arg(padding)); } - else if (index == 1) + else if (style == ApplicationStyle::Dark) { - QApplication::setStyle(QStringLiteral("windowsvista")); + QPalette palette; + palette.setColor(QPalette::All, QPalette::Window, QColor(22, 22, 22)); + palette.setColor(QPalette::Disabled, QPalette::Window, QColor(30, 30, 30)); + palette.setColor(QPalette::All, QPalette::WindowText, QColor(180, 180, 180)); + palette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::Base, QColor(35, 35, 35)); + palette.setColor(QPalette::Disabled, QPalette::Base, QColor(30, 30, 30)); + palette.setColor(QPalette::All, QPalette::AlternateBase, QColor(40, 40, 40)); + palette.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(35, 35, 35)); + palette.setColor(QPalette::All, QPalette::ToolTipBase, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(0, 0, 0)); + palette.setColor(QPalette::All, QPalette::ToolTipText, QColor(170, 170, 170)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(170, 170, 170)); + palette.setColor(QPalette::All, QPalette::PlaceholderText, QColor(100, 100, 100)); + palette.setColor(QPalette::Disabled, QPalette::PlaceholderText, QColor(100, 100, 100)); + palette.setColor(QPalette::All, QPalette::Text, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::Text, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::Button, QColor(30, 30, 30)); + palette.setColor(QPalette::Disabled, QPalette::Button, QColor(20, 20, 20)); + palette.setColor(QPalette::All, QPalette::ButtonText, QColor(180, 180, 180)); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::BrightText, QColor(75, 75, 75)); + palette.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Light, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::Light, QColor(0, 0, 0)); + palette.setColor(QPalette::All, QPalette::Midlight, QColor(40, 40, 40)); + palette.setColor(QPalette::Disabled, QPalette::Midlight, QColor(40, 40, 40)); + palette.setColor(QPalette::All, QPalette::Dark, QColor(90, 90, 90)); + palette.setColor(QPalette::Disabled, QPalette::Dark, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::Mid, QColor(60, 60, 60)); + palette.setColor(QPalette::Disabled, QPalette::Mid, QColor(60, 60, 60)); + palette.setColor(QPalette::All, QPalette::Shadow, QColor(10, 10, 10)); + palette.setColor(QPalette::Disabled, QPalette::Shadow, QColor(20, 20, 20)); + palette.setColor(QPalette::All, QPalette::Highlight, QColor(35, 130, 200)); + palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(35, 130, 200).darker()); + palette.setColor(QPalette::All, QPalette::HighlightedText, QColor(240, 240, 240)); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(35, 35, 35)); + palette.setColor(QPalette::All, QPalette::Link, QColor(40, 130, 220)); + palette.setColor(QPalette::Disabled, QPalette::Link, QColor(40, 130, 220).darker()); + palette.setColor(QPalette::All, QPalette::LinkVisited, QColor(110, 70, 150)); + palette.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(110, 70, 150).darker()); + + qApp->setPalette(palette); + QToolTip::setPalette(palette); + + const int padding{QFontMetrics(QFont()).height() / 2}; + qApp->setStyleSheet(QString(R"( + QToolTip { + padding: %1px; + border: 1px solid rgb(50, 50, 50); + background: rgb(10, 10, 10); + } + )") + .arg(padding)); } } diff --git a/Source/GUI/GUICommon.h b/Source/GUI/GUICommon.h index 714f41a..aab104c 100644 --- a/Source/GUI/GUICommon.h +++ b/Source/GUI/GUICommon.h @@ -14,7 +14,15 @@ extern QStringList g_memBaseNames; QString getStringFromType(Common::MemType type, size_t length = 0); QString getNameFromBase(Common::MemBase base); -void changeApplicationStyle(int); +enum class ApplicationStyle +{ + System = 0, + Light, + DarkGray, + Dark, +}; + +void changeApplicationStyle(ApplicationStyle style); extern bool g_valueEditing; } // namespace GUICommon diff --git a/Source/GUI/MainWindow.cpp b/Source/GUI/MainWindow.cpp index 547e697..15f5877 100644 --- a/Source/GUI/MainWindow.cpp +++ b/Source/GUI/MainWindow.cpp @@ -36,9 +36,9 @@ MainWindow::MainWindow() restoreGeometry(SConfig::getInstance().getMainWindowGeometry()); if (SConfig::getInstance().getMainWindowState().size()) restoreState(SConfig::getInstance().getMainWindowState()); -#ifdef _WIN32 - GUICommon::changeApplicationStyle(SConfig::getInstance().getTheme()); -#endif + + GUICommon::changeApplicationStyle( + static_cast(SConfig::getInstance().getTheme())); m_watcher->restoreWatchModel(SConfig::getInstance().getWatchModel()); m_actAutoHook->setChecked(SConfig::getInstance().getAutoHook()); diff --git a/Source/GUI/Settings/DlgSettings.cpp b/Source/GUI/Settings/DlgSettings.cpp index f9a58fb..cf5d98a 100644 --- a/Source/GUI/Settings/DlgSettings.cpp +++ b/Source/GUI/Settings/DlgSettings.cpp @@ -14,10 +14,13 @@ DlgSettings::DlgSettings(QWidget* parent) : QDialog(parent) { QGroupBox* grbCoreSettings = new QGroupBox("Core settings"); m_cmbTheme = new QComboBox(); - m_cmbTheme->addItem("Dark", 0); - m_cmbTheme->addItem("Light", 1); - connect(m_cmbTheme, QOverload::of(&QComboBox::currentIndexChanged), this, - GUICommon::changeApplicationStyle); + m_cmbTheme->addItem("System", static_cast(GUICommon::ApplicationStyle::System)); + m_cmbTheme->addItem("Light", static_cast(GUICommon::ApplicationStyle::Light)); + m_cmbTheme->addItem("Dark Gray", static_cast(GUICommon::ApplicationStyle::DarkGray)); + m_cmbTheme->addItem("Dark", static_cast(GUICommon::ApplicationStyle::Dark)); + connect(m_cmbTheme, &QComboBox::currentIndexChanged, this, [](const int index) { + GUICommon::changeApplicationStyle(static_cast(index)); + }); QFormLayout* coreSettingsInputLayout = new QFormLayout(); coreSettingsInputLayout->addRow("Theme", m_cmbTheme); @@ -126,9 +129,7 @@ DlgSettings::DlgSettings(QWidget* parent) : QDialog(parent) grbMemorySizeSettings->setLayout(memorySettingsInputLayout); QVBoxLayout* mainLayout = new QVBoxLayout; -#ifdef _WIN32 mainLayout->addWidget(grbCoreSettings); -#endif mainLayout->addWidget(grbTimerSettings); mainLayout->addWidget(grbScannerSettings); mainLayout->addWidget(grbViewerSettings);