aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
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 /src/imports
parentcba5dbf87d3e8e91b142d4d3f3b14b3791104e42 (diff)
Material: use theme cursor in SpinBox
Change-Id: I35c3a15d17a15945ccbfa5eeb4359c7c5be3facf Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/controls/material/SpinBox.qml25
1 files changed, 25 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