Skip to content

feat: enhance window effect support detection#685

Merged
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master
Sep 16, 2025
Merged

feat: enhance window effect support detection#685
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Contributor

Added supportWindowEffect() function to check for both compositing and
blur window capabilities
Updated color picker button enable state to require both composite and
blur window support
Added connection to handle hasBlurWindowChanged signal for dynamic
enable state updates

This change ensures the color picker button is only enabled when both
compositing and blur window effects are supported by the window manager,
providing better user experience by preventing the button from being
enabled in environments where the picker functionality wouldn't work
properly due to missing window effects.

Log: Color picker button now requires both compositing and blur window
support to be enabled

Influence:

  1. Test color picker button enable/disable state when changing window
    manager compositing settings
  2. Verify button state when blur window support is enabled/disabled
  3. Test in environments with different window manager capabilities
  4. Verify picker functionality works correctly when button is enabled

feat: 增强窗口效果支持检测

新增 supportWindowEffect() 函数检查合成和模糊窗口支持能力
更新颜色选择器按钮启用状态,要求同时具备合成和模糊窗口支持
添加处理 hasBlurWindowChanged 信号的连接,实现动态启用状态更新

此更改确保颜色选择器按钮仅在窗口管理器同时支持合成和模糊窗口效果时启用,
提供更好的用户体验,防止在缺少窗口效果的环境中启用按钮而导致功能无法正常
工作。

Log: 颜色选择器按钮现在需要同时支持合成和模糊窗口效果才能启用

Influence:

  1. 测试更改窗口管理器合成设置时颜色选择器按钮的启用/禁用状态
  2. 验证模糊窗口支持启用/禁用时的按钮状态
  3. 在不同窗口管理器能力的环境中进行测试
  4. 验证按钮启用时选择器功能正常工作

PMS: BUG-329555

Added supportWindowEffect() function to check for both compositing and
blur window capabilities
Updated color picker button enable state to require both composite and
blur window support
Added connection to handle hasBlurWindowChanged signal for dynamic
enable state updates

This change ensures the color picker button is only enabled when both
compositing and blur window effects are supported by the window manager,
providing better user experience by preventing the button from being
enabled in environments where the picker functionality wouldn't work
properly due to missing window effects.

Log: Color picker button now requires both compositing and blur window
support to be enabled

Influence:
1. Test color picker button enable/disable state when changing window
manager compositing settings
2. Verify button state when blur window support is enabled/disabled
3. Test in environments with different window manager capabilities
4. Verify picker functionality works correctly when button is enabled

feat: 增强窗口效果支持检测

新增 supportWindowEffect() 函数检查合成和模糊窗口支持能力
更新颜色选择器按钮启用状态,要求同时具备合成和模糊窗口支持
添加处理 hasBlurWindowChanged 信号的连接,实现动态启用状态更新

此更改确保颜色选择器按钮仅在窗口管理器同时支持合成和模糊窗口效果时启用,
提供更好的用户体验,防止在缺少窗口效果的环境中启用按钮而导致功能无法正常
工作。

Log: 颜色选择器按钮现在需要同时支持合成和模糊窗口效果才能启用

Influence:
1. 测试更改窗口管理器合成设置时颜色选择器按钮的启用/禁用状态
2. 验证模糊窗口支持启用/禁用时的按钮状态
3. 在不同窗口管理器能力的环境中进行测试
4. 验证按钮启用时选择器功能正常工作

PMS: BUG-329555
@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743

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

deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Sep 16, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#685
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

我对这段代码进行了审查,发现了一些可以改进的地方:

  1. 代码结构和逻辑:
  • 新增的 supportWindowEffect() 函数设计合理,将窗口效果的判断逻辑集中处理,提高了代码的可维护性。
  • initUI()initConnection() 中都使用了这个函数,保持了逻辑一致性。
  1. 性能优化:
  • DWindowManagerHelper::instance() 被多次调用,可以考虑将其结果缓存为成员变量,避免重复获取实例。
  • supportWindowEffect() 函数中,同样存在重复获取实例的问题,建议优化。
  1. 代码安全:
  • 目前的代码没有对 DWindowManagerHelper::instance() 的返回值进行空指针检查,如果获取实例失败可能会导致程序崩溃。
  • 建议添加适当的错误处理机制。
  1. 改进建议:
class DPrintPickColorWidget : public DWidget {
    // ... 其他成员 ...
private:
    DWindowManagerHelper *m_windowManagerHelper = nullptr;  // 缓存窗口管理器实例
    bool supportWindowEffect() const {
        return m_windowManagerHelper && 
               m_windowManagerHelper->hasComposite() && 
               m_windowManagerHelper->hasBlurWindow();
    }
};

// 在构造函数中初始化
DPrintPickColorWidget::DPrintPickColorWidget(QWidget *parent)
    : DWidget(parent)
    , pinterface(nullptr)
    , m_windowManagerHelper(DWindowManagerHelper::instance())
{
    // ... 其他初始化代码 ...
}

// 修改后的 initUI 和 initConnection
void DPrintPickColorWidget::initUI()
{
    // ... 其他初始化代码 ...
    pickColorBtn->setEnabled(supportWindowEffect());
    // ... 其他代码 ...
}

void DPrintPickColorWidget::initConnection()
{
    // ... 其他连接代码 ...
    connect(m_windowManagerHelper, &DWindowManagerHelper::hasCompositeChanged, this, [this]() {
        this->pickColorBtn->setEnabled(supportWindowEffect());
    });
    connect(m_windowManagerHelper, &DWindowManagerHelper::hasBlurWindowChanged, this, [this]() {
        this->pickColorBtn->setEnabled(supportWindowEffect());
    });
}
  1. 其他建议:
  • 考虑为 supportWindowEffect() 函数添加注释,说明其功能和用途。
  • 可以将窗口效果的判断逻辑封装为一个单独的类或工具函数,提高代码的复用性。
  • 在连接信号槽时,建议使用 Qt5 的新式语法(函数指针)而非 SIGNAL/SLOT 宏,这样可以更好地进行类型检查。

这些改进可以提高代码的性能、安全性和可维护性,同时保持原有功能的完整性。

@18202781743 18202781743 merged commit f390754 into linuxdeepin:master Sep 16, 2025
22 of 23 checks passed
18202781743 pushed a commit to linuxdeepin/dtk6widget that referenced this pull request Sep 16, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#685
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

Comments