Skip to content

fix: add keyboard focus indicator for sliders - #507

Closed
mhduiy wants to merge 1 commit into
masterfrom
fix/dde-304-slider-keyboard-focus
Closed

mhduiy wants to merge 1 commit into
masterfrom
fix/dde-304-slider-keyboard-focus

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

修复内容

修复 PMS BUG-341415:dock 快捷面板滑块缺少键盘焦点指示器。

变更说明

在 SliderProxyStyle::drawComplexControl 方法中新增键盘焦点指示器绘制逻辑:

  • 当滑块获得键盘焦点(QStyle::State_HasFocus)时,使用 DPalette::Highlight 颜色在 handle 周围绘制圆角焦点边框
  • 对 RoundHandler 样式,焦点边框基于重新计算的正方形 handle 区域绘制,与 drawRoundSlider 实际绘制的圆形滑块完全对齐
  • Normal 样式不受影响

关联信息

Summary by Sourcery

Add visible keyboard focus feedback for dock panel sliders.

Bug Fixes:

  • Add a keyboard focus indicator around focused dock sliders to resolve the missing focus feedback issue.

Enhancements:

  • Align the focus indicator with round slider handles while leaving normal slider rendering unchanged.

1. Add focus indicator drawing in SliderProxyStyle::drawComplexControl
2. Draw rounded focus border using DPalette::Highlight when slider has
   keyboard focus (QStyle::State_HasFocus)
3. Recalculate square handle rect for RoundHandler style to align with
   the actual circular slider drawn by drawRoundSlider
4. Normal slider style remains unaffected by the change

Influence:
1. Test slider keyboard focus indicator visibility in dock quick panel
2. Verify RoundHandler style focus border aligns with circular handle
3. Verify Normal style slider has no visual change without focus
4. Test focus indicator appears and disappears correctly with Tab key

fix: 为滑块添加键盘焦点指示器

1. 在 SliderProxyStyle::drawComplexControl 中添加焦点指示器绘制
2. 当滑块获得键盘焦点时使用 DPalette::Highlight 绘制圆角焦点边框
3. RoundHandler 样式重新计算正方形 handle 区域与实际圆形滑块对齐
4. Normal 样式不受此变更影响

Influence:
1. 测试 dock 快捷面板中滑块键盘焦点指示器的可见性
2. 验证 RoundHandler 样式焦点边框与圆形滑块对齐
3. 验证 Normal 样式滑块在无焦点时无视觉变化
4. 测试 Tab 键切换时焦点指示器的显示和隐藏

PMS: BUG-341415
@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

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

Reviewer's Guide

The slider proxy style now renders a palette-highlight rounded focus ring around focused slider handles, with geometry adjusted for round handles to align with their actual circular rendering while preserving existing normal-slider behavior.

Flow diagram for slider keyboard focus indicator rendering

flowchart TD
    A["SliderProxyStyle::drawComplexControl"] --> B{State_HasFocus}
    B -->|No| C["drawNormalSlider or drawRoundSlider"]
    B -->|Yes| D["Get DPalette::Highlight"]
    D --> E{RoundHandler}
    E -->|Yes| F["Recalculate square handle geometry"]
    E -->|No| G["Use rectHandle geometry"]
    F --> H["Expand geometry by margin 3"]
    G --> H
    H --> I["Draw rounded focus border"]
    I --> J["Restore painter"]
    C --> J
Loading

File-Level Changes

Change Details Files
Add a keyboard-focus indicator around the slider handle when the control has focus.
  • Detect QStyle::State_HasFocus in the complex-control drawing path.
  • Use the palette highlight color and a two-pixel pen to draw an unfilled rounded focus border with a three-pixel margin.
  • Recompute the focused handle bounds for RoundHandler so the border aligns with the rendered circular handle.
  • Leave the normal slider rendering path unchanged.
plugins/dde-dock/common/slidercontainer.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

@mhduiy

mhduiy commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

修改不合理,dde-tray-loader 是正确的样式,问题出在dtk,应该在DTK中修复

@mhduiy mhduiy closed this Sep 14, 2026
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.

1 participant