Skip to content

Commit

Permalink
fix: Bug#5930 将主题设置为跟随系统后,再将鼠标移动到深色时,预览图的标题栏没有同步展示为深色 (#312)
Browse files Browse the repository at this point in the history
* fix: Bug#5930 将主题设置为跟随系统后,再将鼠标移动到深色时,预览图的标题栏没有同步展示为深色

修复悬浮预览主题,会受选中的主题影响

Log: 将主题设置为跟随系统后,再将鼠标移动到深色时,预览图的标题栏没有同步展示为深色

Bug: linuxdeepin/developer-center#5930

* chore: 修复选中跟随系统不跟随系统变化

修复选中跟随系统不跟随系统变化

Log: 修复选中跟随系统不跟随系统变化

---------

Co-authored-by: daizhengwen <[email protected]>
  • Loading branch information
DaiZW007 and daizhengwen authored Nov 3, 2023
1 parent aa974a7 commit de13409
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/views/termwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}

// 设置主题
Expand Down

0 comments on commit de13409

Please sign in to comment.