Skip to content

fix: handle font change events in dialog#693

Merged
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master
Oct 23, 2025
Merged

fix: handle font change events in dialog#693
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Contributor

Fix dialog size not updating when system font changes
Add font change event handling to recalculate dialog size
Ensure proper layout when font size or family changes

Influence:

  1. Test dialog appearance when system font settings change
  2. Verify dialog size adapts correctly to different font sizes
  3. Check layout integrity after font changes
  4. Test with various font families and sizes

fix: 处理对话框中的字体变更事件

修复系统字体变更时对话框大小不更新的问题
添加字体变更事件处理以重新计算对话框大小
确保字体大小或字体家族变更时的正确布局

Influence:

  1. 测试系统字体设置变更时对话框的显示效果
  2. 验证对话框大小是否正确适应不同的字体大小
  3. 检查字体变更后的布局完整性
  4. 测试不同字体家族和大小的显示效果

PMS: BUG-331061

@18202781743 18202781743 requested review from BLumia and mhduiy October 20, 2025 09:06
@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 Oct 20, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#693
deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Oct 23, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#693
Fix dialog size not updating when system font changes
Add font change event handling to recalculate dialog size
Ensure proper layout when font size or family changes

Influence:
1. Test dialog appearance when system font settings change
2. Verify dialog size adapts correctly to different font sizes
3. Check layout integrity after font changes
4. Test with various font families and sizes

fix: 处理对话框中的字体变更事件

修复系统字体变更时对话框大小不更新的问题
添加字体变更事件处理以重新计算对话框大小
确保字体大小或字体家族变更时的正确布局

Influence:
1. 测试系统字体设置变更时对话框的显示效果
2. 验证对话框大小是否正确适应不同的字体大小
3. 检查字体变更后的布局完整性
4. 测试不同字体家族和大小的显示效果

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

deepin pr auto review

我来对这段代码进行审查和分析。

这段代码是在 DDialog 类的 changeEvent 方法中添加了对字体变化事件的处理。让我们从几个方面来分析:

  1. 语法逻辑:
  • 语法正确,使用 else if 语句正确处理了 QEvent::FontChange 事件
  • 保持了原有的代码风格和缩进
  • 正确调用了基类的 changeEvent 方法
  1. 代码质量:
  • 优点:代码简洁明了,直接调用了 d->updateSize() 来处理字体变化
  • 建议:虽然代码本身没有问题,但可以考虑添加注释说明为什么字体变化需要更新尺寸
  1. 代码性能:
  • 性能考虑:每次字体变化都会触发 updateSize(),这是一个合理的做法,因为字体变化确实可能影响对话框的尺寸
  • 建议:如果更新尺寸的操作比较耗时,可以考虑添加防抖机制,避免短时间内多次触发
  1. 代码安全:
  • 代码安全:没有明显的安全隐患
  • 建议:在调用 d->updateSize() 之前,可以添加对 d 指针的有效性检查

改进建议:

void DDialog::changeEvent(QEvent *event)
{
    if (!d) {  // 添加安全检查
        return DAbstractDialog::changeEvent(event);
    }

    if (event->type() == QEvent::PaletteChange) {
        if (DApplication::dApp()->isDXcbPlatform()) {
            DThemeManager::instance()->updateTheme(this);
        }
        d->updateSize();
    } else if (event->type() == QEvent::FontChange) {
        // 字体变化时需要更新对话框尺寸以适应新的字体大小
        d->updateSize();
    }
    return DAbstractDialog::changeEvent(event);
}

总的来说,这段修改是合理的,它正确地处理了字体变化事件,确保对话框能够适应字体变化。建议添加安全检查和注释来提高代码的健壮性和可维护性。

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

Source-pull-request: linuxdeepin/dtkwidget#693
@18202781743 18202781743 merged commit 431d824 into linuxdeepin:master Oct 23, 2025
22 of 23 checks passed
18202781743 pushed a commit to linuxdeepin/dtk6widget that referenced this pull request Oct 23, 2025
Synchronize source files from linuxdeepin/dtkwidget.

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