mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
Port away from deprecated QStyle::SH_Widget_Animate
Summary: Use the new QStyle::SH_Widget_Animation_Duration instead, which allows us to not manually hardcode the duration. We still use 1 if animations are disabled, otherwise the scroll would not work at all. See also D5883 for some background. Test Plan: Played with different values in the Animation tab of the Breeze config dialog. Reviewers: #dolphin, broulik Reviewed By: broulik Subscribers: broulik Differential Revision: https://phabricator.kde.org/D10005
This commit is contained in:
parent
c5eb4e3116
commit
7caef6d251
|
@ -35,8 +35,14 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
|
||||||
m_animation(nullptr)
|
m_animation(nullptr)
|
||||||
{
|
{
|
||||||
m_animation = new QPropertyAnimation(this);
|
m_animation = new QPropertyAnimation(this);
|
||||||
const int duration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_scrollBar) ? 100 : 1;
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
m_animation->setDuration(duration);
|
const int animationDuration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, m_scrollBar);
|
||||||
|
const bool animationEnabled = (animationDuration > 0);
|
||||||
|
#else
|
||||||
|
const int animationDuration = 100;
|
||||||
|
const bool animationEnabled = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_scrollBar);
|
||||||
|
#endif
|
||||||
|
m_animation->setDuration(animationEnabled ? animationDuration : 1);
|
||||||
connect(m_animation, &QPropertyAnimation::stateChanged,
|
connect(m_animation, &QPropertyAnimation::stateChanged,
|
||||||
this, &KItemListSmoothScroller::slotAnimationStateChanged);
|
this, &KItemListSmoothScroller::slotAnimationStateChanged);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue