forked from linuxdeepin/deepin-fcitx5configtool-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboardLayout.qml
More file actions
175 lines (163 loc) · 6.4 KB
/
KeyboardLayout.qml
File metadata and controls
175 lines (163 loc) · 6.4 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls 2.3
import QtQuick.Layouts
import org.deepin.dcc 1.0
import org.deepin.dtk 1.0 as D
DccObject {
// 键盘布局列表抬头
DccObject {
id: keyboardLayoutTitle
property bool isEditing: false
name: "KeyboardLayoutTitle"
parentName: "KeyboardLayout"
displayName: qsTr("Keyboard layout")
weight: 10
pageType: DccObject.Item
page: RowLayout {
DccTitle {
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
Layout.leftMargin: 10
text: dccObj.displayName
}
D.Button {
id: button
checkable: true
visible: dccData.layoutCount > 1
checked: keyboardLayoutTitle.isEditing
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.rightMargin: 10
text: keyboardLayoutTitle.isEditing ? qsTr("done") : qsTr("edit")
font: D.DTK.fontManager.t8
background: null
textColor: D.Palette {
normal {
common: D.DTK.makeColor(D.Color.Highlight)
crystal: D.DTK.makeColor(D.Color.Highlight)
}
}
onCheckedChanged: {
keyboardLayoutTitle.isEditing = button.checked
}
}
}
}
DccObject {
name: "KeyboardLayoutTips"
parentName: "KeyboardLayout"
weight: 12
pageType: DccObject.Item
page: D.Label {
textFormat: Text.RichText
text: qsTr("Add the corresponding input method in <a style='text-decoration: none;' href='Manage Input Methods'>Input Method Management</a> to ensure the keyboard layout works when added or switched.")
leftPadding: 10
rightPadding: 10
wrapMode: Text.WordWrap
onLinkActivated: link => DccApp.showPage(link)
}
}
DccObject {
name: "KeyboardLayoutGroup"
parentName: "KeyboardLayout"
weight: 20
pageType: DccObject.Item
page: DccGroupView {}
DccRepeater {
model: dccData.layoutCount
delegate: DccObject {
name: "KeyboardLayoutItem" + index
parentName: "KeyboardLayoutGroup"
weight: 10 + index * 2
pageType: DccObject.Item
backgroundType: DccObject.Normal
page: ItemDelegate {
id: itemDelegate
property bool isCurrentLang: dccData.currentLayout === dccData.userLayoutAt(index, true)
visible: dccObj
hoverEnabled: true
implicitHeight: 40
// icon.name: dccObj.icon
checkable: false
Label {
id: itemName
text: dccData.userLayoutAt(index, true)
elide: Text.ElideRight
anchors {
left: itemDelegate.left
leftMargin: 10
top: itemDelegate.top
topMargin: (itemDelegate.height - itemName.height) / 2
}
}
D.IconButton {
id: removeButton
visible: itemDelegate.isCurrentLang || keyboardLayoutTitle.isEditing
icon.name: itemDelegate.isCurrentLang ? "item_checked" : "list_delete"
icon.width: 16
icon.height: 16
implicitWidth: 16
implicitHeight: 16
anchors {
right: itemDelegate.right
rightMargin: 10
top: itemDelegate.top
topMargin: (itemDelegate.height - removeButton.height) / 2
}
background: null
onClicked: {
if (!keyboardLayoutTitle.isEditing || itemDelegate.isCurrentLang)
return
dccData.deleteUserLayout(itemName.text)
}
}
background: DccItemBackground {
separatorVisible: true
}
onClicked: {
if (keyboardLayoutTitle.isEditing)
return
// console.log("set current layout", itemName.text, dccData.userLayoutAt(index, false))
dccData.currentLayout = dccData.userLayoutAt(index, false)
}
}
}
}
DccObject {
name: "KeyboardLayoutLastItem"
parentName: "KeyboardLayoutGroup"
displayName: qsTr("Add new keyboard layout...")
weight: 999
pageType: DccObject.Item
backgroundType: DccObject.Normal
page: Item {
implicitHeight: 40
D.Button {
id: addButton
implicitHeight: 40
text: dccObj.displayName
background: null
textColor: D.Palette {
normal {
common: D.DTK.makeColor(D.Color.Highlight)
crystal: D.DTK.makeColor(D.Color.Highlight)
}
}
font.pixelSize: D.DTK.fontManager.t8.pixelSize
LayoutsChooser {
id: layoutsChooser
viewModel: dccData.layoutSearchModel()
onSelected: function (data) {
// console.log("selected data...", data)
dccData.addUserLayout(data)
}
}
onClicked: {
keyboardLayoutTitle.isEditing = false
layoutsChooser.active = true
}
}
}
}
}
}