Skip to content

Commit

Permalink
fix: Bug#5930 将主题设置为跟随系统后,再将鼠标移动到深色时,预览图的标题栏没有同步展示为深色
Browse files Browse the repository at this point in the history
修复悬浮预览主题,会受选中的主题影响

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

Bug: linuxdeepin/developer-center#5930
  • Loading branch information
daizhengwen committed Oct 27, 2023
1 parent aa974a7 commit cd1dbf7
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/views/termwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ inline void TermWidget::onColorThemeChanged(const QString &colorTheme)
inline void TermWidget::onThemeChanged(DGuiApplicationHelper::ColorType themeType)
{
if ("System Theme" == Settings::instance()->colorScheme()) {
setTheme("System Theme");
if (DApplicationHelper::instance()->themeType() != themeType) {
setTheme("System Theme");
}
}
}

Expand Down Expand Up @@ -696,24 +698,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 @@ -723,14 +707,29 @@ void TermWidget::changeTitleColor(int lightness)

void TermWidget::setTheme(const QString &colorTheme)
{
qInfo() << "dzw ==== " << 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 cd1dbf7

Please sign in to comment.