Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/package/contents/ui/PrinterItem.qml
Show All 23 Lines | |||||
24 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 24 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
25 | import org.kde.plasma.components 2.0 as PlasmaComponents | 25 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
26 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | 26 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | ||
27 | import org.kde.plasma.printmanager 0.2 as PrintManager | 27 | import org.kde.plasma.printmanager 0.2 as PrintManager | ||
28 | 28 | | |||
29 | Item { | 29 | Item { | ||
30 | id: printerItem | 30 | id: printerItem | ||
31 | 31 | | |||
32 | property bool isPaused: false | 32 | readonly property bool isPaused: printerState === 5 | ||
33 | readonly property bool expanded: ListView.view.currentExpanded == index | 33 | readonly property bool expanded: ListView.view.currentExpanded == index | ||
34 | 34 | | |||
35 | height: container.childrenRect.height + Math.round(units.gridUnit / 2) | 35 | height: container.childrenRect.height + Math.round(units.gridUnit / 2) | ||
36 | width: parent.width - Math.round(units.gridUnit / 2) | 36 | width: parent.width - Math.round(units.gridUnit / 2) | ||
37 | 37 | | |||
38 | MouseArea { | 38 | MouseArea { | ||
39 | id: container | 39 | id: container | ||
40 | anchors { | 40 | anchors { | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 126 | PlasmaComponents.ToolButton { | |||
128 | 128 | | |||
129 | anchors { | 129 | anchors { | ||
130 | right: parent.right | 130 | right: parent.right | ||
131 | rightMargin: Math.round(units.gridUnit / 2) | 131 | rightMargin: Math.round(units.gridUnit / 2) | ||
132 | verticalCenter: printerIcon.verticalCenter | 132 | verticalCenter: printerIcon.verticalCenter | ||
133 | } | 133 | } | ||
134 | 134 | | |||
135 | iconSource: isPaused ? "media-playback-start" : "media-playback-pause" | 135 | iconSource: isPaused ? "media-playback-start" : "media-playback-pause" | ||
136 | tooltip: isPaused ? i18n("Resume printing") : i18n("Pause printing") | ||||
136 | opacity: container.containsMouse ? 1 : 0 | 137 | opacity: container.containsMouse ? 1 : 0 | ||
137 | visible: opacity != 0 | 138 | visible: opacity != 0 | ||
138 | 139 | | |||
139 | onClicked: toggleSelection() | 140 | onClicked: toggleSelection() | ||
140 | } | 141 | } | ||
141 | 142 | | |||
142 | ListView { | 143 | ListView { | ||
143 | id: actionsList | 144 | id: actionsList | ||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 244 | onClicked: { | |||
250 | } | 251 | } | ||
251 | } | 252 | } | ||
252 | } | 253 | } | ||
253 | } | 254 | } | ||
254 | } | 255 | } | ||
255 | } | 256 | } | ||
256 | } | 257 | } | ||
257 | 258 | | |||
258 | Component.onCompleted: { | | |||
259 | isPaused = printerState === 5 | | |||
260 | } | | |||
261 | | ||||
262 | states: [ | 259 | states: [ | ||
broulik: Can you see if assigning a binding here works instead?
```
isPaused = Qt.binding(function() {… | |||||
263 | State { | 260 | State { | ||
264 | name: "NORMAL" | 261 | name: "NORMAL" | ||
265 | when: !isPaused | 262 | when: !isPaused | ||
266 | }, | 263 | }, | ||
267 | 264 | | |||
268 | State { | 265 | State { | ||
269 | name: "PAUSED" | 266 | name: "PAUSED" | ||
270 | when: isPaused | 267 | when: isPaused | ||
Show All 15 Lines | 280 | } else { | |||
286 | } else { | 283 | } else { | ||
287 | return i18np("One job", "%1 jobs", jobsFilterModel.count); | 284 | return i18np("One job", "%1 jobs", jobsFilterModel.count); | ||
288 | } | 285 | } | ||
289 | } | 286 | } | ||
290 | } | 287 | } | ||
291 | 288 | | |||
292 | function toggleSelection() { | 289 | function toggleSelection() { | ||
293 | if (isPaused) { | 290 | if (isPaused) { | ||
294 | if (printerState === 5) { | | |||
295 | printersModel.resumePrinter(printerName) | 291 | printersModel.resumePrinter(printerName) | ||
296 | } | | |||
297 | } else { | 292 | } else { | ||
298 | printersModel.pausePrinter(printerName) | 293 | printersModel.pausePrinter(printerName) | ||
299 | } | 294 | } | ||
300 | isPaused = !isPaused | | |||
301 | } | 295 | } | ||
302 | } | 296 | } |
Can you see if assigning a binding here works instead?
Ideally, this was done entirely declaratively, i.e. assign the property
but I don't know the code enough to tell why it was done imperatively originally