diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp index 134373bb..ab5ecbbf 100644 --- a/qt/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2.cpp @@ -9,6 +9,10 @@ #include #include +#ifdef _WIN32 +#include +#endif + using namespace Ui; static QString GetIconString(device_type type, bool dark) @@ -175,6 +179,63 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector& bus, std::vec trayIcon->show(); darkTheme = palette().window().color().value() < 127; // Adjust +#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")) + { + 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 | + \*-----------------------------------------------------------------*/ + } +#endif + /*-----------------------------------------------------*\ | Update the profile list | \*-----------------------------------------------------*/ diff --git a/qt/arrow-down.png b/qt/arrow-down.png new file mode 100644 index 00000000..a0c0e158 Binary files /dev/null and b/qt/arrow-down.png differ diff --git a/qt/arrow-up.png b/qt/arrow-up.png new file mode 100644 index 00000000..b44f10d8 Binary files /dev/null and b/qt/arrow-up.png differ diff --git a/qt/resources.qrc b/qt/resources.qrc index 7ac5fdb1..66d708b0 100644 --- a/qt/resources.qrc +++ b/qt/resources.qrc @@ -29,5 +29,8 @@ gamepad_dark.png light.png light_dark.png + windows_dark.qss + arrow-down.png + arrow-up.png diff --git a/qt/windows_dark.qss b/qt/windows_dark.qss new file mode 100644 index 00000000..b290c3ad --- /dev/null +++ b/qt/windows_dark.qss @@ -0,0 +1,248 @@ +QMainWindow +{ + background-color: #5c5c5c; + color: white; +} + +/* External QTabWidget */ + +QTabBar +{ + background-color: #5c5c5c; +} + +QTabBar::tab +{ + background-color: #5c5c5c; + padding-top: 5px; + padding-bottom: 5px; + padding-left: 12px; + padding-right: 12px; + border: 1px solid #2e2e2e; + margin-right: 1px; +} + +QTabBar::tab:selected +{ + background-color: #454545; + border: 1px solid #2e2e2e; + border-bottom: 1px solid #191919; +} + +QTabBar::tab:hover +{ + background-color: #757575; + border: 1px solid #404040; + border-bottom: 1px solid #2B2B2B; +} + +QTabWidget::pane +{ + background-color: #5c5c5c; + border: 1px solid #2e2e2e; + position: absolute; + top: -1px; +} + +/* Internal QTabWidget */ + +QTabWidget::pane QTabBar +{ + background-color: #5c5c5c; +} + +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; + margin-right: 0px; + /*margin-bottom: 1px;*/ +} + +QTabWidget QWidget QTabBar::tab QLabel +{ + /*background-color: darkred;*/ +} + +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;*/ +} + +QTabWidget QWidget QTabWidget::pane +{ + background-color: #454545; + border-top: 1px solid #2e2e2e; + border: 1px solid #2e2e2e; + position: absolute; + top: 0px; + left: -1px; +} + +/* Buttons and combo boxes */ + +QPushButton +{ + padding: 3px; + background-color: #404040; + border: 1px solid #2e2e2e; + color: white; +} + +QComboBox +{ + padding: 1px; + background-color: #404040; + border: 1px solid #2e2e2e; + color: white; +} + +QComboBox QAbstractItemView +{ + background-color: #404040; + color: white; + border: 1px solid #2e2e2e; + selection-background-color: #303030; +} + +QScrollBar:vertical +{ + background: #454545; + border: 0px; + margin: 0px 0px; + width: 15px; +} + +/* Arrow images +QScrollBar::up-arrow +{ + image: url(":/arrow-up.png"); +} + +QScrollBar::down-arrow +{ + image: url(":/arrow-down.png"); +} */ + +QScrollBar::handle:vertical +{ + background-color: #454545; +} + +QScrollBar::handle:vertical:hover +{ + background-color: #757575; +} + +QComboBox::drop-down +{ + border: 0px; +} + +QComboBox::down-arrow +{ + image: url(":/arrow-down.png"); +} + +QPushButton:!disabled:hover, QComboBox:!disabled:hover +{ + background-color: #4F4F4F; +} + + +QComboBox QAbstractItemView QScrollBar::handle:hover +{ + background-color: #7A7A7A; +} + +QPushButton:!disabled:hover, QComboBox:!disabled:hover +{ + background-color: #4F4F4F; +} + +QPushButton:disabled, QComboBox:disabled +{ + background-color: #404040; + color: #5B5B5B; +} + +QPushButton:flat +{ + border: 0px; +} + +QRadioButton +{ + color: white; +} + +QRadioButton::disabled +{ + color: #5B5B5B; +} + +/* Line edits and block edits */ + +QLineEdit, QSpinBox +{ + background-color: #4F4F4F; + border: 1px solid #5B5B5B; + color: white; + padding: 1px; +} + +QTreeView +{ + background-color: #5c5c5c; + color: white; +} + +QHeaderView::section +{ + background-color: #454545; + color: white; +} + +QPlainTextEdit +{ + background: #454545; + color: white; +} + +/* QProgressBar and QSlider */ + +QProgressBar +{ + border: 1px solid #2e2e2e; + background-color: #404040; + color: white; +} + +QDialog +{ + background-color: #5c5c5c +} + +/* +the default color is fine +QSlider::handle +{ + background: ; +} +*/