Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/package/contents/ui/ConfigEntries.qml
Show All 11 Lines | |||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. | ||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | 16 | * 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. | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.0 | 20 | import QtQuick 2.5 | ||
21 | import QtQuick.Controls 1.0 as QtControls | 21 | import QtQuick.Controls 1.4 as QQC1 | ||
22 | import QtQuick.Layouts 1.1 as QtLayouts | 22 | import QtQuick.Controls 2.5 as QQC2 | ||
23 | import QtQuick.Layouts 1.3 | ||||
23 | 24 | | |||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 25 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | import org.kde.plasma.components 2.0 as PlasmaComponents | 26 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
26 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 27 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
27 | import org.kde.kquickcontrolsaddons 2.0 | 28 | import org.kde.kquickcontrolsaddons 2.0 | ||
28 | import org.kde.kquickcontrols 2.0 as KQC | 29 | import org.kde.kquickcontrols 2.0 as KQC | ||
30 | import org.kde.kirigami 2.5 as Kirigami | ||||
29 | 31 | | |||
30 | QtLayouts.GridLayout { | 32 | ColumnLayout { | ||
31 | id: iconsPage | 33 | id: iconsPage | ||
32 | 34 | | |||
33 | signal configurationChanged | 35 | signal configurationChanged | ||
34 | 36 | | |||
35 | property var cfg_shownItems: [] | 37 | property var cfg_shownItems: [] | ||
36 | property var cfg_hiddenItems: [] | 38 | property var cfg_hiddenItems: [] | ||
37 | property alias cfg_showAllItems: showAllCheckBox.checked | 39 | property alias cfg_showAllItems: showAllCheckBox.checked | ||
38 | 40 | | |||
39 | columns: 2 // so we can indent the entries below... | | |||
40 | | ||||
41 | function saveConfig () { | 41 | function saveConfig () { | ||
42 | for (var i in tableView.model) { | 42 | for (var i in tableView.model) { | ||
43 | //tableView.model[i].applet.globalShortcut = tableView.model[i].shortcut | 43 | //tableView.model[i].applet.globalShortcut = tableView.model[i].shortcut | ||
44 | } | 44 | } | ||
45 | } | 45 | } | ||
46 | 46 | | |||
47 | PlasmaCore.DataSource { | 47 | PlasmaCore.DataSource { | ||
48 | id: statusNotifierSource | 48 | id: statusNotifierSource | ||
Show All 9 Lines | 57 | } | |||
58 | 58 | | |||
59 | PlasmaCore.SortFilterModel { | 59 | PlasmaCore.SortFilterModel { | ||
60 | id: statusNotifierModel | 60 | id: statusNotifierModel | ||
61 | sourceModel: PlasmaCore.DataModel { | 61 | sourceModel: PlasmaCore.DataModel { | ||
62 | dataSource: statusNotifierSource | 62 | dataSource: statusNotifierSource | ||
63 | } | 63 | } | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | QtControls.CheckBox { | 66 | | ||
67 | Kirigami.FormLayout { | ||||
68 | | ||||
69 | QQC2.CheckBox { | ||||
67 | id: showAllCheckBox | 70 | id: showAllCheckBox | ||
68 | QtLayouts.Layout.fillWidth: true | | |||
69 | QtLayouts.Layout.columnSpan: iconsPage.columns | | |||
70 | QtLayouts.Layout.row: 1 | | |||
71 | text: i18n("Always show all entries") | 71 | text: i18n("Always show all entries") | ||
72 | } | 72 | } | ||
73 | 73 | | |||
74 | QtControls.Button { // just for measurement | 74 | QQC2.Button { // just for measurement | ||
75 | id: measureButton | 75 | id: measureButton | ||
76 | text: "measureButton" | 76 | text: "measureButton" | ||
77 | visible: false | 77 | visible: false | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | // resizeToContents does not take into account the heading | 80 | // resizeToContents does not take into account the heading | ||
81 | QtControls.Label { | 81 | QQC2.Label { | ||
82 | id: shortcutColumnMeasureLabel | 82 | id: shortcutColumnMeasureLabel | ||
83 | text: shortcutColumn.title | 83 | text: shortcutColumn.title | ||
84 | visible: false | 84 | visible: false | ||
85 | } | 85 | } | ||
86 | } | ||||
87 | | ||||
86 | 88 | | |||
87 | function retrieveAllItems() { | 89 | function retrieveAllItems() { | ||
88 | var list = []; | 90 | var list = []; | ||
89 | for (var i = 0; i < statusNotifierModel.count; ++i) { | 91 | for (var i = 0; i < statusNotifierModel.count; ++i) { | ||
90 | var item = statusNotifierModel.get(i); | 92 | var item = statusNotifierModel.get(i); | ||
91 | list.push({ | 93 | list.push({ | ||
92 | "index": i, | 94 | "index": i, | ||
93 | "taskId": item.Id, | 95 | "taskId": item.Id, | ||
Show All 15 Lines | 102 | for (var i = 0; i < plasmoid.applets.length; ++i) { | |||
109 | }); | 111 | }); | ||
110 | } | 112 | } | ||
111 | list.sort(function(a, b) { | 113 | list.sort(function(a, b) { | ||
112 | return a.name.localeCompare(b.name); | 114 | return a.name.localeCompare(b.name); | ||
113 | }); | 115 | }); | ||
114 | return list; | 116 | return list; | ||
115 | } | 117 | } | ||
116 | 118 | | |||
117 | QtControls.TableView { | 119 | // There is no QQC2 version of TableView yet | ||
120 | QQC1.TableView { | ||||
118 | id: tableView | 121 | id: tableView | ||
119 | QtLayouts.Layout.fillWidth: true | 122 | Layout.fillWidth: true | ||
120 | QtLayouts.Layout.fillHeight: true | 123 | Layout.fillHeight: true | ||
121 | QtLayouts.Layout.row: 2 | | |||
122 | QtLayouts.Layout.column: 1 | | |||
123 | 124 | | |||
124 | model: retrieveAllItems() | 125 | model: retrieveAllItems() | ||
125 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | 126 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | ||
126 | flickableItem.boundsBehavior: Flickable.StopAtBounds | 127 | flickableItem.boundsBehavior: Flickable.StopAtBounds | ||
127 | 128 | | |||
128 | Component.onCompleted: { | 129 | Component.onCompleted: { | ||
129 | visibilityColumn.resizeToContents() | 130 | visibilityColumn.resizeToContents() | ||
130 | shortcutColumn.resizeToContents() | 131 | shortcutColumn.resizeToContents() | ||
131 | } | 132 | } | ||
132 | 133 | | |||
133 | // Taken from QtQuickControls BasicTableViewStyle, just to make its height sensible... | 134 | // Taken from QtQuickControls BasicTableViewStyle, just to make its height sensible... | ||
134 | rowDelegate: BorderImage { | 135 | rowDelegate: BorderImage { | ||
135 | visible: styleData.selected || styleData.alternate | 136 | visible: styleData.selected || styleData.alternate | ||
136 | source: "image://__tablerow/" + (styleData.alternate ? "alternate_" : "") | 137 | source: "image://__tablerow/" + (styleData.alternate ? "alternate_" : "") | ||
137 | + (tableView.activeFocus ? "active" : "") | 138 | + (tableView.activeFocus ? "active" : "") | ||
138 | height: measureButton.height | 139 | height: measureButton.height | ||
139 | border.left: 4 ; border.right: 4 | 140 | border.left: 4 ; border.right: 4 | ||
140 | } | 141 | } | ||
141 | 142 | | |||
142 | QtControls.TableViewColumn { | 143 | QQC1.TableViewColumn { | ||
143 | id: entryColumn | 144 | id: entryColumn | ||
144 | width: tableView.viewport.width - visibilityColumn.width - shortcutColumn.width | 145 | width: tableView.viewport.width - visibilityColumn.width - shortcutColumn.width | ||
145 | title: i18nc("Name of the system tray entry", "Entry") | 146 | title: i18nc("Name of the system tray entry", "Entry") | ||
146 | movable: false | 147 | movable: false | ||
147 | resizable: false | 148 | resizable: false | ||
148 | 149 | | |||
149 | delegate: QtLayouts.RowLayout { | 150 | delegate: RowLayout { | ||
150 | Item { // spacer | 151 | Item { // spacer | ||
151 | QtLayouts.Layout.preferredWidth: 1 | 152 | Layout.preferredWidth: 1 | ||
152 | QtLayouts.Layout.fillHeight: true | 153 | Layout.fillHeight: true | ||
153 | } | 154 | } | ||
154 | 155 | | |||
155 | QIconItem { | 156 | QIconItem { | ||
156 | width: units.iconSizes.small | 157 | width: units.iconSizes.small | ||
157 | height: width | 158 | height: width | ||
158 | icon: modelData.iconName || modelData.icon || "" | 159 | icon: modelData.iconName || modelData.icon || "" | ||
159 | } | 160 | } | ||
160 | 161 | | |||
161 | QtControls.Label { | 162 | QQC2.Label { | ||
162 | QtLayouts.Layout.fillWidth: true | 163 | Layout.fillWidth: true | ||
163 | text: modelData.name | 164 | text: modelData.name | ||
164 | elide: Text.ElideRight | 165 | elide: Text.ElideRight | ||
165 | wrapMode: Text.NoWrap | 166 | wrapMode: Text.NoWrap | ||
166 | } | 167 | } | ||
167 | } | 168 | } | ||
168 | } | 169 | } | ||
169 | 170 | | |||
170 | QtControls.TableViewColumn { | 171 | QQC1.TableViewColumn { | ||
171 | id: visibilityColumn | 172 | id: visibilityColumn | ||
172 | title: i18n("Visibility") | 173 | title: i18n("Visibility") | ||
173 | movable: false | 174 | movable: false | ||
174 | resizable: false | 175 | resizable: false | ||
175 | 176 | | |||
176 | delegate: QtControls.ComboBox { | 177 | delegate: QQC2.ComboBox { | ||
177 | implicitWidth: Math.round(units.gridUnit * 6.5) // ComboBox sizing is broken | 178 | implicitWidth: Math.round(units.gridUnit * 6.5) // ComboBox sizing is broken | ||
178 | 179 | | |||
179 | enabled: !showAllCheckBox.checked | 180 | enabled: !showAllCheckBox.checked | ||
180 | currentIndex: { | 181 | currentIndex: { | ||
181 | if (cfg_shownItems.indexOf(modelData.taskId) != -1) { | 182 | if (cfg_shownItems.indexOf(modelData.taskId) != -1) { | ||
182 | return 1; | 183 | return 1; | ||
183 | } else if (cfg_hiddenItems.indexOf(modelData.taskId) != -1) { | 184 | } else if (cfg_hiddenItems.indexOf(modelData.taskId) != -1) { | ||
184 | return 2; | 185 | return 2; | ||
Show All 37 Lines | 192 | onActivated: { | |||
222 | } | 223 | } | ||
223 | } | 224 | } | ||
224 | iconsPage.configurationChanged(); | 225 | iconsPage.configurationChanged(); | ||
225 | } | 226 | } | ||
226 | model: [i18n("Auto"), i18n("Shown"), i18n("Hidden")] | 227 | model: [i18n("Auto"), i18n("Shown"), i18n("Hidden")] | ||
227 | } | 228 | } | ||
228 | } | 229 | } | ||
229 | 230 | | |||
230 | QtControls.TableViewColumn { | 231 | QQC1.TableViewColumn { | ||
231 | id: shortcutColumn | 232 | id: shortcutColumn | ||
232 | title: i18n("Keyboard Shortcut") // FIXME doesn't fit | 233 | title: i18n("Keyboard Shortcut") // FIXME doesn't fit | ||
233 | movable: false | 234 | movable: false | ||
234 | resizable: false | 235 | resizable: false | ||
235 | 236 | | |||
236 | // this Item wrapper prevents TableView from ripping apart the two KeySequenceItem buttons | 237 | // this Item wrapper prevents TableView from ripping apart the two KeySequenceItem buttons | ||
237 | delegate: Item { | 238 | delegate: Item { | ||
238 | implicitWidth: Math.max(shortcutColumnMeasureLabel.width, keySequenceItem.width) + 10 | 239 | implicitWidth: Math.max(shortcutColumnMeasureLabel.width, keySequenceItem.width) + 10 | ||
Show All 27 Lines |