Changeset View
Changeset View
Standalone View
Standalone View
desktoppackage/contents/applet/DefaultCompactRepresentation.qml
Show All 17 Lines | |||||
18 | 18 | | |||
19 | import QtQuick 2.0 | 19 | import QtQuick 2.0 | ||
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 | ||
21 | import org.kde.plasma.core 2.0 as PlasmaCore | 21 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
22 | 22 | | |||
23 | PlasmaCore.IconItem { | 23 | PlasmaCore.IconItem { | ||
24 | id: icon | 24 | id: icon | ||
25 | 25 | | |||
26 | readonly property bool inPanel: (plasmoid.location == PlasmaCore.Types.TopEdge | ||||
27 | || plasmoid.location == PlasmaCore.Types.RightEdge | ||||
28 | || plasmoid.location == PlasmaCore.Types.BottomEdge | ||||
29 | || plasmoid.location == PlasmaCore.Types.LeftEdge) | ||||
30 | | ||||
26 | Layout.minimumWidth: { | 31 | Layout.minimumWidth: { | ||
27 | switch (plasmoid.formFactor) { | 32 | switch (plasmoid.formFactor) { | ||
28 | case PlasmaCore.Types.Vertical: | 33 | case PlasmaCore.Types.Vertical: | ||
29 | return 0; | 34 | return 0; | ||
30 | case PlasmaCore.Types.Horizontal: | 35 | case PlasmaCore.Types.Horizontal: | ||
31 | return height; | 36 | return height; | ||
32 | default: | 37 | default: | ||
33 | return units.gridUnit * 3; | 38 | return units.gridUnit * 3; | ||
34 | } | 39 | } | ||
35 | } | 40 | } | ||
36 | 41 | | |||
37 | Layout.minimumHeight: { | 42 | Layout.minimumHeight: { | ||
38 | switch (plasmoid.formFactor) { | 43 | switch (plasmoid.formFactor) { | ||
39 | case PlasmaCore.Types.Vertical: | 44 | case PlasmaCore.Types.Vertical: | ||
40 | return width; | 45 | return width; | ||
41 | case PlasmaCore.Types.Horizontal: | 46 | case PlasmaCore.Types.Horizontal: | ||
42 | return 0; | 47 | return 0; | ||
43 | default: | 48 | default: | ||
44 | return units.gridUnit * 3; | 49 | return units.gridUnit * 3; | ||
45 | } | 50 | } | ||
46 | } | 51 | } | ||
47 | 52 | | |||
53 | root.Layout.maximumWidth = inPanel ? units.iconSizeHints.panel : undefined; | ||||
54 | root.Layout.maximumHeight = inPanel ? units.iconSizeHints.panel : undefined; | ||||
55 | | ||||
48 | source: plasmoid.icon ? plasmoid.icon : "plasma" | 56 | source: plasmoid.icon ? plasmoid.icon : "plasma" | ||
49 | active: mouseArea.containsMouse | 57 | active: mouseArea.containsMouse | ||
50 | 58 | | |||
51 | MouseArea { | 59 | MouseArea { | ||
52 | id: mouseArea | 60 | id: mouseArea | ||
53 | 61 | | |||
54 | property bool wasExpanded: false | 62 | property bool wasExpanded: false | ||
55 | 63 | | |||
56 | anchors.fill: parent | 64 | anchors.fill: parent | ||
57 | hoverEnabled: true | 65 | hoverEnabled: true | ||
58 | onPressed: wasExpanded = plasmoid.expanded | 66 | onPressed: wasExpanded = plasmoid.expanded | ||
59 | onClicked: plasmoid.expanded = !wasExpanded | 67 | onClicked: plasmoid.expanded = !wasExpanded | ||
60 | } | 68 | } | ||
61 | } | 69 | } |