-
Notifications
You must be signed in to change notification settings - Fork 3
/
TextAlign.qml
57 lines (47 loc) · 1.42 KB
/
TextAlign.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
// Version 4
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
RowLayout {
id: configTextAlign
property string configKey: ''
readonly property string configValue: configKey ? plasmoid.configuration[configKey] : ""
function setValue(val) {
if (configKey) {
plasmoid.configuration[configKey] = val
}
updateChecked()
}
function updateChecked() {
// button.checked bindings are unbound when clicked
justifyLeftButton.checked = Qt.binding(function(){ return configValue == Text.AlignLeft })
justifyCenterButton.checked = Qt.binding(function(){ return configValue == Text.AlignHCenter })
justifyRightButton.checked = Qt.binding(function(){ return configValue == Text.AlignRight })
justifyFillButton.checked = Qt.binding(function(){ return configValue == Text.AlignJustify })
}
Component.onCompleted: updateChecked()
QQC2.Button {
id: justifyLeftButton
icon.name: "format-justify-left-symbolic"
checkable: true
onClicked: setValue(Text.AlignLeft)
}
QQC2.Button {
id: justifyCenterButton
icon.name: "format-justify-center-symbolic"
checkable: true
onClicked: setValue(Text.AlignHCenter)
}
QQC2.Button {
id: justifyRightButton
icon.name: "format-justify-right-symbolic"
checkable: true
onClicked: setValue(Text.AlignRight)
}
QQC2.Button {
id: justifyFillButton
icon.name: "format-justify-fill-symbolic"
checkable: true
onClicked: setValue(Text.AlignJustify)
}
}