68 lines
1.5 KiB
QML
68 lines
1.5 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import qs.config
|
|
import qs.custom
|
|
import qs.services
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
|
|
TextField {
|
|
id: root
|
|
|
|
color: Config.colors.secondary
|
|
placeholderTextColor: Config.colors.tertiary
|
|
font.family: Config.font.family.sans
|
|
font.pointSize: Config.font.size.smaller
|
|
renderType: TextField.NativeRendering
|
|
cursorVisible: !readOnly
|
|
|
|
background: null
|
|
|
|
cursorDelegate: CustomRect {
|
|
id: cursor
|
|
|
|
property bool disableBlink
|
|
|
|
implicitWidth: 2
|
|
color: Config.colors.primary
|
|
radius: 20
|
|
|
|
Connections {
|
|
target: root
|
|
|
|
function onCursorPositionChanged(): void {
|
|
if (root.activeFocus && root.cursorVisible) {
|
|
cursor.opacity = 1;
|
|
cursor.disableBlink = true;
|
|
enableBlink.restart();
|
|
}
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: enableBlink
|
|
|
|
interval: 100
|
|
onTriggered: cursor.disableBlink = false
|
|
}
|
|
|
|
Timer {
|
|
running: root.activeFocus && root.cursorVisible && !cursor.disableBlink
|
|
repeat: true
|
|
triggeredOnStart: true
|
|
interval: 500
|
|
onTriggered: parent.opacity = parent.opacity === 1 ? 0 : 1
|
|
}
|
|
|
|
Binding {
|
|
when: !root.activeFocus || !root.cursorVisible
|
|
cursor.opacity: 0
|
|
}
|
|
|
|
Behavior on opacity {
|
|
Anim {
|
|
duration: Config.anim.durations.small
|
|
}
|
|
}
|
|
}
|
|
}
|