Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 增加滚动区域滚轮滚动到顶部或底部的回弹效果 #596

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

Whale107
Copy link
Contributor

@Whale107 Whale107 commented Aug 5, 2024

增加滚动区域滚轮滚动到顶部或底部的回弹效果

Log:

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Whale107

The full list of commands accepted by this bot can be found here.

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 Aug 5, 2024
Synchronize source files from linuxdeepin/dtkwidget.

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

deepin-bot bot commented Aug 5, 2024

Doc Check bot
🟡 some documents missing!

File Line Symbol
include/widgets/dbounceanimation.h 17 DBounceAnimation::DBounceAnimation
include/widgets/dbounceanimation.h 19 void DBounceAnimation::setAnimationTarget
include/widgets/dbounceanimation.h 20 void DBounceAnimation::setAniMationEnable
include/widgets/dbounceanimation.h 13 DBounceAnimation
src/widgets/private/dbounceanimation_p.h 15 QPropertyAnimation* DBounceAnimationPrivate::m_animation
src/widgets/private/dbounceanimation_p.h 16 QAbstractScrollArea* DBounceAnimationPrivate::m_animationTarget
src/widgets/private/dbounceanimation_p.h 17 int DBounceAnimationPrivate::m_deltaSum
src/widgets/private/dbounceanimation_p.h 13 DBounceAnimationPrivate::DBounceAnimationPrivate
src/widgets/private/dbounceanimation_p.h 10 DBounceAnimationPrivate

return;

d->m_animationTarget = w;

Copy link
Contributor

Choose a reason for hiding this comment

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

空行

if (!w)
return;

w->installEventFilter(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

有 install 应该有 uninstall 的逻辑,比如 if (d->m_animationTarget != w)


QTimer::singleShot(100, this, [this, d, orientation]() {

orientation & Qt::Vertical
Copy link
Contributor

Choose a reason for hiding this comment

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

不用 if else 的理由是啥, 这样可读性更差。。。

@@ -196,6 +198,8 @@ DListView::DListView(QWidget *parent) :
DObject(*new DListViewPrivate(this))
{
d_func()->init();
auto animation = new DBounceAnimation(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

可以加一个环境变量禁用这种动画的。 类似 if (!qEnvironmentVariableIsSet("DTK_DISABLE_LISTVIEW_ANIMATION"))

public:
explicit DBounceAnimation(QObject *parent = nullptr);

void setAnimationTarget(QAbstractScrollArea *w);
Copy link
Contributor

Choose a reason for hiding this comment

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

可以加一个 setEnable 接口方便用户禁用启用

增加滚动区域滚轮滚动到顶部或底部的回弹效果

Log:
deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Aug 12, 2024
Synchronize source files from linuxdeepin/dtkwidget.

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

deepin pr auto review

关键摘要:

  • DBounceAnimation类的构造函数中,没有检查parent参数是否为nullptr,可能会导致未定义行为。
  • setAnimationTarget方法中,如果m_animationTarget已经设置为w,则没有必要再次设置。
  • eventFilter方法中,处理QWheelEvent的逻辑可能不正确,因为wheelEvent的参数类型是QWheelEvent *,而不是QEvent *
  • bounceBack方法中,使用d->m_animationTarget->viewport()->x()y()获取滚动视图的坐标,但没有考虑到滚动视图可能没有viewport()对象的情况。
  • bounceBack方法中,使用d->m_animationTarget->horizontalScrollBar()->maximum()minimum()获取水平滚动条的最大和最小值,但没有考虑到滚动条可能不存在的情况。
  • bounceBack方法中,使用d->m_animationTarget->verticalScrollBar()->maximum()minimum()获取垂直滚动条的最大和最小值,但没有考虑到滚动条可能不存在的情况。
  • bounceBack方法中,当m_animationdirectionBackward时,没有正确地设置m_animationdirectionForward,而是直接修改了m_animationsetDirection方法。
  • bounceBack方法中,没有正确处理m_animationfinished信号,可能导致资源泄漏。
  • bounceBack方法中的QTimer::singleShot回调函数中使用了this指针,但没有考虑到this指针可能为nullptr的情况。
  • DBounceAnimationPrivate类的构造函数中,没有正确地初始化m_animationm_animationTarget成员变量。
  • DBounceAnimationPrivate类中的m_deltaSum成员变量应该使用int类型,而不是QPoint类型。

是否建议立即修改:

@Whale107 Whale107 merged commit a25938d into linuxdeepin:dev/animation Aug 21, 2024
20 of 21 checks passed
Whale107 added a commit to Whale107/dtkwidget that referenced this pull request Sep 23, 2024
增加滚动区域滚轮滚动到顶部或底部的回弹效果

Log:
deepin-bot bot pushed a commit that referenced this pull request Sep 23, 2024
增加滚动区域滚轮滚动到顶部或底部的回弹效果

Log:
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