aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-07-11 14:47:28 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-07-13 18:57:46 +0000
commit95f05dffe2c6a88acd7501341c6b909f5d6a54c2 (patch)
tree6d4f3313bbb72345be78998510b53741331d5db2 /src/imports
parentf4a42a914ce2718259e683f860a86449d4aaff83 (diff)
Material: trigger ripple effects on release for some controls
Android 5 used to trigger ripple effects on press, but Android 6 made ripple effects a bit more subtle. For check boxes, radio buttons, and switches it still triggers on press, but these controls where the wave is larger, it's triggered on release instead. Change-Id: Ib4d301d5ccf72d5db106bcc6ad6afee30cef0b1e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/controls/material/Button.qml1
-rw-r--r--src/imports/controls/material/CheckDelegate.qml1
-rw-r--r--src/imports/controls/material/ItemDelegate.qml1
-rw-r--r--src/imports/controls/material/MenuItem.qml1
-rw-r--r--src/imports/controls/material/RadioDelegate.qml1
-rw-r--r--src/imports/controls/material/SwitchDelegate.qml1
-rw-r--r--src/imports/controls/material/qquickmaterialripple.cpp27
-rw-r--r--src/imports/controls/material/qquickmaterialripple_p.h8
8 files changed, 36 insertions, 5 deletions
diff --git a/src/imports/controls/material/Button.qml b/src/imports/controls/material/Button.qml
index ae98853a..dd4d614e 100644
--- a/src/imports/controls/material/Button.qml
+++ b/src/imports/controls/material/Button.qml
@@ -107,6 +107,7 @@ T.Button {
clipRadius: 2
width: parent.width
height: parent.height
+ trigger: Ripple.Release
pressed: control.pressed
anchor: control
active: control.down || control.visualFocus || control.hovered
diff --git a/src/imports/controls/material/CheckDelegate.qml b/src/imports/controls/material/CheckDelegate.qml
index 0092f174..099c851b 100644
--- a/src/imports/controls/material/CheckDelegate.qml
+++ b/src/imports/controls/material/CheckDelegate.qml
@@ -83,6 +83,7 @@ T.CheckDelegate {
height: parent.height
clip: visible
+ trigger: Ripple.Release
pressed: control.pressed
anchor: control
active: control.down || control.visualFocus || control.hovered
diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml
index a493ecbd..79aa60ea 100644
--- a/src/imports/controls/material/ItemDelegate.qml
+++ b/src/imports/controls/material/ItemDelegate.qml
@@ -75,6 +75,7 @@ T.ItemDelegate {
height: parent.height
clip: visible
+ trigger: Ripple.Release
pressed: control.pressed
anchor: control
active: control.down || control.visualFocus || control.hovered
diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml
index 4f221f2c..63379e84 100644
--- a/src/imports/controls/material/MenuItem.qml
+++ b/src/imports/controls/material/MenuItem.qml
@@ -84,6 +84,7 @@ T.MenuItem {
height: parent.height
clip: visible
+ trigger: Ripple.Release
pressed: control.pressed
anchor: control
active: control.down || control.visualFocus || control.hovered
diff --git a/src/imports/controls/material/RadioDelegate.qml b/src/imports/controls/material/RadioDelegate.qml
index 918f9a37..5c943a7f 100644
--- a/src/imports/controls/material/RadioDelegate.qml
+++ b/src/imports/controls/material/RadioDelegate.qml
@@ -83,6 +83,7 @@ T.RadioDelegate {
height: parent.height
clip: visible
+ trigger: Ripple.Release
pressed: control.pressed
anchor: control
active: control.down || control.visualFocus || control.hovered
diff --git a/src/imports/controls/material/SwitchDelegate.qml b/src/imports/controls/material/SwitchDelegate.qml
index 7b81524c..31cd4660 100644
--- a/src/imports/controls/material/SwitchDelegate.qml
+++ b/src/imports/controls/material/SwitchDelegate.qml
@@ -83,6 +83,7 @@ T.SwitchDelegate {
height: parent.height
clip: visible
+ trigger: Ripple.Release
pressed: control.pressed
anchor: control
active: control.down || control.visualFocus || control.hovered
diff --git a/src/imports/controls/material/qquickmaterialripple.cpp b/src/imports/controls/material/qquickmaterialripple.cpp
index efe022f4..2cb80f1b 100644
--- a/src/imports/controls/material/qquickmaterialripple.cpp
+++ b/src/imports/controls/material/qquickmaterialripple.cpp
@@ -202,7 +202,7 @@ QQuickAnimatorJob *QQuickMaterialRippleAnimator::createJob() const
}
QQuickMaterialRipple::QQuickMaterialRipple(QQuickItem *parent)
- : QQuickItem(parent), m_active(false), m_pressed(false), m_enterDelay(0), m_clipRadius(0.0), m_anchor(nullptr), m_opacityAnimator(nullptr)
+ : QQuickItem(parent), m_active(false), m_pressed(false), m_enterDelay(0), m_trigger(Press), m_clipRadius(0.0), m_anchor(nullptr), m_opacityAnimator(nullptr)
{
setOpacity(0.0);
setFlag(ItemHasContents);
@@ -275,10 +275,27 @@ void QQuickMaterialRipple::setPressed(bool pressed)
m_pressed = pressed;
- if (pressed)
- prepareWave();
- else
- exitWave();
+ if (pressed) {
+ if (m_trigger == Press)
+ prepareWave();
+ else
+ exitWave();
+ } else {
+ if (m_trigger == Release)
+ enterWave();
+ else
+ exitWave();
+ }
+}
+
+QQuickMaterialRipple::Trigger QQuickMaterialRipple::trigger() const
+{
+ return m_trigger;
+}
+
+void QQuickMaterialRipple::setTrigger(Trigger trigger)
+{
+ m_trigger = trigger;
}
QPointF QQuickMaterialRipple::anchorPoint() const
diff --git a/src/imports/controls/material/qquickmaterialripple_p.h b/src/imports/controls/material/qquickmaterialripple_p.h
index 80a562cf..a1cfed94 100644
--- a/src/imports/controls/material/qquickmaterialripple_p.h
+++ b/src/imports/controls/material/qquickmaterialripple_p.h
@@ -63,6 +63,7 @@ class QQuickMaterialRipple : public QQuickItem
Q_PROPERTY(bool pressed READ isPressed WRITE setPressed FINAL)
Q_PROPERTY(bool active READ isActive WRITE setActive FINAL)
Q_PROPERTY(QQuickItem *anchor READ anchor WRITE setAnchor FINAL)
+ Q_PROPERTY(Trigger trigger READ trigger WRITE setTrigger FINAL)
public:
QQuickMaterialRipple(QQuickItem *parent = nullptr);
@@ -79,6 +80,12 @@ public:
bool isPressed() const;
void setPressed(bool pressed);
+ enum Trigger { Press, Release };
+ Q_ENUM (Trigger)
+
+ Trigger trigger() const;
+ void setTrigger(Trigger trigger);
+
QPointF anchorPoint() const;
QQuickItem *anchor() const;
@@ -97,6 +104,7 @@ private:
bool m_active;
bool m_pressed;
int m_enterDelay;
+ Trigger m_trigger;
qreal m_clipRadius;
QColor m_color;
QQuickItem *m_anchor;