aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-06-08 23:04:06 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-06-16 08:45:42 +0000
commite96fd5f39158f775d45ae9a60564f00454b789ed (patch)
tree8de27d350b79b9190a3e3eacdc5935246ce8871a
parent513363e940e0978931083544374bfe092107b9fb (diff)
ScrollBar: fix flashing in Material & Universal styles
Ensure a suitable starting opacity for the inactive state transition. When calling increase() and decrease() from key-handlers, as the docs suggest, we flash the scrollbar by turning the active state on, and then back off immediately. If there is an opacity animation when the scrollbar becomes active (Material & Universal), the opacity animation is stopped right away, because the state changes back to inactive. This state changing trick worked only with the Default style, because it changes the opacity without animating when it becomes active. Change-Id: I4117de79c7145a710c0b6c43873ca2336b64e21e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/imports/controls/material/ScrollBar.qml1
-rw-r--r--src/imports/controls/universal/ScrollBar.qml1
-rw-r--r--tests/auto/controls/data/tst_scrollbar.qml40
3 files changed, 42 insertions, 0 deletions
diff --git a/src/imports/controls/material/ScrollBar.qml b/src/imports/controls/material/ScrollBar.qml
index 156c5781..8374c0f9 100644
--- a/src/imports/controls/material/ScrollBar.qml
+++ b/src/imports/controls/material/ScrollBar.qml
@@ -81,6 +81,7 @@ T.ScrollBar {
Transition {
from: "active"
SequentialAnimation {
+ PropertyAction{ targets: [contentItem, background]; property: "opacity"; value: 1.0 }
PauseAnimation { duration: 2450 }
NumberAnimation { targets: [contentItem, background]; property: "opacity"; to: 0.0 }
}
diff --git a/src/imports/controls/universal/ScrollBar.qml b/src/imports/controls/universal/ScrollBar.qml
index 981e382a..cbb81f1b 100644
--- a/src/imports/controls/universal/ScrollBar.qml
+++ b/src/imports/controls/universal/ScrollBar.qml
@@ -83,6 +83,7 @@ T.ScrollBar {
Transition {
from: "active"
SequentialAnimation {
+ PropertyAction{ targets: [contentItem, background]; property: "opacity"; value: 1.0 }
PauseAnimation { duration: 3000 }
NumberAnimation { targets: [contentItem, background]; property: "opacity"; to: 0.0 }
}
diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml
index 6697de88..3e153ebb 100644
--- a/tests/auto/controls/data/tst_scrollbar.qml
+++ b/tests/auto/controls/data/tst_scrollbar.qml
@@ -736,4 +736,44 @@ TestCase {
container.destroy()
}
+
+ function test_flashing() {
+ var control = createTemporaryObject(scrollBar, testCase, {size: 0.2})
+ verify(control)
+
+ var activeSpy = signalSpy.createObject(control, {target: control, signalName: "activeChanged"})
+ verify(activeSpy.valid)
+
+ compare(control.active, false)
+ if (control.contentItem)
+ compare(control.contentItem.opacity, 0)
+ if (control.background)
+ compare(control.background.opacity, 0)
+
+ control.increase()
+ compare(control.position, 0.1)
+ compare(control.active, false)
+ compare(activeSpy.count, 2)
+ if (control.contentItem)
+ verify(control.contentItem.opacity > 0)
+ if (control.background)
+ verify(control.background.opacity > 0)
+ if (control.contentItem)
+ tryCompare(control.contentItem, "opacity", 0)
+ if (control.background)
+ tryCompare(control.background, "opacity", 0)
+
+ control.decrease()
+ compare(control.position, 0.0)
+ compare(control.active, false)
+ compare(activeSpy.count, 4)
+ if (control.contentItem)
+ verify(control.contentItem.opacity > 0)
+ if (control.background)
+ verify(control.background.opacity > 0)
+ if (control.contentItem)
+ tryCompare(control.contentItem, "opacity", 0)
+ if (control.background)
+ tryCompare(control.background, "opacity", 0)
+ }
}