style: add Gruvbox theme (#1796)

This commit is contained in:
Richard Habitzreuter 2024-12-15 11:28:36 -03:00 committed by GitHub
parent 0fd1ab674b
commit d2ac92481b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 9 deletions

View file

@ -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<int>(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;
}
}

View file

@ -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;
}

View file

@ -7,13 +7,7 @@
#include <QLineEdit>
#include <QWidget>
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

View file

@ -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
};