diff --git a/qt/OpenRGBDevicePage.ui b/qt/OpenRGBDevicePage.ui index 5acbed14..7d6d5f0f 100644 --- a/qt/OpenRGBDevicePage.ui +++ b/qt/OpenRGBDevicePage.ui @@ -16,6 +16,9 @@ + + background-color: #00ffff + @@ -43,6 +46,9 @@ + + background-color: #0000ff + @@ -64,6 +70,9 @@ + + background-color: #ffff00 + @@ -122,6 +131,9 @@ + + background-color: #ff0000 + @@ -164,6 +176,9 @@ + + background-color: #ff00ff + @@ -220,6 +235,9 @@ + + background-color: #00ff00 + diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp index ab5ecbbf..2fdd54d0 100644 --- a/qt/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2.cpp @@ -86,6 +86,61 @@ static void UpdateDetectionProgressCallback(void * this_ptr) QMetaObject::invokeMethod(this_obj, "onDetectionProgressUpdated", Qt::QueuedConnection); } +bool OpenRGBDialog2::IsDarkTheme() + { + #ifdef _WIN32 + /*-------------------------------------------------*\ + | Windows dark theme settings | + \*-------------------------------------------------*/ + json theme_settings; + + /*-------------------------------------------------*\ + | Get prefered theme from settings manager | + \*-------------------------------------------------*/ + theme_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Setting_Theme"); + + /*-------------------------------------------------*\ + | Read the theme key and adjust accordingly | + \*-------------------------------------------------*/ + std::string current_theme = "light"; + + if(theme_settings.contains("theme")) + { + current_theme = theme_settings["theme"]; + } + + if((current_theme == "auto") || (current_theme == "dark")) + { + if(current_theme == "auto") + { + QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", QSettings::NativeFormat); + + if(settings.value("AppsUseLightTheme") != 0) + { + return false; + } + else if(settings.value("AppsUseLightTheme") == 0) + { + return true; + } + } + else if(current_theme == "dark") + { + return true; + } + } + return false; + + #else + if(QPalette().window().color().value() < 127) + { + return true; + } + #endif + + return false; +} + OpenRGBDialog2::OpenRGBDialog2(std::vector& bus, std::vector& control, QWidget *parent) : QMainWindow(parent), busses(bus), controllers(control), ui(new OpenRGBDialog2Ui) { ui->setupUi(this); @@ -154,7 +209,7 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector& bus, std::vec QAction* actionQuickBlue = new QAction("Blue", this); connect(actionQuickBlue, SIGNAL(triggered()), this, SLOT(on_QuickBlue())); quickColorsMenu->addAction(actionQuickBlue); - + QAction* actionQuickMagenta = new QAction("Magenta", this); connect(actionQuickMagenta, SIGNAL(triggered()), this, SLOT(on_QuickMagenta())); quickColorsMenu->addAction(actionQuickMagenta); @@ -177,62 +232,20 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector& bus, std::vec trayIcon->setToolTip("OpenRGB"); trayIcon->setContextMenu(trayIconMenu); trayIcon->show(); - darkTheme = palette().window().color().value() < 127; // Adjust #ifdef _WIN32 /*-------------------------------------------------*\ - | Windows dark theme settings | + | Apply dark theme on Windows if configured | \*-------------------------------------------------*/ - json theme_settings; - /*-------------------------------------------------*\ - | Get prefered theme from settings manager | - \*-------------------------------------------------*/ - theme_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Setting_Theme"); - - /*-------------------------------------------------*\ - | Read the theme key and adjust accordingly | - \*-------------------------------------------------*/ - std::string current_theme = "light"; - - if(theme_settings.contains("theme")) + if(IsDarkTheme()) { - current_theme = theme_settings["theme"]; - } - - if((current_theme == "auto") || (current_theme == "dark")) - { - darkTheme = true; - - if(current_theme == "auto") - { - QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", QSettings::NativeFormat); - - if(settings.value("AppsUseLightTheme") != 0) - { - darkTheme = false; - } - } - - /*-------------------------------------------------*\ - | Apply dark theme on Windows if configured | - \*-------------------------------------------------*/ - if(darkTheme) - { - darkTheme = 1; - QPalette pal = palette(); - pal.setColor(QPalette::WindowText, Qt::white); - QApplication::setPalette(pal); - QFile darkTheme(":/windows_dark.qss"); - darkTheme.open(QFile::ReadOnly); - setStyleSheet(darkTheme.readAll()); - } - } - else if (current_theme == "light") - { - /*-----------------------------------------------------------------*\ - | It defaults to light theme so just an empty statement should work | - \*-----------------------------------------------------------------*/ + QPalette pal = palette(); + pal.setColor(QPalette::WindowText, Qt::white); + QApplication::setPalette(pal); + QFile darkTheme(":/windows_dark.qss"); + darkTheme.open(QFile::ReadOnly); + setStyleSheet(darkTheme.readAll()); } #endif @@ -293,13 +306,20 @@ void OpenRGBDialog2::AddSoftwareInfoPage() QString SoftwareLabelString = "
Software
"; QLabel *SoftwareTabLabel = new QLabel(); SoftwareTabLabel->setText(SoftwareLabelString); SoftwareTabLabel->setIndent(20); - SoftwareTabLabel->setGeometry(0, 0, 200, 20); + if(IsDarkTheme()) + { + SoftwareTabLabel->setGeometry(0, 25, 200, 50); + } + else + { + SoftwareTabLabel->setGeometry(0, 0, 200, 25); + } ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SoftwareTabLabel); } @@ -320,14 +340,20 @@ void OpenRGBDialog2::AddI2CToolsPage() QString SMBusToolsLabelString = "
SMBus Tools
"; QLabel *SMBusToolsTabLabel = new QLabel(); SMBusToolsTabLabel->setText(SMBusToolsLabelString); SMBusToolsTabLabel->setIndent(20); - SMBusToolsTabLabel->setGeometry(0, 0, 200, 20); - + if(IsDarkTheme()) + { + SMBusToolsTabLabel->setGeometry(0, 25, 200, 50); + } + else + { + SMBusToolsTabLabel->setGeometry(0, 0, 200, 25); + } ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SMBusToolsTabLabel); } @@ -445,13 +471,20 @@ void OpenRGBDialog2::UpdateDevicesList() | type and append device name string. | \*-----------------------------------------------------*/ QString NewLabelString = "
" + QString::fromStdString(controllers[controller_idx]->name) + "
"; QLabel *NewTabLabel = new QLabel(); NewTabLabel->setText(NewLabelString); NewTabLabel->setIndent(20); - NewTabLabel->setGeometry(0, 0, 200, 20); + if(IsDarkTheme()) + { + NewTabLabel->setGeometry(0, 25, 200, 50); + } + else + { + NewTabLabel->setGeometry(0, 0, 200, 25); + } ui->DevicesTabBar->tabBar()->setTabButton(ui->DevicesTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel); @@ -504,13 +537,20 @@ void OpenRGBDialog2::UpdateDevicesList() | type and append device name string. | \*-----------------------------------------------------*/ QString NewLabelString = "
" + QString::fromStdString(controllers[controller_idx]->name) + "
"; QLabel *NewTabLabel = new QLabel(); NewTabLabel->setText(NewLabelString); NewTabLabel->setIndent(20); - NewTabLabel->setGeometry(0, 0, 200, 20); + if(IsDarkTheme()) + { + NewTabLabel->setGeometry(0, 25, 200, 50); + } + else + { + NewTabLabel->setGeometry(0, 0, 200, 25); + } ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel); diff --git a/qt/OpenRGBDialog2.h b/qt/OpenRGBDialog2.h index 33a137fb..03be402f 100644 --- a/qt/OpenRGBDialog2.h +++ b/qt/OpenRGBDialog2.h @@ -39,6 +39,8 @@ public: void setMode(unsigned char mode_val); + static bool IsDarkTheme(); + protected: std::vector& busses; std::vector& controllers; @@ -74,7 +76,6 @@ private: void SetDetectionViewState(bool detection_showing); bool device_view_showing = false; - bool darkTheme = false; private slots: void on_Exit(); diff --git a/qt/OpenRGBProfileSaveDialog.cpp b/qt/OpenRGBProfileSaveDialog.cpp index bc0790af..ccde3709 100644 --- a/qt/OpenRGBProfileSaveDialog.cpp +++ b/qt/OpenRGBProfileSaveDialog.cpp @@ -1,9 +1,32 @@ +#include +#include "ResourceManager.h" +#include "OpenRGBDialog2.h" #include "OpenRGBProfileSaveDialog.h" #include "ui_OpenRGBProfileSaveDialog.h" +#ifdef _WIN32 +#include +#endif + Ui::OpenRGBProfileSaveDialog::OpenRGBProfileSaveDialog(QWidget *parent) : QDialog(parent), ui(new Ui::OpenRGBProfileSaveDialogUi) { + #ifdef _WIN32 + bool DarkTheme = OpenRGBDialog2::IsDarkTheme(); + /*-------------------------------------------------*\ + | Apply dark theme on Windows if configured | + \*-------------------------------------------------*/ + if(DarkTheme) + { + darkTheme = 1; + QPalette pal = palette(); + pal.setColor(QPalette::WindowText, Qt::white); + QApplication::setPalette(pal); + QFile darkTheme(":/windows_dark.qss"); + darkTheme.open(QFile::ReadOnly); + setStyleSheet(darkTheme.readAll()); + } + #endif ui->setupUi(this); } diff --git a/qt/OpenRGBProfileSaveDialog.h b/qt/OpenRGBProfileSaveDialog.h index 4b46a8ba..f7eebc65 100644 --- a/qt/OpenRGBProfileSaveDialog.h +++ b/qt/OpenRGBProfileSaveDialog.h @@ -3,6 +3,7 @@ #include #include "ui_OpenRGBProfileSaveDialog.h" +#include "OpenRGBDialog2.h" namespace Ui { @@ -21,6 +22,7 @@ public: private: Ui::OpenRGBProfileSaveDialogUi *ui; + bool darkTheme = false; }; #endif // OPENRGBPROFILESAVEDIALOG_H diff --git a/qt/windows_dark.qss b/qt/windows_dark.qss index b290c3ad..b58ffdf7 100644 --- a/qt/windows_dark.qss +++ b/qt/windows_dark.qss @@ -33,11 +33,11 @@ QTabBar::tab:hover { background-color: #757575; border: 1px solid #404040; - border-bottom: 1px solid #2B2B2B; } QTabWidget::pane { + /* This is the housing for all of the tabs*/ background-color: #5c5c5c; border: 1px solid #2e2e2e; position: absolute; @@ -49,43 +49,36 @@ QTabWidget::pane QTabWidget::pane QTabBar { background-color: #5c5c5c; + border-right: 1px solid #2e2e2e; } QTabWidget QWidget QTabBar::tab { background-color: #5c5c5c; - /*padding: 5px;*/ padding-top: 4px; padding-bottom: 5px; height: 50px; border: 10px; - border-bottom: 1px; - border-right: 1px solid #5c5c5c; + border-right: 1px solid #2e2e2e; margin-right: 0px; - /*margin-bottom: 1px;*/ -} - -QTabWidget QWidget QTabBar::tab QLabel -{ - /*background-color: darkred;*/ + margin-bottom: 2px; } QTabWidget QWidget QTabBar::tab:selected { background-color: #454545; border: 1px solid #2e2e2e; - border-top: 1px solid #2e2e2e; border-right: 1px solid #454545; } QTabWidget QWidget QTabBar::tab:hover { background-color: #757575; - border: 1px solid #2e2e2e; - /*border-right: 1px solid #2e2e2e;*/ + border: 1px solid #5c5c5c; + border-right: 1px solid #2e2e2e; } -QTabWidget QWidget QTabWidget::pane +QTabWidget QWidget QTabWidget::pane /* The contents of the tab (colors, modes, leds, etc.) */ { background-color: #454545; border-top: 1px solid #2e2e2e; @@ -95,6 +88,33 @@ QTabWidget QWidget QTabWidget::pane left: -1px; } +/* QDialog boxes */ + +QDialog::QWidget +{ + background: #454545; + background-color: #454545; + color: white; +} + +QDialog QWidget::QDialogButtonBox +{ + background-color: #454545; + color: white; +} + +QDialog QWidget::QLabel +{ + background-color: #454545; + color: white; +} + +QDialog QWidget::QLineEdit +{ + background-color: #454545; + color: white; +} + /* Buttons and combo boxes */ QPushButton