From ecd29b671ee955252ae07a5d53a564ba97579f81 Mon Sep 17 00:00:00 2001 From: Tian Shilin Date: Tue, 23 Jun 2026 16:48:55 +0800 Subject: [PATCH] fix: Prevent terminal theme from being changed by other applications 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 --- src/settings/settings.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index 03676f03..154bc998 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd +// Copyright (C) 2019 ~ 2026 Uniontech Software Technology Co.,Ltd // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -150,6 +150,23 @@ void Settings::init() setColorScheme(sysTheme); } } + + // 按 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 auto desiredType = (colorScheme() == "Light") + ? DGuiApplicationHelper::LightType + : DGuiApplicationHelper::DarkType; + if (helper->paletteType() != desiredType) { + helper->setPaletteType(desiredType); + } + } + } /******** Modify by n014361 wangpeili 2020-01-10: 增加窗口状态选项 ************/ auto windowState = settings->option("advanced.window.use_on_starting"); QMap windowStateMap;