Skip to content

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Oct 13, 2025

  1. Fix scrollbar hide animation logic to properly handle mouse hover and press events
  2. Change from setting property flag to directly restarting animation when scrollbar is hovered or pressed
  3. Add condition to only restart animation when it's already running
  4. This ensures smooth animation behavior when user interacts with scrollbar during hide animation

fix: 修复滚动条隐藏动画行为

  1. 修复滚动条隐藏动画逻辑,正确处理鼠标悬停和按下事件
  2. 从设置属性标志改为在滚动条悬停或按下时直接重启动画
  3. 添加条件,仅在动画运行时才重启动画
  4. 确保用户在隐藏动画期间与滚动条交互时的平滑动画行为

deepin-ci-robot added a commit to linuxdeepin/qt6integration that referenced this pull request Oct 13, 2025
Synchronize source files from linuxdeepin/qt5integration.

Source-pull-request: linuxdeepin/qt5integration#283
@wjyrich wjyrich force-pushed the fix-scrollbar-show branch from 095149c to 2711dcd Compare October 13, 2025 09:05
deepin-ci-robot added a commit to linuxdeepin/qt6integration that referenced this pull request Oct 13, 2025
Synchronize source files from linuxdeepin/qt5integration.

Source-pull-request: linuxdeepin/qt5integration#283
@wjyrich wjyrich force-pushed the fix-scrollbar-show branch from 2711dcd to 4904088 Compare October 13, 2025 09:06
deepin-ci-robot added a commit to linuxdeepin/qt6integration that referenced this pull request Oct 13, 2025
Synchronize source files from linuxdeepin/qt5integration.

Source-pull-request: linuxdeepin/qt5integration#283
1. Fix scrollbar hide animation logic to properly handle mouse hover and
press events
2. Change from setting property flag to directly restarting animation
when scrollbar is hovered or pressed
3. Add condition to only restart animation when it's already running
4. This ensures smooth animation behavior when user interacts with
scrollbar during hide animation

fix: 修复滚动条隐藏动画行为

1. 修复滚动条隐藏动画逻辑,正确处理鼠标悬停和按下事件
2. 从设置属性标志改为在滚动条悬停或按下时直接重启动画
3. 添加条件,仅在动画运行时才重启动画
4. 确保用户在隐藏动画期间与滚动条交互时的平滑动画行为
@wjyrich wjyrich force-pushed the fix-scrollbar-show branch from 4904088 to 333dde4 Compare October 13, 2025 09:06
deepin-ci-robot added a commit to linuxdeepin/qt6integration that referenced this pull request Oct 13, 2025
Synchronize source files from linuxdeepin/qt5integration.

Source-pull-request: linuxdeepin/qt5integration#283
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

这段代码的修改是关于滚动条动画控制的逻辑。我来分析一下这个改动:

语法逻辑

  • 原代码只检查滚动条是否被悬停或按下(isHoveredOrPressed)
  • 新代码增加了对动画状态的检查(st == QAbstractAnimation::Running)
  • 语法上没有问题,逻辑更严谨了

代码质量

  • 改进后的代码质量更高,因为它考虑了动画的运行状态
  • 添加了注释说明标记属性的作用,提高了代码可读性
  • 通过增加动画状态检查,可以避免在动画未运行时进行不必要的处理

代码性能

  • 这个改动实际上提高了性能,因为它避免了对非运行状态动画的处理
  • 减少了不必要的属性设置操作

代码安全

  • 改进更安全,因为它确保只有在动画运行时才执行相关操作
  • 避免了在动画未运行时可能出现的竞态条件

建议改进

  1. 可以考虑将动画状态检查提取为一个单独的函数,提高代码可读性:
bool isAnimationRunning(const QStyleOptionSlider *scrollBar) {
    QPropertyAnimation *animation = qobject_cast<QPropertyAnimation*>(scrollBar->widget()->property("_d_dtk_scrollbar_animation").value<QObject*>());
    return animation && animation->state() == QAbstractAnimation::Running;
}

// 然后在原代码中使用:
if (isHoveredOrPressed && isAnimationRunning(scrollBar)) {
    // ...
}
  1. 可以考虑添加日志输出,便于调试:
if (isHoveredOrPressed && st == QAbstractAnimation::Running) {
    qDebug() << "Scrollbar animation is running, keeping visible";
    // ...
}
  1. 建议添加对st变量的空值检查,以防万一:
if (isHoveredOrPressed && st && st == QAbstractAnimation::Running) {
    // ...
}

总体来说,这是一个合理的改进,使代码更加健壮和可靠。

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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 18202781743 merged commit 66c83e0 into linuxdeepin:master Oct 13, 2025
21 of 22 checks passed
18202781743 pushed a commit to linuxdeepin/qt6integration that referenced this pull request Oct 13, 2025
Synchronize source files from linuxdeepin/qt5integration.

Source-pull-request: linuxdeepin/qt5integration#283
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