diff --git a/src/main.cpp b/src/main.cpp index 35e7a2d2..3dd9ce1f 100644 --- a/src/main.cpp +++ b/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 { diff --git a/src/ui/w_PrefrencesWindow.cpp b/src/ui/w_PrefrencesWindow.cpp index 333d132a..745dd3f8 100644 --- a/src/ui/w_PrefrencesWindow.cpp +++ b/src/ui/w_PrefrencesWindow.cpp @@ -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 }