From d2ac92481b514bd2dacbd60abdc460cd076d9d3c Mon Sep 17 00:00:00 2001 From: Richard Habitzreuter Date: Sun, 15 Dec 2024 11:28:36 -0300 Subject: [PATCH] style: add Gruvbox theme (#1796) --- src/qt_gui/main_window.cpp | 13 +++++++++++++ src/qt_gui/main_window_themes.cpp | 22 ++++++++++++++++++++-- src/qt_gui/main_window_themes.h | 8 +------- src/qt_gui/main_window_ui.h | 6 ++++++ 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 3eb629c0b..0b5137c4b 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -111,6 +111,7 @@ void MainWindow::CreateActions() { m_theme_act_group->addAction(ui->setThemeGreen); m_theme_act_group->addAction(ui->setThemeBlue); m_theme_act_group->addAction(ui->setThemeViolet); + m_theme_act_group->addAction(ui->setThemeGruvbox); } void MainWindow::AddUiWidgets() { @@ -540,6 +541,14 @@ void MainWindow::CreateConnects() { isIconBlack = false; } }); + connect(ui->setThemeGruvbox, &QAction::triggered, &m_window_themes, [this]() { + m_window_themes.SetWindowTheme(Theme::Gruvbox, ui->mw_searchbar); + Config::setMainWindowTheme(static_cast(Theme::Gruvbox)); + if (isIconBlack) { + SetUiIcons(false); + isIconBlack = false; + } + }); } void MainWindow::StartGame() { @@ -912,6 +921,10 @@ void MainWindow::SetLastUsedTheme() { ui->setThemeViolet->setChecked(true); isIconBlack = false; SetUiIcons(false); + case Theme::Gruvbox: + ui->setThemeGruvbox->setChecked(true); + isIconBlack = false; + SetUiIcons(false); break; } } diff --git a/src/qt_gui/main_window_themes.cpp b/src/qt_gui/main_window_themes.cpp index 35e64ef74..65dd04269 100644 --- a/src/qt_gui/main_window_themes.cpp +++ b/src/qt_gui/main_window_themes.cpp @@ -15,7 +15,6 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { themePalette.setColor(QPalette::Window, QColor(50, 50, 50)); themePalette.setColor(QPalette::WindowText, Qt::white); themePalette.setColor(QPalette::Base, QColor(20, 20, 20)); - themePalette.setColor(QPalette::AlternateBase, QColor(25, 25, 25)); themePalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53)); themePalette.setColor(QPalette::ToolTipBase, Qt::white); themePalette.setColor(QPalette::ToolTipText, Qt::white); @@ -28,7 +27,6 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { themePalette.setColor(QPalette::HighlightedText, Qt::black); qApp->setPalette(themePalette); break; - case Theme::Light: mw_searchbar->setStyleSheet("background-color: #ffffff;" // Light gray background "color: #000000;" // Black text @@ -115,6 +113,26 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { themePalette.setColor(QPalette::Highlight, QColor(42, 130, 218)); // Light blue highlight themePalette.setColor(QPalette::HighlightedText, Qt::black); // Black highlighted text + qApp->setPalette(themePalette); + break; + case Theme::Gruvbox: + mw_searchbar->setStyleSheet("background-color: #1d2021;" + "color: #f9f5d7;" + "border: 2px solid #f9f5d7;" + "padding: 5px;"); + themePalette.setColor(QPalette::Window, QColor(29, 32, 33)); + themePalette.setColor(QPalette::WindowText, QColor(249, 245, 215)); + themePalette.setColor(QPalette::Base, QColor(29, 32, 33)); + themePalette.setColor(QPalette::AlternateBase, QColor(50, 48, 47)); + themePalette.setColor(QPalette::ToolTipBase, QColor(249, 245, 215)); + themePalette.setColor(QPalette::ToolTipText, QColor(249, 245, 215)); + themePalette.setColor(QPalette::Text, QColor(249, 245, 215)); + themePalette.setColor(QPalette::Button, QColor(40, 40, 40)); + themePalette.setColor(QPalette::ButtonText, QColor(249, 245, 215)); + themePalette.setColor(QPalette::BrightText, QColor(251, 73, 52)); + themePalette.setColor(QPalette::Link, QColor(131, 165, 152)); + themePalette.setColor(QPalette::Highlight, QColor(131, 165, 152)); + themePalette.setColor(QPalette::HighlightedText, Qt::black); qApp->setPalette(themePalette); break; } diff --git a/src/qt_gui/main_window_themes.h b/src/qt_gui/main_window_themes.h index 6da70e995..d162da87b 100644 --- a/src/qt_gui/main_window_themes.h +++ b/src/qt_gui/main_window_themes.h @@ -7,13 +7,7 @@ #include #include -enum class Theme : int { - Dark, - Light, - Green, - Blue, - Violet, -}; +enum class Theme : int { Dark, Light, Green, Blue, Violet, Gruvbox }; class WindowThemes : public QObject { Q_OBJECT diff --git a/src/qt_gui/main_window_ui.h b/src/qt_gui/main_window_ui.h index 5ff572f86..df64361fd 100644 --- a/src/qt_gui/main_window_ui.h +++ b/src/qt_gui/main_window_ui.h @@ -36,6 +36,7 @@ public: QAction* setThemeGreen; QAction* setThemeBlue; QAction* setThemeViolet; + QAction* setThemeGruvbox; QWidget* centralWidget; QLineEdit* mw_searchbar; QPushButton* playButton; @@ -158,6 +159,9 @@ public: setThemeViolet = new QAction(MainWindow); setThemeViolet->setObjectName("setThemeViolet"); setThemeViolet->setCheckable(true); + setThemeGruvbox = new QAction(MainWindow); + setThemeGruvbox->setObjectName("setThemeGruvbox"); + setThemeGruvbox->setCheckable(true); centralWidget = new QWidget(MainWindow); centralWidget->setObjectName("centralWidget"); sizePolicy.setHeightForWidth(centralWidget->sizePolicy().hasHeightForWidth()); @@ -282,6 +286,7 @@ public: menuThemes->addAction(setThemeGreen); menuThemes->addAction(setThemeBlue); menuThemes->addAction(setThemeViolet); + menuThemes->addAction(setThemeGruvbox); menuGame_List_Icons->addAction(setIconSizeTinyAct); menuGame_List_Icons->addAction(setIconSizeSmallAct); menuGame_List_Icons->addAction(setIconSizeMediumAct); @@ -368,6 +373,7 @@ public: setThemeGreen->setText(QCoreApplication::translate("MainWindow", "Green", nullptr)); setThemeBlue->setText(QCoreApplication::translate("MainWindow", "Blue", nullptr)); setThemeViolet->setText(QCoreApplication::translate("MainWindow", "Violet", nullptr)); + setThemeGruvbox->setText("Gruvbox"); toolBar->setWindowTitle(QCoreApplication::translate("MainWindow", "toolBar", nullptr)); } // retranslateUi };