fix: Prevent terminal theme from being changed by other applications - #545
Conversation
83e9d82 to
ebef10e
Compare
log: When the terminal is in fixed Light/Dark mode but dtkgui's per-app DConfig (org.deepin.dtk.preference.themeType) is out of sync with the saved colorScheme (e.g. upgrades from older builds, wiped or imported DConfig, shipped conf already containing a fixed theme), the isCustomPalette() guard in DGuiApplicationHelper never engages and external dde-appearance palette broadcasts propagate to qApp. Align dtkgui's paletteType with the saved colorScheme at the end of Settings::init() so the existing guard takes effect. Follow-system mode (extendColorScheme empty AND paletteType==UnknownType) is preserved. pms: bug-365877
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: JWWTSL, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 按 colorScheme 对齐 paletteType,激活 dtkgui 的 isCustomPalette() 过滤,
// 避免外部应用切主题时 dde-appearance 经 DPlatformTheme 把 palette 推送到本进程 qApp。
// 跟随系统模式(extendColorScheme 为空且 paletteType 为 UnknownType)保持原状。
{
auto helper = DGuiApplicationHelper::instance();
const bool isFollowSystem = extendColorScheme().isEmpty()
&& helper->paletteType() == DGuiApplicationHelper::UnknownType;
if (!isFollowSystem) {
const QString currentScheme = colorScheme();
DGuiApplicationHelper::ColorType desiredType = DGuiApplicationHelper::DarkType;
if (currentScheme == "Light") {
desiredType = DGuiApplicationHelper::LightType;
} else if (currentScheme == "Dark") {
desiredType = DGuiApplicationHelper::DarkType;
} else {
// 防御性处理:对于非标准主题值,保持当前 paletteType 不变
desiredType = helper->paletteType();
}
if (helper->paletteType() != desiredType) {
helper->setPaletteType(desiredType);
}
}
} |
log: When the terminal is in fixed Light/Dark mode but dtkgui's per-app DConfig (org.deepin.dtk.preference.themeType) is out of sync with the saved colorScheme (e.g. upgrades from older builds, wiped or imported DConfig, shipped conf already containing a fixed theme), the isCustomPalette() guard in DGuiApplicationHelper never engages and external dde-appearance palette broadcasts propagate to qApp. Align dtkgui's paletteType with the saved colorScheme at the end of Settings::init() so the existing guard takes effect. Follow-system mode (extendColorScheme empty AND paletteType==UnknownType) is preserved.
pms: bug-365877