Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/package/contents/ui/printmanager.qml
Show All 24 Lines | |||||
25 | import org.kde.plasma.printmanager 0.2 as PrintManager | 25 | import org.kde.plasma.printmanager 0.2 as PrintManager | ||
26 | 26 | | |||
27 | Item { | 27 | Item { | ||
28 | id: printmanager | 28 | id: printmanager | ||
29 | 29 | | |||
30 | property int jobsFilter: printmanager.Plasmoid.configuration.allJobs ? PrintManager.JobModel.WhichAll : | 30 | property int jobsFilter: printmanager.Plasmoid.configuration.allJobs ? PrintManager.JobModel.WhichAll : | ||
31 | printmanager.Plasmoid.configuration.completedJobs ? PrintManager.JobModel.WhichCompleted : PrintManager.JobModel.WhichActive | 31 | printmanager.Plasmoid.configuration.completedJobs ? PrintManager.JobModel.WhichCompleted : PrintManager.JobModel.WhichActive | ||
32 | 32 | | |||
33 | property alias serverUnavailable: printersModel.serverUnavailable | ||||
34 | property string printersModelError: "" | ||||
35 | | ||||
33 | readonly property string kcmName: "kcm_printer_manager" | 36 | readonly property string kcmName: "kcm_printer_manager" | ||
34 | readonly property bool kcmAllowed: KCMShell.authorize(kcmName + ".desktop").length > 0 | 37 | readonly property bool kcmAllowed: KCMShell.authorize(kcmName + ".desktop").length > 0 | ||
35 | 38 | | |||
36 | Plasmoid.toolTipMainText: i18n("Printers") | 39 | Plasmoid.toolTipMainText: i18n("Printers") | ||
37 | Plasmoid.toolTipSubText: activeJobsFilterModel.activeCount ? i18np("There is one print job in the queue", | 40 | Plasmoid.toolTipSubText: activeJobsFilterModel.activeCount ? i18np("There is one print job in the queue", | ||
38 | "There are %1 print jobs in the queue", | 41 | "There are %1 print jobs in the queue", | ||
39 | activeJobsFilterModel.activeCount) | 42 | activeJobsFilterModel.activeCount) | ||
40 | : i18n("Print queue is empty") | 43 | : i18n("Print queue is empty") | ||
41 | Plasmoid.icon: "printer" | 44 | Plasmoid.icon: "printer" | ||
42 | Plasmoid.fullRepresentation: PopupDialog { | 45 | Plasmoid.fullRepresentation: PopupDialog { | ||
43 | id: dialogItem | 46 | id: dialogItem | ||
44 | 47 | | |||
45 | anchors.fill: parent | 48 | anchors.fill: parent | ||
46 | focus: true | 49 | focus: true | ||
47 | } | 50 | } | ||
48 | 51 | | |||
49 | Plasmoid.switchWidth: units.gridUnit * 10 | 52 | Plasmoid.switchWidth: units.gridUnit * 10 | ||
50 | Plasmoid.switchHeight: units.gridUnit * 10 | 53 | Plasmoid.switchHeight: units.gridUnit * 10 | ||
51 | Plasmoid.status: (activeJobsFilterModel.activeCount > 0) ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus | 54 | Plasmoid.status: { | ||
55 | if (activeJobsFilterModel.activeCount > 0) { | ||||
56 | return PlasmaCore.Types.ActiveStatus; | ||||
57 | } else if (printersModel.count > 0 || serverUnavailable) { | ||||
58 | return PlasmaCore.Types.PassiveStatus; | ||||
59 | } else { | ||||
60 | return PlasmaCore.Types.HiddenStatus; | ||||
61 | } | ||||
62 | } | ||||
52 | 63 | | |||
53 | onJobsFilterChanged: jobsModel.setWhichJobs(jobsFilter) | 64 | onJobsFilterChanged: jobsModel.setWhichJobs(jobsFilter) | ||
54 | Component.onCompleted: { | 65 | Component.onCompleted: { | ||
55 | if (kcmAllowed) { | 66 | if (kcmAllowed) { | ||
56 | plasmoid.setAction("printerskcm", i18n("&Configure Printers..."), "printer"); | 67 | plasmoid.setAction("printerskcm", i18n("&Configure Printers..."), "printer"); | ||
57 | } | 68 | } | ||
58 | } | 69 | } | ||
59 | 70 | | |||
71 | PrintManager.PrinterModel { | ||||
72 | id: printersModel | ||||
73 | onError: printersModelError = errorTitle | ||||
74 | } | ||||
75 | | ||||
60 | PrintManager.JobSortFilterModel { | 76 | PrintManager.JobSortFilterModel { | ||
61 | id: jobsFilterModel | 77 | id: jobsFilterModel | ||
62 | 78 | | |||
63 | sourceModel: PrintManager.JobModel { | 79 | sourceModel: PrintManager.JobModel { | ||
64 | id: jobsModel | 80 | id: jobsModel | ||
65 | Component.onCompleted: setWhichJobs(printmanager.jobsFilter) | 81 | Component.onCompleted: setWhichJobs(printmanager.jobsFilter) | ||
66 | } | 82 | } | ||
67 | } | 83 | } | ||
Show All 12 Lines |