blob: d1ef157f8741359ae576fa88487fa3a30fa1dc39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import QtQuick
import QtQuick.Controls.Material
Rectangle {
id: cursor
color: parent.Material.accentColor
width: 2
visible: parent.activeFocus && !parent.readOnly && parent.selectionStart === parent.selectionEnd
Connections {
target: cursor.parent
function onCursorPositionChanged() {
// keep a moving cursor visible
cursor.opacity = 1
timer.restart()
}
}
Timer {
id: timer
running: cursor.parent.activeFocus && !cursor.parent.readOnly && interval != 0
repeat: true
interval: Application.styleHints.cursorFlashTime / 2
onTriggered: cursor.opacity = !cursor.opacity ? 1 : 0
// force the cursor visible when gaining focus
onRunningChanged: cursor.opacity = 1
}
}
|