Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/package/contents/ui/PrinterItem.qml
Show All 24 Lines | |||||
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 | property bool isPaused: false | ||
33 | 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 { | ||
41 | fill: parent | 41 | fill: parent | ||
Show All 14 Lines | 49 | onEntered: { | |||
56 | } | 56 | } | ||
57 | } | 57 | } | ||
58 | onExited: { | 58 | onExited: { | ||
59 | if (printerItem.ListView.view.highlightItem) { | 59 | if (printerItem.ListView.view.highlightItem) { | ||
60 | printerItem.ListView.view.highlightItem.opacity = 0 | 60 | printerItem.ListView.view.highlightItem.opacity = 0 | ||
61 | } | 61 | } | ||
62 | } | 62 | } | ||
63 | onClicked: { | 63 | onClicked: { | ||
64 | printerItem.ListView.view.currentExpanded = expanded ? -1 : index; | 64 | // the order is important, don't change since the last | ||
65 | // line resets the value of expanded and makes the code hard to read | ||||
66 | // if it's not the last one | ||||
65 | jobsFilterModel.filteredPrinters = expanded ? "" : printerName | 67 | jobsFilterModel.filteredPrinters = expanded ? "" : printerName | ||
68 | printerItem.ListView.view.currentExpanded = expanded ? -1 : index; | ||||
66 | } | 69 | } | ||
67 | 70 | | |||
68 | KQuickControlsAddons.QIconItem { | 71 | KQuickControlsAddons.QIconItem { | ||
69 | id: printerIcon | 72 | id: printerIcon | ||
70 | 73 | | |||
71 | anchors { | 74 | anchors { | ||
72 | left: parent.left | 75 | left: parent.left | ||
73 | verticalCenter: labelsColumn.verticalCenter | 76 | verticalCenter: labelsColumn.verticalCenter | ||
▲ Show 20 Lines • Show All 230 Lines • Show Last 20 Lines |