From 30e98ba8f7646fcceaf85cc808e05fcc88b66442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Mon, 3 Feb 2014 16:30:50 +0100 Subject: [PATCH] units.longDuration and units.shortDuration properties These centralize the duration of animations, currently set to 250 and 50 milliseconds. They're notifiable since we want to be able to switch off animations at runtime. CCMAIL:plasma-devel@kde.org --- src/declarativeimports/core/units.cpp | 14 +++++++++- src/declarativeimports/core/units.h | 27 +++++++++++++++++++ .../qml/animations/Animations.js | 4 +-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp index bb4090197..ae4c13404 100644 --- a/src/declarativeimports/core/units.cpp +++ b/src/declarativeimports/core/units.cpp @@ -33,7 +33,8 @@ Units::Units (QObject *parent) : QObject(parent), m_gridUnit(-1), - m_devicePixelRatio(-1) + m_devicePixelRatio(-1), + m_longDuration(250) { m_iconSizes = new QQmlPropertyMap(this); updateDevicePixelRatio(); @@ -163,6 +164,17 @@ void Units::updateSpacing() } } + +int Units::longDuration() const +{ + return m_longDuration; +} + +int Units::shortDuration() const +{ + return m_longDuration / 5; +} + bool Units::eventFilter(QObject *watched, QEvent *event) { if (watched == QCoreApplication::instance()) { diff --git a/src/declarativeimports/core/units.h b/src/declarativeimports/core/units.h index 5885a874c..dfe6658b4 100644 --- a/src/declarativeimports/core/units.h +++ b/src/declarativeimports/core/units.h @@ -83,6 +83,18 @@ class Units : public QObject */ Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged) + /** + * units.longDuration should be used for longer, screen-covering animations, for opening and + * closing of dialogs and other "not too small" animations + */ + Q_PROPERTY(int longDuration READ longDuration NOTIFY durationChanged) + + /** + * units.longDuration should be used for short animations, such as accentuating a UI event, + * hover events, etc.. + */ + Q_PROPERTY(int shortDuration READ shortDuration NOTIFY durationChanged) + public: Units(QObject *parent = 0); ~Units(); @@ -116,11 +128,24 @@ public: */ int largeSpacing() const; + /** + * @return Duration for long animations, in milliseconds. + * @since 5.0 + */ + int longDuration() const; + + /** + * @return Duration for short animations, in milliseconds. + * @since 5.0 + */ + int shortDuration() const; + Q_SIGNALS: void devicePixelRatioChanged(); void gridUnitChanged(); void iconSizesChanged(); void spacingChanged(); + void durationChanged(); private Q_SLOTS: void themeChanged(); @@ -144,6 +169,8 @@ private: int m_smallSpacing; int m_largeSpacing; + + int m_longDuration; }; #endif //UNITS_H diff --git a/src/declarativeimports/plasmaextracomponents/qml/animations/Animations.js b/src/declarativeimports/plasmaextracomponents/qml/animations/Animations.js index 96db3c14a..b8492f870 100644 --- a/src/declarativeimports/plasmaextracomponents/qml/animations/Animations.js +++ b/src/declarativeimports/plasmaextracomponents/qml/animations/Animations.js @@ -2,7 +2,7 @@ .pragma library // a normal animation -var normalDuration = 250; +var normalDuration = units.longDuration; // for direct feedback, such as tapping -var feedbackDuration = 50; \ No newline at end of file +var feedbackDuration = units.shortDuration; \ No newline at end of file