Skip to content

fix(personalization): fix treeland theme switching logic#3294

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
mhduiy:appearnace-auto
Jun 16, 2026
Merged

fix(personalization): fix treeland theme switching logic#3294
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
mhduiy:appearnace-auto

Conversation

@mhduiy

@mhduiy mhduiy commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

当控制中心设置为自动时,系统深浅色会动态变更。之前直接把treeland的实际深浅色
属性设置到model中,会导致控制中心选项中的"自动"显示为"深色"或"浅色",
这不符合预期。

现在改用 dde-appearance 保存的 GlobalTheme 属性作为控制中心深浅色的数据来源, 该数据在自动模式下保持不变,正确显示为"自动"。

pms: BUG-346357

Summary by Sourcery

Bug Fixes:

  • Prevent the control center theme option from incorrectly showing Light or Dark when system theme is set to Auto by decoupling it from Treeland's dynamically changing actual theme state.

@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes direct updates of the model’s current appearance based on Treeland’s actual light/dark theme, and instead relies on dde-appearance’s GlobalTheme as the single source of truth for control center theme state to keep the 'Auto' option stable.

File-Level Changes

Change Details Files
Stop mapping Treeland’s effective light/dark theme directly into the model and document the new behavior of using GlobalTheme as the data source for control center theme state.
  • Removed the switch statement that set model currentAppearance to .light/.dark/"" based on theme_type values
  • Left the windowThemeTypeChanged(themeType) signal emission intact so Treeland updates still propagate
  • Added detailed comments explaining why Treeland’s effective theme is no longer written into the model and that dde-appearance GlobalTheme should be used instead
src/plugin-personalization/operation/treelandworker.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • If m_model->setCurrentAppearance(...) is no longer used as a result of this change, consider removing the now-unused method and related state to avoid confusion and dead code.
  • Given that the model no longer reacts to themeType here, double-check whether any UI elements still depend on this signal-to-model linkage and, if not, clean up any remaining references to currentAppearance in the model to keep responsibilities clear.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- If `m_model->setCurrentAppearance(...)` is no longer used as a result of this change, consider removing the now-unused method and related state to avoid confusion and dead code.
- Given that the model no longer reacts to `themeType` here, double-check whether any UI elements still depend on this signal-to-model linkage and, if not, clean up any remaining references to `currentAppearance` in the model to keep responsibilities clear.

## Individual Comments

### Comment 1
<location path="src/plugin-personalization/operation/treelandworker.cpp" line_range="632-634" />
<code_context>
-        m_model->setCurrentAppearance("");
-        break;
-    }
+    // 设置给Treeland的深浅色属性是系统实际生效的深浅色,当控制中心设置为自动时,此时系统的深浅色会动态的变更
+    // 如果直接把treeland的属性设置到model中,会导致控制中心选项中的自动显示为深色或者浅色,这不符合预期。
+    // 现在使用 dde-appearance 保存的GlobalTheme属性来作为控制中心深浅色的数据来源,该数据在自动时数据保持不变
 }

</code_context>
<issue_to_address>
**issue:** Comment describes behavior that is not reflected in this function’s implementation.

This comment describes behavior (using dde-appearance’s GlobalTheme as the source of truth in auto mode) that this function no longer implements—it only emits a signal. If that logic now lives elsewhere, this comment should be updated or removed so it reflects what this function actually does, and the higher-level behavior documented where it is implemented instead.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/plugin-personalization/operation/treelandworker.cpp
robertkill
robertkill previously approved these changes Jun 12, 2026
@mhduiy mhduiy force-pushed the appearnace-auto branch 2 times, most recently from 48e6f49 to b40ca36 Compare June 12, 2026 08:19
当控制中心设置为自动时,系统深浅色会动态变更。之前直接把treeland的实际深浅色
属性设置到model中,会导致控制中心选项中的"自动"显示为"深色"或"浅色",
这不符合预期。

现在改用 dde-appearance 保存的 GlobalTheme 属性作为控制中心深浅色的数据来源,
该数据在自动模式下保持不变,正确显示为"自动"。

pms: BUG-346357
@mhduiy mhduiy force-pushed the appearnace-auto branch from b40ca36 to ff5b89b Compare June 16, 2026 01:30
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy, robertkill

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mhduiy

mhduiy commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit f9ea53f into linuxdeepin:master Jun 16, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants