-
Notifications
You must be signed in to change notification settings - Fork 5
/
MaterialTextbox.qml
96 lines (88 loc) · 2.32 KB
/
MaterialTextbox.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import QtQuick 2.7
import QtGraphicalEffects 1.0
import SddmComponents 2.0
import QtQuick.Controls 2.0
TextField {
clip: true
color: config.accent2
font.family: config.font
font.pointSize: 15
selectByMouse: true
selectionColor: "#a8d6ec"
verticalAlignment: TextInput.AlignVCenter
leftPadding: 2
bottomPadding: 15
cursorDelegate: Item {
id: root
property Item input: parent
width: 3
height: input.cursorRectangle.height
visible: input.activeFocus && input.selectionStart === input.selectionEnd
Rectangle {
width: 2
height: parent.height + 3
radius: width
color: config.accent2
}
Rectangle {
id: handle
x: -width/2 + parent.width/2
width: 2
height: width
radius: width
color: config.accent2
anchors.top: parent.bottom
}
MouseArea {
drag {
target: root
minimumX: 0
minimumY: 0
maximumX: input.width
maximumY: input.height - root.height
}
width: handle.width * 2
height: parent.height + handle.height
x: -width/2
onReleased: {
var pos = mapToItem(input, mouse.x, mouse.y);
input.cursorPosition = input.positionAt(pos.x, pos.y);
}
}
}
background: Item {
implicitHeight: 40
Rectangle {
id: back
anchors.fill: parent
anchors.bottomMargin: 5
opacity: 0
}
Rectangle {
id: tborder
anchors.bottom: back.bottom
width: parent.width
height: 1
color: "#000000"
}
Rectangle {
id: borderactive
anchors.bottom: back.bottom
width: 0
height: 2
color: config.accent2
}
}
onFocusChanged: {
if (focus) {
color = config.accent2
borderactive.width = tborder.width
cursorVisible = true
} else {
color = "#888888"
border.color = "#000000"
borderactive.width = 0
cursorVisible = false
}
}
}