Skip to content

fix(editor): add hover and press states to color mark icons - #538

Open
tianming-1996 wants to merge 1 commit into
linuxdeepin:masterfrom
tianming-1996:bug-196825-color-mark-states
Open

fix(editor): add hover and press states to color mark icons#538
tianming-1996 wants to merge 1 commit into
linuxdeepin:masterfrom
tianming-1996:bug-196825-color-mark-states

Conversation

@tianming-1996

@tianming-1996 tianming-1996 commented Aug 20, 2026

Copy link
Copy Markdown

Log: 增加颜色标记图标悬停与按压状态
Bug: https://pms.uniontech.com/bug-view-196825.html
Influence: 右键菜单颜色标记增加悬停和按压反馈,兼容 Qt5/Qt6。

Summary by Sourcery

Add interactive hover and press states to color mark icons and finalize selection on release.

New Features:

  • Add hover and pressed visual feedback to color mark icons in the color selection widget.

Bug Fixes:

  • Ensure color selection is committed on left-button release while preserving responsive press feedback.

Enhancements:

  • Support the updated pointer-event behavior across Qt5 and Qt6.

Tests:

  • Extend color label tests to cover hover, pressed, release, and cross-version event handling.

Chores:

  • Update widget copyright years.

Log: 增加颜色标记图标悬停与按压状态
Bug: https://pms.uniontech.com/bug-view-196825.html
Influence: 右键菜单颜色标记增加悬停和按压反馈,兼容 Qt5/Qt6。

@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.

Sorry @tianming-1996, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tianming-1996

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

@sourcery-ai

sourcery-ai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds hover and press visual feedback states to color mark icons in ColorLabel, refactors mouse event handling to separate press/release logic, and extends tests to cover new states and behavior while maintaining Qt5/Qt6 compatibility.

Sequence diagram for ColorLabel hover/press/release interaction

sequenceDiagram
    actor User
    participant ColorLabel
    participant DWidget
    participant ColorSelectWdg

    User->>ColorLabel: enterEvent
    ColorLabel->>DWidget: enterEvent
    ColorLabel->>ColorLabel: m_bHover = true
    ColorLabel->>ColorLabel: update
    ColorLabel->>ColorLabel: paintEvent (hover state)

    User->>ColorLabel: mousePressEvent (LeftButton)
    ColorLabel->>ColorLabel: m_bPressed = true
    ColorLabel->>ColorLabel: update
    ColorLabel->>DWidget: mousePressEvent
    ColorLabel->>ColorLabel: paintEvent (pressed state)

    User->>ColorLabel: mouseReleaseEvent (LeftButton)
    ColorLabel->>ColorLabel: m_bPressed = false
    ColorLabel->>ColorLabel: m_bSelected = true
    ColorLabel->>ColorLabel: update
    ColorLabel-->>ColorSelectWdg: sigColorClicked(m_bSelected, m_color)
    ColorLabel->>DWidget: mouseReleaseEvent

    User->>ColorLabel: leaveEvent
    ColorLabel->>DWidget: leaveEvent
    ColorLabel->>ColorLabel: m_bHover = false
    ColorLabel->>ColorLabel: m_bPressed = false
    ColorLabel->>ColorLabel: update
    ColorLabel->>ColorLabel: paintEvent (normal/selected state)
Loading

File-Level Changes

Change Details Files
Implement hover, press, and selected visual states for ColorLabel while preserving original appearance as the normal state.
  • Refactored paintEvent logic to branch on pressed, hover, and normal states with different ellipse sizes and colors.
  • Implemented pressed state as a slightly shrunken inner circle with darkened color plus optional selection ring.
  • Implemented hover state as a slightly enlarged circle and optional selection ring.
  • Kept original rendering path as the normal non-hover, non-press case, using inner and outer paths for selection ring.
src/widgets/ColorSelectWdg.cpp
Add hover and press state tracking and event handling to ColorLabel, including Qt5/Qt6 enter event compatibility.
  • Declared enterEvent overload compatible with Qt5 and Qt6 using conditional compilation and marked paint/mouse events as overrides.
  • Added leaveEvent, mousePressEvent, and mouseReleaseEvent overrides to update m_bHover, m_bPressed, and m_bSelected, emit sigColorClicked on release, and call base class event handlers.
  • Introduced m_bHover and m_bPressed boolean members with default false initialization alongside existing selection state.
src/widgets/ColorSelectWdg.h
src/widgets/ColorSelectWdg.cpp
Extend unit tests to cover new hover, press/release behavior and adapt to the updated event model.
  • Updated paintEvent unit test to exercise hover and pressed rendering branches before deletion.
  • Refactored mousePressEvent tests to use stack-allocated QMouseEvent objects, verify m_bPressed toggling, ensure sigColorClicked is emitted only on left-button release, and that right-clicks do not change pressed state.
  • Added a new hover-state test to validate enterEvent and leaveEvent behavior and that both hover and pressed flags reset on leave.
  • Updated ColorSelectWdg lambda test to simulate press then release on a color label, asserting that the first label loses selection and sigColorSelected is emitted only after release.
tests/src/widgets/ut_colorselectwidget.cpp
Update SPDX copyright years for ColorSelectWdg implementation and header files.
  • Changed SPDX-FileCopyrightText range from 2019 - 2022 to 2019-2026 in implementation and header.
  • Normalized spacing in the SPDX header comment lines.
src/widgets/ColorSelectWdg.cpp
src/widgets/ColorSelectWdg.h

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

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.

2 participants