Skip to content

fix: improve dialog sizing and remove unused event filter#697

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
18202781743:master
Oct 28, 2025
Merged

fix: improve dialog sizing and remove unused event filter#697
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Contributor

  1. Enhanced dialog width calculation to respect maximum width constraint
  2. Added dynamic height calculation based on layout's total height for
    the given width
  3. Removed unused event filter for title and message labels that handled
    font changes
  4. The event filter was unnecessary as Qt's layout system already
    handles text wrapping properly

Influence:

  1. Test dialog resizing with various content lengths
  2. Verify dialog respects maximum width settings
  3. Check that text wrapping works correctly in title and message labels
  4. Test dialog appearance with different font sizes
  5. Ensure dialog maintains minimum size requirements

fix: 改进对话框尺寸计算并移除未使用的事件过滤器

  1. 增强对话框宽度计算以遵循最大宽度约束
  2. 添加基于布局总高度的动态高度计算
  3. 移除用于标题和消息标签字体变化的未使用事件过滤器
  4. 该事件过滤器不再必要,因为Qt的布局系统已能正确处理文本换行

Influence:

  1. 测试不同内容长度时的对话框调整大小
  2. 验证对话框遵循最大宽度设置
  3. 检查标题和消息标签中的文本换行是否正确工作
  4. 测试不同字体大小下的对话框外观
  5. 确保对话框保持最小尺寸要求

PMS: BUG-331061

1. Enhanced dialog width calculation to respect maximum width constraint
2. Added dynamic height calculation based on layout's total height for
the given width
3. Removed unused event filter for title and message labels that handled
font changes
4. The event filter was unnecessary as Qt's layout system already
handles text wrapping properly

Influence:
1. Test dialog resizing with various content lengths
2. Verify dialog respects maximum width settings
3. Check that text wrapping works correctly in title and message labels
4. Test dialog appearance with different font sizes
5. Ensure dialog maintains minimum size requirements

fix: 改进对话框尺寸计算并移除未使用的事件过滤器

1. 增强对话框宽度计算以遵循最大宽度约束
2. 添加基于布局总高度的动态高度计算
3. 移除用于标题和消息标签字体变化的未使用事件过滤器
4. 该事件过滤器不再必要,因为Qt的布局系统已能正确处理文本换行

Influence:
1. 测试不同内容长度时的对话框调整大小
2. 验证对话框遵循最大宽度设置
3. 检查标题和消息标签中的文本换行是否正确工作
4. 测试不同字体大小下的对话框外观
5. 确保对话框保持最小尺寸要求

PMS: BUG-331061
@18202781743 18202781743 requested review from BLumia and mhduiy October 28, 2025 06:12
deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Oct 28, 2025
Synchronize source files from linuxdeepin/dtkwidget.

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

deepin pr auto review

我来对这段代码变更进行详细分析:

  1. 修改内容分析:

第一处修改在 updateSize() 函数中:

size.setWidth(qMin(q->maximumWidth(), qMax(size.width(), DIALOG::DEFAULT_WIDTH)));
if (auto layout = q->layout()) {
    size.setHeight(layout->totalHeightForWidth(size.width()));
}

第二处修改删除了 eventFilter() 中对标签字体变化的处理代码。

  1. 改进建议:

语法逻辑:

  • 代码语法正确,逻辑清晰
  • 第一处修改增加了对最大宽度的限制,并使用布局计算高度,这是合理的改进
  • 第二处修改删除了字体变化处理,需要确认是否会影响功能

代码质量:

  • 使用了 auto 关键字,符合现代C++风格
  • 代码结构清晰,易于理解
  • 建议在 totalHeightForWidth 调用前添加空指针检查

代码性能:

  • 新增的布局计算可能会带来轻微性能开销,但这是必要的功能改进
  • 删除事件过滤器中的字体变化处理可以提升性能

代码安全:

  • 使用 auto 时已经进行了类型检查
  • 建议添加对 layout() 返回值的空指针检查
  1. 具体改进建议:
void DDialogPrivate::updateSize()
{
    if (!q->testAttribute(Qt::WA_Resized)) {
        QSize size = q->sizeHint();

        // 限制宽度在最大值和默认值之间
        size.setWidth(qMin(q->maximumWidth(), qMax(size.width(), DIALOG::DEFAULT_WIDTH)));
        
        // 安全地获取布局并计算高度
        if (QLayout *layout = q->layout()) {
            size.setHeight(layout->totalHeightForWidth(size.width()));
        }
        
        // 确保最小高度
        size.setHeight(qMax(size.height(), DIALOG::DEFAULT_HEIGHT));

        q->resize(size);
    }
}
  1. 潜在问题:
  • 删除字体变化处理可能会影响某些场景下的显示效果,建议确认这个改动是否会影响现有功能
  • 如果确实需要处理字体变化,可以考虑将其移到更合适的位置,比如单独的更新函数中
  1. 总体评价:
    这次改动主要优化了对话框的尺寸计算逻辑,使其更加合理和可控。删除事件过滤器中的字体处理代码可能是为了简化逻辑或性能优化,但需要确保不会影响功能。建议在提交前进行充分的测试,特别是涉及字体变化的场景。

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

@18202781743
Copy link
Contributor Author

/forcemerge

18202781743 pushed a commit to linuxdeepin/dtk6widget that referenced this pull request Oct 28, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#697
@deepin-bot
Copy link
Contributor

deepin-bot bot commented Oct 28, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit 67dc851 into linuxdeepin:master Oct 28, 2025
20 of 23 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