diff --git a/src/views/termwidget.cpp b/src/views/termwidget.cpp index ac0bfad8b..a95753d86 100644 --- a/src/views/termwidget.cpp +++ b/src/views/termwidget.cpp @@ -309,8 +309,15 @@ inline void TermWidget::onColorThemeChanged(const QString &colorTheme) inline void TermWidget::onThemeChanged(DGuiApplicationHelper::ColorType themeType) { + Q_UNUSED(themeType); if ("System Theme" == Settings::instance()->colorScheme()) { - setTheme("System Theme"); + QString theme; + if (DApplicationHelper::DarkType == DApplicationHelper::instance()->themeType()) { + theme = "Dark"; + } else { + theme = "Light"; + } + setColorScheme(theme); } } @@ -696,24 +703,6 @@ void TermWidget::inputRemotePassword(const QString &remotePassword) void TermWidget::changeTitleColor(int lightness) { - QString colorTheme = Settings::instance()->colorScheme(); - // 自定义主题 - if (colorTheme == Settings::instance()->m_configCustomThemePath) { - DGuiApplicationHelper::ColorType systemTheme = DGuiApplicationHelper::DarkType; - if ("Light" == Settings::instance()->themeSetting->value("CustomTheme/TitleStyle")) { - systemTheme = DGuiApplicationHelper::LightType; - } - DApplicationHelper::instance()->setPaletteType(systemTheme); - return; - } - - // 跟随系统 - if ("System Theme" == colorTheme) { - DApplicationHelper::instance()->setPaletteType(DGuiApplicationHelper::UnknownType); - return; - } - - // 其他 if (lightness >= 192) { DGuiApplicationHelper::instance()->setPaletteType(DGuiApplicationHelper::LightType); } else { @@ -726,11 +715,25 @@ void TermWidget::setTheme(const QString &colorTheme) QString theme = colorTheme; // 跟随系统 if ("System Theme" == colorTheme) { + DApplicationHelper::instance()->setPaletteType(DGuiApplicationHelper::UnknownType); if (DApplicationHelper::DarkType == DApplicationHelper::instance()->themeType()) { theme = "Dark"; } else { theme = "Light"; } + setColorScheme(theme); + return; + } + + // 自定义主题 + if (colorTheme == Settings::instance()->m_configCustomThemePath) { + DGuiApplicationHelper::ColorType systemTheme = DGuiApplicationHelper::DarkType; + if ("Light" == Settings::instance()->themeSetting->value("CustomTheme/TitleStyle")) { + systemTheme = DGuiApplicationHelper::LightType; + } + DApplicationHelper::instance()->setPaletteType(systemTheme); + setColorScheme(theme); + return; } // 设置主题