feat: support setColorScheme() API as well#322
Conversation
Reviewer's GuideAdd full support for Qt 6.5+ colorScheme() and Qt 6.8+ requestColorScheme() by tracking an explicit requested scheme, integrating with DTK paletteType/themeName-based detection, and propagating scheme changes into DTK while ensuring theme change handling is correctly triggered. Sequence diagram for Qt setColorScheme() handling and DTK integrationsequenceDiagram
actor QMLApp
participant QStyleHints
participant QPlatformTheme
participant QDeepinTheme
participant DGuiApplicationHelper
participant DPlatformTheme
participant QWindowSystemInterface
QMLApp->>QStyleHints: setColorScheme(Dark/Light/Unknown)
QStyleHints->>QPlatformTheme: requestColorScheme(scheme)
QPlatformTheme->>QDeepinTheme: requestColorScheme(scheme)
QDeepinTheme->>QDeepinTheme: set m_requestedColorScheme
QDeepinTheme->>QWindowSystemInterface: handleThemeChange()
QDeepinTheme->>DGuiApplicationHelper: setPaletteType(DarkType/LightType/UnknownType)
QMLApp->>QStyleHints: colorScheme()
QStyleHints->>QPlatformTheme: colorScheme()
QPlatformTheme->>QDeepinTheme: colorScheme()
alt m_requestedColorScheme != Unknown
QDeepinTheme-->>QPlatformTheme: return m_requestedColorScheme
else helper->paletteType() != UnknownType
QDeepinTheme->>DGuiApplicationHelper: paletteType()
DGuiApplicationHelper-->>QDeepinTheme: DarkType/LightType
QDeepinTheme-->>QPlatformTheme: return Dark/Light
else theme detected from applicationTheme()
QDeepinTheme->>DGuiApplicationHelper: applicationTheme()
DGuiApplicationHelper-->>QDeepinTheme: DPlatformTheme
QDeepinTheme->>DPlatformTheme: themeName()
DPlatformTheme-->>QDeepinTheme: themeName
QDeepinTheme-->>QPlatformTheme: return Dark if themeName endsWith("dark") else Light
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
colorScheme()fallback logic now always returnsLightwhen DTK does not provide a palette type or a theme name ending withdark; if a neutral/unknown state is desirable, consider returningUnknowninstead to avoid forcing light mode in ambiguous cases. - In
colorScheme(), thethemeName.endsWith("dark")check may miss themes with different casing or naming conventions; consider making this comparison case-insensitive or more robust to avoid misclassifying dark themes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `colorScheme()` fallback logic now always returns `Light` when DTK does not provide a palette type or a theme name ending with `dark`; if a neutral/unknown state is desirable, consider returning `Unknown` instead to avoid forcing light mode in ambiguous cases.
- In `colorScheme()`, the `themeName.endsWith("dark")` check may miss themes with different casing or naming conventions; consider making this comparison case-insensitive or more robust to avoid misclassifying dark themes.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
支持 Qt 6.8 的 QStyleHints::setColorScheme() 以及对应的 resetColorScheme() 接口 This amends: ba6d77f PMS: BUG-369921 Log:
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 代码逻辑完善,无需修改 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia 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 |
支持 Qt 6.8 的 QStyleHints::setColorScheme() 以及对应的
resetColorScheme() 接口
This amends: ba6d77f
PMS: BUG-369921
可供测试的 QML 程序:
Summary by Sourcery
Support Qt 6.8 color scheme requests in the Deepin platform theme and align color scheme resolution with DTK’s palette and system theme semantics.
New Features:
Enhancements: