mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
[fix] Fixed dark theme settings on QV2RAY_USE_BUILTIN_DARKTHEME #130
Signed-off-by: Leroy.H.Y <lhy20010403@hotmail.com>
This commit is contained in:
parent
9121fc5bb6
commit
12e25c92b1
18
src/main.cpp
18
src/main.cpp
@ -244,17 +244,13 @@ int main(int argc, char *argv[])
|
||||
font.setFamily("微软雅黑");
|
||||
_qApp.setFont(font);
|
||||
#endif
|
||||
QStringList themes = QStyleFactory::keys();
|
||||
|
||||
if (themes.contains(QSTRING(confObject.UISettings.theme))) {
|
||||
_qApp.setStyle(QSTRING(confObject.UISettings.theme));
|
||||
LOG(MODULE_INIT " " MODULE_UI, "Setting Qv2ray UI themes.")
|
||||
}
|
||||
|
||||
#if QV2RAY_USE_BUILTIN_DARKTHEME
|
||||
LOG(MODULE_UI, "Using built-in theme.")
|
||||
|
||||
if (confObject.UISettings.useDarkTheme) {
|
||||
LOG(MODULE_UI, " --> Using built-in dark theme.")
|
||||
// From https://forum.qt.io/topic/101391/windows-10-dark-theme/4
|
||||
_qApp.setStyle("Fusion");
|
||||
QPalette darkPalette;
|
||||
QColor darkColor = QColor(45, 45, 45);
|
||||
QColor disabledColor = QColor(127, 127, 127);
|
||||
@ -280,6 +276,14 @@ int main(int argc, char *argv[])
|
||||
qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
|
||||
}
|
||||
|
||||
#else
|
||||
QStringList themes = QStyleFactory::keys();
|
||||
|
||||
if (themes.contains(QSTRING(confObject.UISettings.theme))) {
|
||||
_qApp.setStyle(QSTRING(confObject.UISettings.theme));
|
||||
LOG(MODULE_INIT " " MODULE_UI, "Setting Qv2ray UI themes.")
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
try {
|
||||
|
@ -33,6 +33,10 @@ PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent),
|
||||
//
|
||||
themeCombo->setCurrentText(QSTRING(CurrentConfig.UISettings.theme));
|
||||
darkChartThemeCB->setChecked(CurrentConfig.UISettings.useDarkTheme);
|
||||
#if QV2RAY_USE_BUILTIN_DARKTHEME
|
||||
// If we use built in theme, it should always be fusion.
|
||||
themeCombo->setEnabled(!CurrentConfig.UISettings.useDarkTheme);
|
||||
#endif
|
||||
languageComboBox->setCurrentText(QSTRING(CurrentConfig.UISettings.language));
|
||||
logLevelComboBox->setCurrentIndex(CurrentConfig.logLevel);
|
||||
tProxyCheckBox->setChecked(CurrentConfig.tProxySupport);
|
||||
@ -712,4 +716,13 @@ void PrefrencesWindow::on_darkChartThemeCB_stateChanged(int arg1)
|
||||
{
|
||||
LOADINGCHECK
|
||||
CurrentConfig.UISettings.useDarkTheme = arg1 == Qt::Checked;
|
||||
#if QV2RAY_USE_BUILTIN_DARKTHEME
|
||||
themeCombo->setEnabled(arg1 != Qt::Checked);
|
||||
|
||||
if (arg1 == Qt::Checked) {
|
||||
themeCombo->setCurrentIndex(QStyleFactory::keys().indexOf("Fusion"));
|
||||
CurrentConfig.UISettings.theme = "Fusion";
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user