aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls/material/TextArea.qml
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-25 22:17:38 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-26 17:26:59 +0000
commit57fe5822c5ed7ce77d45b7c1858585edaa83263b (patch)
treeedc3f49ea278f54fbac23a1ff683dde96af2ca1c /src/imports/controls/material/TextArea.qml
parent3070c078923c90a3ebcbbe9cbaf2063231e4e4b9 (diff)
Update Material editors
- hide the cursor and stop the timer when the editor doesn't have active focus - bring the cursor visible when gaining focus, and keep it visible while it's being moved - make use of QStyleHints::cursorFlashTime() - fix background positioning - set selection color to avoid the default blue Change-Id: I588f1f1cceaa2a6c9930cbdb1f0d1680117e0eef Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/imports/controls/material/TextArea.qml')
-rw-r--r--src/imports/controls/material/TextArea.qml26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/imports/controls/material/TextArea.qml b/src/imports/controls/material/TextArea.qml
index 4f5c7491..a5423727 100644
--- a/src/imports/controls/material/TextArea.qml
+++ b/src/imports/controls/material/TextArea.qml
@@ -51,17 +51,31 @@ T.TextArea {
padding: 6
color: enabled ? Material.primaryTextColor : Material.hintTextColor
-// selectionColor: Theme.selectionColor
-// selectedTextColor: Theme.selectedTextColor
+ selectionColor: Material.accentColor
+ selectedTextColor: Material.primaryHighlightedTextColor
cursorDelegate: Rectangle {
+ id: cursor
color: control.Material.accentColor
width: 2
+ visible: control.activeFocus && control.selectionStart === control.selectionEnd
+
+ Connections {
+ target: control
+ onCursorPositionChanged: {
+ // keep a moving cursor visible
+ cursor.opacity = 1
+ timer.restart()
+ }
+ }
Timer {
- running: true
+ id: timer
+ running: control.activeFocus
repeat: true
- interval: 500
- onTriggered: parent.visible = !parent.visible
+ interval: Qt.styleHints.cursorFlashTime
+ onTriggered: cursor.opacity = !cursor.opacity ? 1 : 0
+ // force the cursor visible when gaining focus
+ onRunningChanged: cursor.opacity = 1
}
}
@@ -84,7 +98,7 @@ T.TextArea {
//! [background]
background: Rectangle {
- y: control.y + control.height - height
+ y: control.height - height
implicitWidth: 120
height: control.activeFocus ? 2 : 1
color: control.activeFocus ? control.Material.accentColor : control.Material.hintTextColor