Skip to content

fix(ui): set icon opacity for photo mode buttons in takePhotoSettingA…#474

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
Resurgamz:release/eagle
May 21, 2026
Merged

fix(ui): set icon opacity for photo mode buttons in takePhotoSettingA…#474
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
Resurgamz:release/eagle

Conversation

@Resurgamz
Copy link
Copy Markdown

@Resurgamz Resurgamz commented May 21, 2026

…reaWidget

Add setIconOpacity(1) calls for flashlight, delay, filters, and exposure buttons when entering photo mode to restore correct visual state

修复(ui): 拍照模式下恢复按钮图标透明度状态

进入拍照模式时对闪光灯、延迟拍摄、滤镜、曝光按钮调用 setIconOpacity(1), 恢复按钮图标正常透明度显示

Log: 修复拍照模式按钮图标透明度异常
Bug: https://pms.uniontech.com/bug-view-196565.html

Summary by Sourcery

Bug Fixes:

  • Fix incorrect icon opacity for flashlight, delay, filters, and exposure buttons in photo mode.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 21, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Restores correct icon opacity for photo mode control buttons when entering photo mode by explicitly resetting icon opacity on key UI buttons alongside existing overall opacity changes.

Flow diagram for photo mode button opacity updates

flowchart LR
    A[enterPhotoMode setState true] --> B[setOpacity 102 on m_flashlightUnfoldBtn]
    A --> C[setOpacity 102 on m_filtersUnfoldBtn]
    A --> D[setOpacity 102 on m_exposureBtn]
    A --> E[setIconOpacity 1 on m_flashlightUnfoldBtn]
    A --> F[setIconOpacity 1 on m_delayUnfoldBtn]
    A --> G[setIconOpacity 1 on m_filtersUnfoldBtn]
    A --> H[setIconOpacity 1 on m_exposureBtn]
Loading

File-Level Changes

Change Details Files
Ensure photo mode control buttons reset icon opacity when entering photo mode to avoid stale semi-transparent icons.
  • In photo mode state branch, keep existing overall button opacity set to 102 for flashlight, filters, and exposure buttons
  • Add setIconOpacity(1) calls for flashlight, delay, filters, and exposure buttons when switching to photo mode to restore full icon opacity
src/src/takephotosettingareawidget.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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider replacing the hard-coded opacity values (e.g., 102 and 1) with named constants or an enum to make the intended visual states clearer and easier to maintain.
  • It may be worth centralizing the logic that restores button opacity/iconOpacity for photo mode into a small helper to avoid future inconsistencies if more buttons or states are added.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider replacing the hard-coded opacity values (e.g., `102` and `1`) with named constants or an enum to make the intended visual states clearer and easier to maintain.
- It may be worth centralizing the logic that restores button opacity/iconOpacity for photo mode into a small helper to avoid future inconsistencies if more buttons or states are added.

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.

…reaWidget

Add setIconOpacity(1) calls for flashlight, delay, filters, and exposure buttons when entering photo mode to restore correct visual state

修复(ui): 拍照模式下恢复按钮图标透明度状态

进入拍照模式时对闪光灯、延迟拍摄、滤镜、曝光按钮调用 setIconOpacity(1), 恢复按钮图标正常透明度显示

Log: 修复拍照模式按钮图标透明度异常
Bug: https://pms.uniontech.com/bug-view-196565.html
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

你好!我是你的智能编程助手 CodeGeeX。我已仔细审查了你提供的 Git Diff 输入。本次代码变更主要包含两处修改:一处是版权年份的更新,另一处是在 setState 函数中为四个按钮设置了图标透明度。

以下是我对本次代码变更的详细审查意见:

1. 语法逻辑

  • 逻辑一致性缺失:在 if (bPhoto)true 的分支中,你为四个按钮(m_flashlightUnfoldBtn, m_delayUnfoldBtn, m_filtersUnfoldBtn, m_exposureBtn)设置了 setIconOpacity(1)。然而,在对应的 else 分支中,只对其中三个按钮调用了 setVisible(false)缺少了 m_delayUnfoldBtn->setVisible(false);
    • 潜在风险:如果 m_delayUnfoldBtnelse 分支中没有被隐藏,那么当 bPhotofalse 时,该按钮可能会残留在界面上,导致 UI 逻辑错误。如果它是被其他逻辑隐藏的,那么代码的聚合性就较差,建议将相关的状态设置放在一起。

2. 代码质量

  • 代码重复与可维护性:在 if 分支中,对四个按钮连续调用了相同参数的 setIconOpacity(1),在此之前还有对 setOpacity(102) 的调用。这种针对同一组控件进行批量相同属性设置的代码显得比较冗余。
    • 改进建议:可以考虑将这些按钮指针放入一个容器(如 QListQVector),然后通过遍历的方式统一设置属性。这样不仅代码更简洁,未来如果增加或删除按钮,只需修改容器初始化的地方即可,无需修改业务逻辑。
  • 版权年份更新:将 2021 改为 2026 属于常规更新,但请注意,2026 是未来的年份。如果这是为了省去未来几年频繁修改的麻烦,某些开源合规检查工具可能会抛出警告(因为版权年份通常应反映首次发布或最近修改的实际年份)。请确认这符合你们团队的规范。

3. 代码性能

  • 性能影响极小:本次变更仅仅是修改了控件的属性(透明度),这些都是 O(1) 的操作,且触发的是 UI 重绘,在性能上没有可挑剔的地方,不会造成性能瓶颈。

4. 代码安全

  • 空指针风险:代码中直接调用了 m_delayUnfoldBtn->setIconOpacity(1) 等方法,但没有进行空指针检查。虽然在这些成员变量通常在构造函数中初始化,但如果存在对象生命周期管理不当或初始化顺序问题,可能会导致空指针解引用(Null Pointer Dereference)崩溃。
    • 改进建议:如果这些按钮的创建和当前函数的调用不在同一个线程,或者其生命周期不完全确定,建议在调用前增加 Q_ASSERTif (m_delayUnfoldBtn) 的判断。

综合改进建议代码示例

基于以上分析,我为你提供一份重构后的代码示例,以提升代码的健壮性和可维护性:

// 在头文件中(如 takephotosettingareawidget.h)添加成员变量:
// QList<QWidget*> m_photoModeButtons; // 或者使用对应的按钮类型,如 QList<CustomButton*> m_photoModeButtons;

// 在构造函数中进行初始化(确保按钮 new 之后):
// m_photoModeButtons = {m_flashlightUnfoldBtn, m_delayUnfoldBtn, m_filtersUnfoldBtn, m_exposureBtn};

// 修改后的 setState 函数:
void takePhotoSettingAreaWidget::setState(bool bPhoto)
{
    // ... 前置代码 ...

    if (bPhoto) {
        // 使用范围 for 循环统一设置,减少代码重复
        for (auto* btn : m_photoModeButtons) {
            if (btn) { // 安全性检查
                btn->setVisible(true); // 确保可见(如果原逻辑需要)
            }
        }
        
        // 单独处理特殊透明度的设置(如果 setOpacity 和 setIconOpacity 是所有按钮共有的,也可以放入循环)
        m_flashlightUnfoldBtn->setOpacity(102);
        m_filtersUnfoldBtn->setOpacity(102);
        m_exposureBtn->setOpacity(102);
        
        for (auto* btn : m_photoModeButtons) {
            if (btn) {
                btn->setIconOpacity(1);
            }
        }
    } else {
        // 统一隐藏,修复原先可能遗漏 m_delayUnfoldBtn 的问题
        for (auto* btn : m_photoModeButtons) {
            if (btn) {
                btn->setVisible(false);
            }
        }
    }
    
    // ... 后置代码 ...
}

总结:本次变更最核心的问题是逻辑一致性缺失else 分支可能遗漏了对 m_delayUnfoldBtn 的隐藏),建议优先排查并修复。其次,通过引入容器和遍历的方式,可以显著提升代码的整洁度和可维护性。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, Resurgamz

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

@Resurgamz
Copy link
Copy Markdown
Author

/merge

@deepin-bot deepin-bot Bot merged commit dc12dc8 into linuxdeepin:release/eagle May 21, 2026
22 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