From 049978008b1268a1f46bde99ad260002fee7fd56 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Thu, 19 Mar 2020 11:22:55 -0600 Subject: [PATCH] Make animation durations consistent with Kirigami values Summary: Right now longDuration is 120ms and shortDuration is 24ms. This presents three problems: - The durations are far too fast, especially shortDuration, which is so fast that it seems like there is no animation at all. - The durations are not consistent with Kirigami, which uses 150 for short and 250 for long. - There is no longer value available, as with the one being added to Kirigami in D28143. Accordingly, this patch makes the short and long values consistent with Kirigami's values, and adds a new `veryLongDuration` value to match the one being added to Kirigami in D28143. Reviewers: #plasma, davidedmundson, mart Reviewed By: #plasma, mart Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D28144 --- src/declarativeimports/core/plugins.qmltypes | 1 + src/declarativeimports/core/units.cpp | 9 +++++++-- src/declarativeimports/core/units.h | 12 ++++++++++++ .../kirigamiplasmadesktopstyle/Units.qml | 6 ++++++ src/declarativeimports/kirigamiplasmastyle/Units.qml | 6 ++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/declarativeimports/core/plugins.qmltypes b/src/declarativeimports/core/plugins.qmltypes index b66b7d769..b78040db5 100644 --- a/src/declarativeimports/core/plugins.qmltypes +++ b/src/declarativeimports/core/plugins.qmltypes @@ -882,6 +882,7 @@ Module { Property { name: "devicePixelRatio"; type: "double"; isReadonly: true } Property { name: "longDuration"; type: "int"; isReadonly: true } Property { name: "shortDuration"; type: "int"; isReadonly: true } + Property { name: "veryLongDuration"; type: "int"; isReadonly: true } Signal { name: "spacingChanged" } Signal { name: "durationChanged" } Method { diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp index 146ce8525..edb853476 100644 --- a/src/declarativeimports/core/units.cpp +++ b/src/declarativeimports/core/units.cpp @@ -33,7 +33,7 @@ #include #include -const int defaultLongDuration = 120; +const int defaultLongDuration = 250; SharedAppFilter::SharedAppFilter(QObject *parent) @@ -272,7 +272,12 @@ int Units::longDuration() const int Units::shortDuration() const { - return qMax(1, m_longDuration / 5); + return qMax(1, qRound(m_longDuration * 0.6)); +} + +int Units::veryLongDuration() const +{ + return m_longDuration * 2; } #include "moc_units.cpp" diff --git a/src/declarativeimports/core/units.h b/src/declarativeimports/core/units.h index f3d444c7f..129a3bfcf 100644 --- a/src/declarativeimports/core/units.h +++ b/src/declarativeimports/core/units.h @@ -132,6 +132,12 @@ class Units : public QObject */ Q_PROPERTY(int shortDuration READ shortDuration NOTIFY durationChanged) + /** + * units.veryLongDuration should be used for specialty animations that benefit + * from being even longer than longDuration. + */ + Q_PROPERTY(int veryLongDuration READ veryLongDuration NOTIFY durationChanged) + public: /// @cond INTERNAL_DOCS @@ -187,6 +193,12 @@ public: * @since 5.0 */ int shortDuration() const; + + /** + * @return Duration for very long animations, in milliseconds. + * @since 5.69 + */ + int veryLongDuration() const; /// @endcond /** diff --git a/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml b/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml index 40903b7aa..9ddb24a8e 100644 --- a/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml +++ b/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml @@ -99,6 +99,12 @@ QtObject { */ property int shortDuration: units.shortDuration + /** + * units.veryLongDuration should be used for specialty animations that benefit + * from being even longer than longDuration. + */ + property int veryLongDuration: units.veryLongDuration + readonly property QtObject __styleItem: QtQuickControlsPrivate.StyleItem {elementType: "frame" } /** diff --git a/src/declarativeimports/kirigamiplasmastyle/Units.qml b/src/declarativeimports/kirigamiplasmastyle/Units.qml index ef4b6b8d1..19bd59d60 100644 --- a/src/declarativeimports/kirigamiplasmastyle/Units.qml +++ b/src/declarativeimports/kirigamiplasmastyle/Units.qml @@ -93,6 +93,12 @@ QtObject { */ property int shortDuration: units.shortDuration + /** + * units.veryLongDuration should be used for specialty animations that benefit + * from being even longer than longDuration. + */ + property int veryLongDuration: units.veryLongDuration + /** * How much the mouse scroll wheel scrolls, expressed in lines of text. * Note: this is strictly for classical mouse wheels, touchpads 2 figer scrolling won't be affected