aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Krupenko <krnekit@gmail.com>2016-04-12 19:15:10 +0300
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-04-13 11:05:30 +0000
commit3d149697a002cbc608cc7b9242bc6d6589ae8181 (patch)
treef4c11cbe62aa0f7b8e1aea1c3d8b00d6a55d971a
parentcba5dbf87d3e8e91b142d4d3f3b14b3791104e42 (diff)
Material: use theme cursor in SpinBox
Change-Id: I35c3a15d17a15945ccbfa5eeb4359c7c5be3facf Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--src/imports/controls/material/SpinBox.qml25
-rw-r--r--tests/auto/sanity/BLACKLIST2
2 files changed, 27 insertions, 0 deletions
diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml
index 5d2044e6..0c9fe767 100644
--- a/src/imports/controls/material/SpinBox.qml
+++ b/src/imports/controls/material/SpinBox.qml
@@ -74,6 +74,31 @@ T.SpinBox {
selectedTextColor: control.Material.primaryTextColor
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
+ cursorDelegate: Rectangle {
+ id: cursor
+ color: control.Material.accentColor
+ width: 2
+ visible: control.activeFocus && contentItem.selectionStart === contentItem.selectionEnd
+
+ Connections {
+ target: contentItem
+ onCursorPositionChanged: {
+ // keep a moving cursor visible
+ cursor.opacity = 1
+ timer.restart()
+ }
+ }
+
+ Timer {
+ id: timer
+ running: control.activeFocus
+ repeat: true
+ interval: Qt.styleHints.cursorFlashTime
+ onTriggered: cursor.opacity = !cursor.opacity ? 1 : 0
+ // force the cursor visible when gaining focus
+ onRunningChanged: cursor.opacity = 1
+ }
+ }
validator: control.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST
index 5a000c5c..ffff0c96 100644
--- a/tests/auto/sanity/BLACKLIST
+++ b/tests/auto/sanity/BLACKLIST
@@ -1,3 +1,5 @@
+[signalHandlers:material/SpinBox.qml]
+*
[signalHandlers:material/TextArea.qml]
*
[signalHandlers:material/TextField.qml]