Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/package/contents/ui/PrinterItem.qml
Show All 23 Lines | 232 | MouseArea { | |||
---|---|---|---|---|---|
251 | } | 251 | } | ||
252 | } | 252 | } | ||
253 | } | 253 | } | ||
254 | } | 254 | } | ||
255 | } | 255 | } | ||
256 | } | 256 | } | ||
257 | 257 | | |||
258 | Component.onCompleted: { | 258 | Component.onCompleted: { | ||
259 | isPaused = printerState === 5 | 259 | isPaused = printerState === 5 | ||
broulik: Can you see if assigning a binding here works instead?
```
isPaused = Qt.binding(function() {… | |||||
260 | printersModel.dataChanged.connect(printerDataChanged) | ||||
260 | } | 261 | } | ||
261 | 262 | | |||
262 | states: [ | 263 | states: [ | ||
263 | State { | 264 | State { | ||
264 | name: "NORMAL" | 265 | name: "NORMAL" | ||
265 | when: !isPaused | 266 | when: !isPaused | ||
266 | }, | 267 | }, | ||
267 | 268 | | |||
268 | State { | 269 | State { | ||
269 | name: "PAUSED" | 270 | name: "PAUSED" | ||
270 | when: isPaused | 271 | when: isPaused | ||
271 | PropertyChanges { target: printerNameLabel; opacity: 0.6 } | 272 | PropertyChanges { target: printerNameLabel; opacity: 0.6 } | ||
272 | PropertyChanges { target: printerIcon; opacity: 0.6 } | 273 | PropertyChanges { target: printerIcon; opacity: 0.6 } | ||
273 | } | 274 | } | ||
274 | ] | 275 | ] | ||
275 | 276 | | |||
277 | function printerDataChanged() { | ||||
278 | var nowPaused = printerState === 5 | ||||
279 | if (nowPaused != isPaused) { | ||||
280 | isPaused = nowPaused | ||||
281 | } | ||||
282 | } | ||||
283 | | ||||
276 | function getJobsLabel() { | 284 | function getJobsLabel() { | ||
277 | if (printmanager.jobsFilter == PrintManager.JobModel.WhichActive) { | 285 | if (printmanager.jobsFilter == PrintManager.JobModel.WhichActive) { | ||
278 | if (jobsFilterModel.count == 0) { | 286 | if (jobsFilterModel.count == 0) { | ||
279 | return i18n("No active jobs"); | 287 | return i18n("No active jobs"); | ||
280 | } else { | 288 | } else { | ||
281 | return i18np("One active job", "%1 active jobs", jobsFilterModel.count); | 289 | return i18np("One active job", "%1 active jobs", jobsFilterModel.count); | ||
282 | } | 290 | } | ||
283 | } else { | 291 | } else { | ||
Show All 19 Lines |
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