From aecf9237cc945025061c526dda29c0035aece2ac Mon Sep 17 00:00:00 2001 From: Carson Black Date: Sat, 12 Dec 2020 01:39:47 -0500 Subject: [PATCH] Add veryShortDuration This adds an veryShortDuration for UI elements that should animate near instantly, but should have a hint of smoothness. --- src/declarativeimports/core/units.cpp | 5 +++++ src/declarativeimports/core/units.h | 12 ++++++++++++ .../kirigamiplasmadesktopstyle/Units.qml | 6 ++++++ src/declarativeimports/kirigamiplasmastyle/Units.qml | 6 ++++++ 4 files changed, 29 insertions(+) diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp index 9a041bf7e..4642b1b94 100644 --- a/src/declarativeimports/core/units.cpp +++ b/src/declarativeimports/core/units.cpp @@ -261,6 +261,11 @@ int Units::shortDuration() const return qMax(1, qRound(m_longDuration * 0.6)); } +int Units::veryShortDuration() const +{ + return qRound(m_longDuration * 0.3); +} + int Units::veryLongDuration() const { return m_longDuration * 2; diff --git a/src/declarativeimports/core/units.h b/src/declarativeimports/core/units.h index b3b93dabc..8d657079c 100644 --- a/src/declarativeimports/core/units.h +++ b/src/declarativeimports/core/units.h @@ -119,6 +119,12 @@ class Units : public QObject */ Q_PROPERTY(int shortDuration READ shortDuration NOTIFY durationChanged) + /** + * units.veryShortDuration should be used for elements that should animate near instantly, + * but should have a hint of smoothness + */ + Q_PROPERTY(int veryShortDuration READ veryShortDuration NOTIFY durationChanged) + /** * units.veryLongDuration should be used for specialty animations that benefit * from being even longer than longDuration. @@ -186,6 +192,12 @@ public: * @since 5.69 */ int veryLongDuration() const; + + /** + * @return Duration for instantaneous animations, in milliseconds. + * @since 5.78 + */ + int veryShortDuration() const; /// @endcond /** diff --git a/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml b/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml index 2893e1efb..952267f8e 100644 --- a/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml +++ b/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml @@ -96,6 +96,12 @@ QtObject { */ property int veryLongDuration: units.veryLongDuration + /** + * units.veryShortDuration should be used for elements that should have a hint of smoothness, + * but otherwise animate near instantly. + */ + property int veryShortDuration: units.veryShortDuration + readonly property QtObject __styleItem: QtQuickControlsPrivate.StyleItem {elementType: "frame" } /** diff --git a/src/declarativeimports/kirigamiplasmastyle/Units.qml b/src/declarativeimports/kirigamiplasmastyle/Units.qml index 8e475aefa..8afc7839d 100644 --- a/src/declarativeimports/kirigamiplasmastyle/Units.qml +++ b/src/declarativeimports/kirigamiplasmastyle/Units.qml @@ -84,6 +84,12 @@ QtObject { */ property int shortDuration: units.shortDuration + /** + * units.veryShortDuration should be used for elements that should have a hint of smoothness, + * but otherwise animate near instantly. + */ + property int veryShortDuration: units.veryShortDuration + /** * units.veryLongDuration should be used for specialty animations that benefit * from being even longer than longDuration.