Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/package/contents/ui/ConfigGeneral.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2013 Sebastian Kügler <sebas@kde.org> | 2 | * Copyright 2013 Sebastian Kügler <sebas@kde.org> | ||
3 | * Copyright 2014 Marco Martin <mart@kde.org> | 3 | * Copyright 2014 Marco Martin <mart@kde.org> | ||
4 | * Copyright 2019 ivan tkachenko <ratijastk@kde.org> | ||||
5 | * Copyright 2019 Nicolas Fella <nicolas.fella@gmx.de> | ||||
4 | * | 6 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | 9 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | 10 | * (at your option) any later version. | ||
9 | * | 11 | * | ||
10 | * This program is distributed in the hope that it will be useful, | 12 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
14 | * | 16 | * | ||
15 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | 18 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||
18 | */ | 20 | */ | ||
19 | 21 | | |||
20 | import QtQuick 2.0 | 22 | import QtQuick 2.5 | ||
21 | import QtQuick.Controls 2.3 as QtControls | 23 | import QtQuick.Controls 1.4 as QQC1 | ||
ngraham: there are no longer any QQC1 items here; you can remove this import entirely | |||||
22 | import QtQuick.Layouts 1.0 as QtLayouts | 24 | import QtQuick.Controls 2.5 as QQC2 | ||
25 | import QtQuick.Layouts 1.3 | ||||
23 | 26 | | |||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | | |||
25 | import org.kde.plasma.components 2.0 as PlasmaComponents | | |||
26 | import org.kde.kquickcontrolsaddons 2.0 | 27 | import org.kde.kquickcontrolsaddons 2.0 | ||
28 | import org.kde.kquickcontrols 2.0 as KQC | ||||
27 | import org.kde.kirigami 2.5 as Kirigami | 29 | import org.kde.kirigami 2.5 as Kirigami | ||
28 | 30 | | |||
29 | Item { | 31 | ColumnLayout { | ||
30 | id: iconsPage | 32 | | ||
33 | id: root | ||||
31 | 34 | | |||
32 | signal configurationChanged | 35 | signal configurationChanged | ||
33 | 36 | | |||
34 | width: childrenRect.width | 37 | property var cfg_shownItems: [] | ||
35 | height: childrenRect.height | 38 | property var cfg_hiddenItems: [] | ||
36 | implicitWidth: mainColumn.implicitWidth | | |||
37 | implicitHeight: pageColumn.implicitHeight | | |||
38 | | ||||
39 | property alias cfg_applicationStatusShown: applicationStatus.checked | | |||
40 | property alias cfg_communicationsShown: communications.checked | | |||
41 | property alias cfg_systemServicesShown: systemServices.checked | | |||
42 | property alias cfg_hardwareControlShown: hardwareControl.checked | | |||
43 | property alias cfg_miscellaneousShown: miscellaneous.checked | | |||
44 | property var cfg_extraItems: [] | 39 | property var cfg_extraItems: [] | ||
40 | property alias cfg_showAllItems: showAllCheckBox.checked | ||||
45 | 41 | | |||
46 | QtControls.CheckBox { | 42 | QQC2.ComboBox { | ||
47 | id: dummyCheckbox | 43 | id: comboboxMeasure | ||
48 | visible: false | 44 | visible: false | ||
49 | } | 45 | } | ||
50 | 46 | | |||
51 | Kirigami.FormLayout { | 47 | KQC.KeySequenceItem { | ||
52 | id: pageColumn | 48 | id: keyMeasure | ||
53 | anchors { | 49 | visible: false | ||
54 | left: parent.left | | |||
55 | right: parent.right | | |||
56 | } | 50 | } | ||
57 | 51 | | |||
58 | Item { | 52 | QQC2.CheckBox { | ||
59 | Kirigami.FormData.isSection: true | 53 | id: showAllCheckBox | ||
60 | Kirigami.FormData.label: i18n("Categories") | 54 | text: i18n("Always show all entries") | ||
61 | } | 55 | } | ||
62 | 56 | | |||
63 | QtControls.CheckBox { | 57 | QQC2.ScrollView { | ||
64 | id: applicationStatus | 58 | Layout.fillWidth: true | ||
65 | text: i18n("Application Status") | 59 | Layout.fillHeight: true | ||
60 | | ||||
61 | ListView { | ||||
62 | model: plasmoid.nativeInterface.entryModel | ||||
63 | | ||||
64 | Layout.fillWidth: true | ||||
65 | Layout.fillHeight: true | ||||
These have no effect because the ListView isn't in a layout; you can just remove them ngraham: These have no effect because the ListView isn't in a layout; you can just remove them | |||||
66 | | ||||
67 | header: RowLayout { | ||||
68 | width: parent.width | ||||
69 | Kirigami.Heading { | ||||
70 | text: i18n("Entry") | ||||
71 | Layout.fillWidth: true | ||||
66 | } | 72 | } | ||
67 | QtControls.CheckBox { | 73 | Kirigami.Heading { | ||
68 | id: communications | 74 | text: i18n("Visibility") | ||
69 | text: i18n("Communications") | 75 | Layout.preferredWidth: comboboxMeasure.width | ||
70 | } | 76 | } | ||
71 | QtControls.CheckBox { | 77 | Kirigami.Heading { | ||
72 | id: systemServices | 78 | text: i18n("Shortcut") | ||
73 | text: i18n("System Services") | 79 | Layout.preferredWidth: keyMeasure.width | ||
74 | } | 80 | } | ||
75 | QtControls.CheckBox { | | |||
76 | id: hardwareControl | | |||
77 | text: i18n("Hardware Control") | | |||
78 | } | 81 | } | ||
79 | QtControls.CheckBox { | 82 | | ||
80 | id: miscellaneous | 83 | delegate: RowLayout { | ||
81 | text: i18n("Miscellaneous") | 84 | width: parent.width | ||
85 | | ||||
86 | QIconItem { | ||||
ngraham: Use a `Kirigami.Icon` instead as it has better scaling behavior | |||||
87 | id: theIcon | ||||
88 | width: units.iconSizes.small | ||||
89 | height: width | ||||
90 | icon: model.iconName || model.icon | ||||
91 | } | ||||
92 | QQC2.Label { | ||||
93 | text: name | ||||
94 | Layout.fillWidth: true | ||||
95 | elide: Text.ElideRight | ||||
96 | wrapMode: Text.NoWrap | ||||
97 | } | ||||
98 | | ||||
99 | QQC2.ComboBox { | ||||
100 | enabled: !showAllCheckBox.checked | ||||
101 | model: isPlasmoid ? [i18n("Auto"), i18n("Shown"), i18n("Hidden"), i18n("Disabled")] : [i18n("Auto"), i18n("Shown"), i18n("Hidden")] | ||||
While we're at it, I might suggest using visibility strings that are bit more obvious about their purpose. In particular "Auto" has the same issue as "Smart" in that it's not clear what it actually does. I might propose something like this: Always shown Shown while in use/when relevant/something like that Only shown in pop-up Disabled ngraham: While we're at it, I might suggest using visibility strings that are bit more obvious about… | |||||
Might be cleaner to set up the combobox model like so: https://cgit.kde.org/kdeplasma-addons.git/tree/wallpapers/potd/contents/ui/config.qml#n82, and then you could simplify currentIndex and onActivated a lot ngraham: Might be cleaner to set up the combobox model like so: https://cgit.kde.org/kdeplasma-addons. | |||||
102 | | ||||
103 | currentIndex: { | ||||
104 | if (cfg_shownItems.indexOf(taskId) != -1) { | ||||
105 | return 1; | ||||
106 | } else if (cfg_hiddenItems.indexOf(taskId) != -1) { | ||||
107 | return 2; | ||||
108 | } else { | ||||
109 | return 0; | ||||
110 | } | ||||
82 | } | 111 | } | ||
83 | 112 | | |||
113 | onActivated: { | ||||
114 | var shownIndex = cfg_shownItems.indexOf(taskId); | ||||
115 | var hiddenIndex = cfg_hiddenItems.indexOf(taskId); | ||||
116 | var extraIndex = cfg_extraItems.indexOf(taskId); | ||||
84 | 117 | | |||
85 | Item { | 118 | switch (index) { | ||
86 | Kirigami.FormData.isSection: true | 119 | case 0: { | ||
87 | Kirigami.FormData.label: i18n("Extra Items") | 120 | if (shownIndex > -1) { | ||
121 | cfg_shownItems.splice(shownIndex, 1); | ||||
122 | } | ||||
123 | if (hiddenIndex > -1) { | ||||
124 | cfg_hiddenItems.splice(hiddenIndex, 1); | ||||
88 | } | 125 | } | ||
89 | 126 | | |||
90 | Repeater { | 127 | if (extraIndex === -1) { | ||
91 | model: plasmoid.nativeInterface.availablePlasmoids | 128 | cfg_extraItems.push(taskId) | ||
92 | delegate: QtControls.CheckBox { | | |||
93 | QtLayouts.Layout.minimumWidth: childrenRect.width | | |||
94 | checked: cfg_extraItems.indexOf(plugin) != -1 | | |||
95 | implicitWidth: itemLayout.width + itemLayout.x | | |||
96 | onCheckedChanged: { | | |||
97 | var index = cfg_extraItems.indexOf(plugin); | | |||
98 | if (checked) { | | |||
99 | if (index === -1) { | | |||
100 | cfg_extraItems.push(plugin); | | |||
101 | } | 129 | } | ||
102 | } else { | 130 | | ||
103 | if (index > -1) { | 131 | break; | ||
104 | cfg_extraItems.splice(index, 1); | | |||
105 | } | 132 | } | ||
133 | case 1: { | ||||
134 | if (shownIndex === -1) { | ||||
135 | cfg_shownItems.push(taskId); | ||||
106 | } | 136 | } | ||
107 | configurationChanged() // qml cannot detect changes inside an Array | 137 | if (hiddenIndex > -1) { | ||
138 | cfg_hiddenItems.splice(hiddenIndex, 1); | ||||
108 | } | 139 | } | ||
109 | QtLayouts.RowLayout { | 140 | if (extraIndex === -1) { | ||
110 | id: itemLayout | 141 | cfg_extraItems.push(taskId) | ||
111 | anchors.verticalCenter: parent.verticalCenter | 142 | } | ||
112 | x: dummyCheckbox.width | 143 | break; | ||
113 | QIconItem { | 144 | } | ||
114 | icon: model.decoration | 145 | case 2: { | ||
115 | width: units.iconSizes.small | 146 | if (shownIndex > -1) { | ||
116 | height: width | 147 | cfg_shownItems.splice(shownIndex, 1); | ||
148 | } | ||||
149 | if (hiddenIndex === -1) { | ||||
150 | cfg_hiddenItems.push(taskId); | ||||
151 | } | ||||
152 | if (extraIndex === -1) { | ||||
153 | cfg_extraItems.push(taskId) | ||||
117 | } | 154 | } | ||
118 | QtControls.Label { | 155 | break; | ||
119 | text: model.display | | |||
120 | } | 156 | } | ||
157 | case 3: { | ||||
158 | if (extraIndex > -1) { | ||||
159 | cfg_extraItems.splice(extraIndex, 1); | ||||
160 | } | ||||
161 | break; | ||||
162 | } | ||||
163 | } | ||||
164 | root.configurationChanged(); | ||||
165 | } | ||||
166 | } | ||||
167 | KQC.KeySequenceItem { | ||||
168 | id: keySequenceItem | ||||
169 | visible: isPlasmoid | ||||
170 | keySequence: shortcut | ||||
171 | onKeySequenceChanged: { | ||||
172 | shortcut = keySequence | ||||
173 | } | ||||
174 | } | ||||
175 | // Placeholder for when KeySequenceItem is not visible | ||||
176 | Item { | ||||
177 | Layout.preferredWidth: keyMeasure.width | ||||
178 | visible: !keySequenceItem.visible | ||||
121 | } | 179 | } | ||
122 | } | 180 | } | ||
123 | } | 181 | } | ||
124 | } | 182 | } | ||
125 | } | 183 | } |
there are no longer any QQC1 items here; you can remove this import entirely