Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/package/contents/ui/ConfigEntries.qml
Show All 30 Lines | 30 | ColumnLayout { | |||
---|---|---|---|---|---|
31 | id: iconsPage | 31 | id: iconsPage | ||
32 | 32 | | |||
33 | signal configurationChanged | 33 | signal configurationChanged | ||
34 | 34 | | |||
35 | property var cfg_shownItems: [] | 35 | property var cfg_shownItems: [] | ||
36 | property var cfg_hiddenItems: [] | 36 | property var cfg_hiddenItems: [] | ||
37 | property alias cfg_showAllItems: showAllCheckBox.checked | 37 | property alias cfg_showAllItems: showAllCheckBox.checked | ||
38 | 38 | | |||
39 | function saveConfig () { | | |||
40 | for (var i in tableView.model) { | | |||
41 | //tableView.model[i].applet.globalShortcut = tableView.model[i].shortcut | | |||
42 | } | | |||
43 | } | | |||
44 | | ||||
45 | PlasmaCore.DataSource { | | |||
46 | id: statusNotifierSource | | |||
47 | engine: "statusnotifieritem" | | |||
48 | interval: 0 | | |||
49 | onSourceAdded: { | | |||
50 | connectSource(source) | | |||
51 | } | | |||
52 | Component.onCompleted: { | | |||
53 | connectedSources = sources | | |||
54 | } | | |||
55 | } | | |||
56 | | ||||
57 | PlasmaCore.SortFilterModel { | 39 | PlasmaCore.SortFilterModel { | ||
58 | id: statusNotifierModel | 40 | id: systemTrayModel | ||
59 | sourceModel: PlasmaCore.DataModel { | 41 | sourceModel: plasmoid.nativeInterface.systemTrayModel | ||
60 | dataSource: statusNotifierSource | | |||
61 | } | | |||
62 | } | 42 | } | ||
63 | 43 | | |||
64 | | ||||
65 | Kirigami.FormLayout { | 44 | Kirigami.FormLayout { | ||
66 | 45 | | |||
67 | QQC2.CheckBox { | 46 | QQC2.CheckBox { | ||
68 | id: showAllCheckBox | 47 | id: showAllCheckBox | ||
69 | text: i18n("Always show all entries") | 48 | text: i18n("Always show all entries") | ||
70 | } | 49 | } | ||
71 | 50 | | |||
72 | QQC2.Button { // just for measurement | 51 | QQC2.Button { // just for measurement | ||
73 | id: measureButton | 52 | id: measureButton | ||
74 | text: "measureButton" | 53 | text: "measureButton" | ||
75 | visible: false | 54 | visible: false | ||
76 | } | 55 | } | ||
77 | 56 | | |||
78 | // resizeToContents does not take into account the heading | 57 | // resizeToContents does not take into account the heading | ||
79 | QQC2.Label { | 58 | QQC2.Label { | ||
80 | id: shortcutColumnMeasureLabel | 59 | id: shortcutColumnMeasureLabel | ||
81 | text: shortcutColumn.title | 60 | text: shortcutColumn.title | ||
82 | visible: false | 61 | visible: false | ||
83 | } | 62 | } | ||
84 | } | 63 | } | ||
85 | 64 | | |||
86 | 65 | // convert to QtObjects compatible with TableView | |||
87 | function retrieveAllItems() { | 66 | function retrieveAllItems() { | ||
88 | var list = []; | 67 | var list = []; | ||
89 | for (var i = 0; i < statusNotifierModel.count; ++i) { | 68 | for (var i = 0; i < systemTrayModel.count; i++) { | ||
90 | var item = statusNotifierModel.get(i); | 69 | var item = systemTrayModel.get(i); | ||
91 | list.push({ | 70 | if (item.itemType === "Plasmoid" && !item.hasApplet) { | ||
92 | "index": i, | 71 | continue; | ||
93 | "taskId": item.Id, | | |||
94 | "name": item.Title, | | |||
95 | "iconName": item.IconName, | | |||
96 | "icon": item.Icon | | |||
97 | }); | | |||
98 | } | 72 | } | ||
nicolasfella: You can try doing
```
for (item of systemTrayModel) {
]
```
But I don't know if that will work | |||||
Unfortunately model is not iterable. This code will be removed in D22176 anyway. kmaterka: Unfortunately model is not iterable. This code will be removed in D22176 anyway. | |||||
99 | var lastIndex = list.length; | | |||
100 | for (var i = 0; i < plasmoid.applets.length; ++i) { | | |||
101 | var item = plasmoid.applets[i] | | |||
102 | list.push({ | 73 | list.push({ | ||
103 | "index": (i + lastIndex), | 74 | "taskId": item.itemId, | ||
104 | "applet": item, | 75 | "name": item.display, | ||
105 | "taskId": item.pluginName, | 76 | "icon": item.decoration, | ||
106 | "name": item.title, | 77 | "applet": item.applet | ||
107 | "iconName": item.icon, | | |||
108 | "shortcut": item.globalShortcut | | |||
109 | }); | 78 | }); | ||
110 | } | 79 | } | ||
111 | list.sort(function(a, b) { | 80 | list.sort(function(a, b) { | ||
112 | return a.name.localeCompare(b.name); | 81 | return a.name.localeCompare(b.name); | ||
113 | }); | 82 | }); | ||
114 | return list; | 83 | return list; | ||
115 | } | 84 | } | ||
116 | 85 | | |||
Show All 32 Lines | 117 | delegate: RowLayout { | |||
149 | Item { // spacer | 118 | Item { // spacer | ||
150 | Layout.preferredWidth: 1 | 119 | Layout.preferredWidth: 1 | ||
151 | Layout.fillHeight: true | 120 | Layout.fillHeight: true | ||
152 | } | 121 | } | ||
153 | 122 | | |||
154 | QIconItem { | 123 | QIconItem { | ||
155 | width: units.iconSizes.small | 124 | width: units.iconSizes.small | ||
156 | height: width | 125 | height: width | ||
157 | icon: modelData.iconName || modelData.icon || "" | 126 | icon: modelData.icon | ||
158 | } | 127 | } | ||
159 | 128 | | |||
160 | QQC2.Label { | 129 | QQC2.Label { | ||
161 | Layout.fillWidth: true | 130 | Layout.fillWidth: true | ||
162 | text: modelData.name | 131 | text: modelData.name | ||
163 | elide: Text.ElideRight | 132 | elide: Text.ElideRight | ||
164 | wrapMode: Text.NoWrap | 133 | wrapMode: Text.NoWrap | ||
165 | } | 134 | } | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 198 | QQC1.TableViewColumn { | |||
236 | delegate: Item { | 205 | delegate: Item { | ||
237 | implicitWidth: Math.max(shortcutColumnMeasureLabel.width, keySequenceItem.width) + 10 | 206 | implicitWidth: Math.max(shortcutColumnMeasureLabel.width, keySequenceItem.width) + 10 | ||
238 | height: keySequenceItem.height | 207 | height: keySequenceItem.height | ||
239 | 208 | | |||
240 | KQC.KeySequenceItem { | 209 | KQC.KeySequenceItem { | ||
241 | id: keySequenceItem | 210 | id: keySequenceItem | ||
242 | anchors.right: parent.right | 211 | anchors.right: parent.right | ||
243 | 212 | | |||
244 | keySequence: modelData.shortcut | 213 | keySequence: modelData.applet ? modelData.applet.globalShortcut : "" | ||
245 | // only Plasmoids have that | 214 | // only Plasmoids have that | ||
246 | visible: modelData.hasOwnProperty("shortcut") | 215 | visible: modelData.hasOwnProperty("applet") | ||
247 | onKeySequenceChanged: { | 216 | onKeySequenceChanged: { | ||
248 | if (keySequence !== modelData.shortcut) { | 217 | if (modelData.applet && keySequence !== modelData.applet.globalShortcut) { | ||
249 | // both SNIs and plasmoids are listed in the same TableView | 218 | modelData.applet.globalShortcut = keySequence | ||
250 | // but they come from two separate models, so we need to subtract | | |||
251 | // the SNI model count to get the actual plasmoid index | | |||
252 | var index = modelData.index - statusNotifierModel.count | | |||
253 | plasmoid.applets[index].globalShortcut = keySequence | | |||
254 | 219 | | |||
255 | iconsPage.configurationChanged() | 220 | iconsPage.configurationChanged() | ||
256 | } | 221 | } | ||
257 | 222 | | |||
258 | shortcutColumn.resizeToContents() | 223 | shortcutColumn.resizeToContents() | ||
259 | } | 224 | } | ||
260 | } | 225 | } | ||
261 | } | 226 | } | ||
262 | } | 227 | } | ||
263 | } | 228 | } | ||
264 | } | 229 | } |
You can try doing
But I don't know if that will work