Add the dark theme files

Commit amended for code style and to remove duplicate code by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
silas 2020-11-20 17:12:15 -06:00 committed by Adam Honse
parent 8dd0d85104
commit 6347feb575
5 changed files with 312 additions and 0 deletions

View file

@ -9,6 +9,10 @@
#include <QMessageBox>
#include <QCloseEvent>
#ifdef _WIN32
#include <QSettings>
#endif
using namespace Ui;
static QString GetIconString(device_type type, bool dark)
@ -175,6 +179,63 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& 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 |
\*-----------------------------------------------------*/

BIN
qt/arrow-down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

BIN
qt/arrow-up.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

View file

@ -29,5 +29,8 @@
<file>gamepad_dark.png</file>
<file>light.png</file>
<file>light_dark.png</file>
<file>windows_dark.qss</file>
<file>arrow-down.png</file>
<file>arrow-up.png</file>
</qresource>
</RCC>

248
qt/windows_dark.qss Normal file
View file

@ -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: ;
}
*/