Revision control

Copy as Markdown

// 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
// Qt-Security score:significant reason:default
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
}
}