Commit 3ce3d1f4 authored by Jonathan Marten's avatar Jonathan Marten
Browse files

Update the GUI enabled/paused state if it changes externally

This means via the cupsenable/cupsdisable commands, CUPS detecting an
error etc.  Eliminate the explicit tracking of the printer state using
isPaused and simply do it declaratively instead.

Differential Revision: https://phabricator.kde.org/D25186
parent 03af4175
...@@ -29,7 +29,7 @@ import org.kde.plasma.printmanager 0.2 as PrintManager ...@@ -29,7 +29,7 @@ import org.kde.plasma.printmanager 0.2 as PrintManager
Item { Item {
id: printerItem id: printerItem
property bool isPaused: false readonly property bool isPaused: printerState === 5
readonly property bool expanded: ListView.view.currentExpanded == index readonly property bool expanded: ListView.view.currentExpanded == index
height: container.childrenRect.height + Math.round(units.gridUnit / 2) height: container.childrenRect.height + Math.round(units.gridUnit / 2)
...@@ -133,6 +133,7 @@ Item { ...@@ -133,6 +133,7 @@ Item {
} }
iconSource: isPaused ? "media-playback-start" : "media-playback-pause" iconSource: isPaused ? "media-playback-start" : "media-playback-pause"
tooltip: isPaused ? i18n("Resume printing") : i18n("Pause printing")
opacity: container.containsMouse ? 1 : 0 opacity: container.containsMouse ? 1 : 0
visible: opacity != 0 visible: opacity != 0
...@@ -255,10 +256,6 @@ Item { ...@@ -255,10 +256,6 @@ Item {
} }
} }
Component.onCompleted: {
isPaused = printerState === 5
}
states: [ states: [
State { State {
name: "NORMAL" name: "NORMAL"
...@@ -291,12 +288,9 @@ Item { ...@@ -291,12 +288,9 @@ Item {
function toggleSelection() { function toggleSelection() {
if (isPaused) { if (isPaused) {
if (printerState === 5) { printersModel.resumePrinter(printerName)
printersModel.resumePrinter(printerName)
}
} else { } else {
printersModel.pausePrinter(printerName) printersModel.pausePrinter(printerName)
} }
isPaused = !isPaused
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment