-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathTextField.qml
114 lines (90 loc) · 2.25 KB
/
TextField.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import QtQuick 2.3
import Pyblish 0.1
TextEdit {
property string style: "body1"
property color backgroundColor: "transparent"
property var fontStyles: {
"display4": {
"size": 112,
"font": "light"
},
"display3": {
"size": 56,
"font": "regular"
},
"display2": {
"size": 45,
"font": "regular"
},
"display1": {
"size": 34,
"font": "regular"
},
"headline": {
"size": 24,
"font": "regular"
},
"title": {
"size": 20,
"font": "medium"
},
"subheading": {
"size": 16,
"size_desktop": 15,
"font": "regular"
},
"body2": {
"size": 14,
"size_desktop": 13,
"font": "medium"
},
"body1": {
"size": 14,
"size_desktop": 13,
"font": "regular"
},
"menu": {
"size": 14,
"size_desktop": 13,
"font": "medium"
},
"button": {
"size": 14,
"font": "medium"
},
"caption": {
"size": 12,
"font": "regular"
}
}
property real sizeMult: .75
property var fontInfo: fontStyles[style]
font.pixelSize: fontInfo.size * sizeMult
font.family: mainFont.name
font.weight: {
var weight = fontInfo.font
if (weight == "medium") {
return Font.DemiBold
} else if (weight == "regular") {
return Font.Normal
} else if (weight == "light") {
return Font.Light
}
}
font.capitalization: style == "button" ? Font.AllUppercase : Font.MixedCase
color: Theme.dark.textColor
selectByMouse: true
selectionColor: Theme.alpha(color, 0.5)
selectedTextColor: Qt.darker(color, 2)
selectByMouse: true
selectByKeyboard: true
Rectangle {
id: background
color: backgroundColor
anchors.fill: parent
}
Component.onCompleted: {
if (typeof fontInfo == "undefined")
print("WARNING: style \"%1\" was not found".arg(style))
}
}