-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathEditableLabel.qml
46 lines (45 loc) · 1.2 KB
/
EditableLabel.qml
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
TextField {
signal edited(string text, bool activeFocus)
id: self
color: 'white'
focus: false
readOnly: !self.enabled
activeFocusOnPress: true
autoScroll: activeFocus
background: Rectangle {
color: 'transparent'
border.width: 1
border.color: 'white'
radius: 4
visible: !self.readOnly
opacity: (self.activeFocus ? 0.4 : 0) + (self.hovered ? 0.1 : 0)
Behavior on opacity {
SequentialAnimation {
PauseAnimation {
duration: 300
}
SmoothedAnimation {
velocity: 1
}
}
}
}
bottomPadding: topPadding
cursorPosition: 0
selectByMouse: activeFocus
maximumLength: 50
onTextChanged: {
self.edited(text, self.activeFocus)
if (!self.activeFocus) self.ensureVisible(0)
}
onActiveFocusChanged: {
self.edited(self.text, activeFocus)
if (!activeFocus) self.ensureVisible(0)
}
ToolTip.text: self.text
ToolTip.visible: contentWidth > availableWidth && hovered
ToolTip.delay: 1000
}