[plasma-framework] src/declarativeimports: units.longDuration and units.shortDuration properties
Sebastian Kügler
sebas at kde.org
Mon Feb 3 15:53:34 UTC 2014
Git commit 30e98ba8f7646fcceaf85cc808e05fcc88b66442 by Sebastian Kügler.
Committed on 03/02/2014 at 15:30.
Pushed by sebas into branch 'master'.
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 at kde.org
M +13 -1 src/declarativeimports/core/units.cpp
M +27 -0 src/declarativeimports/core/units.h
M +2 -2 src/declarativeimports/plasmaextracomponents/qml/animations/Animations.js
http://commits.kde.org/plasma-framework/30e98ba8f7646fcceaf85cc808e05fcc88b66442
diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp
index bb40901..ae4c134 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 5885a87..dfe6658 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 96db3c1..b8492f8 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
More information about the Plasma-devel
mailing list