Changeset View
Changeset View
Standalone View
Standalone View
kcms/keyboard/kcmui/package/contents/ui/FcitxIMConfig.qml
- This file was added.
1 | import QtQuick 2.9 | ||||
---|---|---|---|---|---|
2 | import QtQuick.Layouts 1.3 | ||||
3 | import QtQuick.Controls 2.3 as Controls | ||||
4 | import org.kde.kirigami 2.4 as Kirigami | ||||
5 | | ||||
6 | Controls.Dialog { | ||||
7 | header: Kirigami.Heading { text: i18n("IM Config") } | ||||
8 | id: root | ||||
9 | property var configModel; | ||||
10 | | ||||
11 | function openForModel(model) { | ||||
12 | configModel = model; | ||||
13 | open(); | ||||
14 | } | ||||
15 | | ||||
16 | ColumnLayout { | ||||
17 | anchors.fill: parent | ||||
18 | | ||||
19 | ColumnLayout { | ||||
20 | id: header | ||||
21 | visible: false | ||||
22 | Layout.fillHeight: true | ||||
23 | | ||||
24 | Connections { | ||||
25 | target: root | ||||
26 | onOpened: { | ||||
27 | if (configModel.isRealIM) { | ||||
28 | header.visible = true; | ||||
29 | | ||||
30 | latinCheckbox.checked = configModel.isLatinSwitchingEnabled | ||||
31 | latinLayoutList.model = configModel.latinModeLayoutList | ||||
32 | latinLayoutList.currentIndex = configModel.selectedLatinLayoutIndex | ||||
33 | } | ||||
34 | else { | ||||
35 | header.visible = false; | ||||
36 | } | ||||
37 | } | ||||
38 | } | ||||
39 | | ||||
40 | Controls.CheckBox { | ||||
41 | id: latinCheckbox | ||||
42 | text: i18n("Enable Switching to Latin") | ||||
43 | onCheckedChanged: configModel.isLatinSwitchingEnabled = checked; | ||||
44 | } | ||||
45 | | ||||
46 | Controls.ComboBox { | ||||
47 | enabled: latinCheckbox.checked | ||||
48 | id: latinLayoutList | ||||
49 | textRole: "description" | ||||
50 | Layout.minimumWidth: 500 | ||||
51 | onActivated: configModel.selectedLatinLayoutIndex = currentIndex | ||||
52 | } | ||||
53 | } | ||||
54 | | ||||
55 | ListView { | ||||
56 | id: configList; | ||||
57 | model: configModel | ||||
58 | | ||||
59 | width: parent.width | ||||
60 | Layout.fillHeight: true | ||||
61 | | ||||
62 | clip: true | ||||
63 | | ||||
64 | Component { | ||||
65 | id: sectionHeading | ||||
66 | Rectangle { | ||||
67 | width: parent.width | ||||
68 | height: childrenRect.height | ||||
69 | color: "transparent" | ||||
70 | | ||||
71 | Text { | ||||
72 | text: section | ||||
73 | font.bold: true | ||||
74 | font.pixelSize: 20 | ||||
75 | } | ||||
76 | } | ||||
77 | } | ||||
78 | | ||||
79 | section.property: "group" | ||||
80 | section.delegate: sectionHeading | ||||
81 | | ||||
82 | delegate: RowLayout { | ||||
83 | id: itemDelegate | ||||
84 | property var model_: model; | ||||
85 | height: 40 | ||||
86 | spacing: 10 | ||||
87 | | ||||
88 | Controls.Label { | ||||
89 | Layout.minimumWidth: 300 | ||||
90 | Layout.fillHeight: true | ||||
91 | verticalAlignment: Text.AlignVCenter | ||||
92 | horizontalAlignment: Text.AlignRight | ||||
93 | text: model.description; | ||||
94 | } | ||||
95 | | ||||
96 | Component.onCompleted: { | ||||
97 | switch (model.type) { | ||||
98 | case "EnumType": | ||||
99 | Qt.createQmlObject( | ||||
100 | "import QtQuick 2.9; | ||||
101 | import QtQuick.Controls 2.3 as Controls; | ||||
102 | Controls.ComboBox { | ||||
103 | model: model_.data; | ||||
104 | currentIndex: model_.data.indexOf(model_.current_value); | ||||
105 | onActivated: model_.current_value = currentText; | ||||
106 | }", itemDelegate, "dynamicSnippet1"); | ||||
107 | break; | ||||
108 | case "BooleanType": | ||||
109 | Qt.createQmlObject( | ||||
110 | "import QtQuick 2.9; | ||||
111 | import QtQuick.Controls 2.3 as Controls; | ||||
112 | Controls.CheckBox { | ||||
113 | checked: model_.current_value | ||||
114 | onCheckedChanged: model_.current_value = checked; | ||||
115 | }", itemDelegate, "dynamicSnippet2"); | ||||
116 | break; | ||||
117 | case "HotkeyType": | ||||
118 | Qt.createQmlObject( | ||||
119 | "import QtQuick 2.9; | ||||
120 | import org.kde.kquickcontrols 2.0 as KQuickControls; | ||||
121 | KQuickControls.KeySequenceItem { | ||||
122 | keySequence: model_.current_value | ||||
123 | onKeySequenceChanged: model_.current_value = keySequence; | ||||
124 | }", itemDelegate, "dynamicSnippet3"); | ||||
125 | break; | ||||
126 | case "IntegerType": | ||||
127 | Qt.createQmlObject( | ||||
128 | "import QtQuick 2.9; | ||||
129 | import QtQuick.Controls 2.3 as Controls; | ||||
130 | Controls.TextField { | ||||
131 | text: model_.current_value; | ||||
132 | onTextChanged: model_.current_value = text; | ||||
133 | }", itemDelegate, "dynamicSnippet4"); | ||||
134 | break; | ||||
135 | case "StringType": | ||||
136 | case "CharType": | ||||
137 | Qt.createQmlObject( | ||||
138 | "import QtQuick 2.9; | ||||
139 | import QtQuick.Controls 2.3 as Controls; | ||||
140 | Controls.TextField { | ||||
141 | text: model_.current_value; | ||||
142 | onTextChanged: model_.current_value = text; | ||||
143 | }", itemDelegate, "dynamicSnippet4"); | ||||
144 | break; | ||||
145 | } | ||||
146 | } | ||||
147 | } | ||||
148 | } | ||||
149 | } | ||||
150 | | ||||
151 | footer: RowLayout { | ||||
152 | Controls.Button { | ||||
153 | text: i18n("Save"); | ||||
154 | onClicked: { | ||||
155 | configList.model.save(); | ||||
156 | close(); | ||||
157 | } | ||||
158 | } | ||||
159 | Controls.Button { | ||||
160 | text: i18n("Discard"); | ||||
161 | onClicked: { | ||||
162 | close(); | ||||
163 | } | ||||
164 | } | ||||
165 | } | ||||
166 | } |