Changeset View
Changeset View
Standalone View
Standalone View
applets/kickoff/package/contents/ui/Kickoff.qml
Show All 31 Lines | |||||
32 | 32 | | |||
33 | Item { | 33 | Item { | ||
34 | id: kickoff | 34 | id: kickoff | ||
35 | 35 | | |||
36 | readonly property bool inPanel: (plasmoid.location == PlasmaCore.Types.TopEdge | 36 | readonly property bool inPanel: (plasmoid.location == PlasmaCore.Types.TopEdge | ||
37 | || plasmoid.location == PlasmaCore.Types.RightEdge | 37 | || plasmoid.location == PlasmaCore.Types.RightEdge | ||
38 | || plasmoid.location == PlasmaCore.Types.BottomEdge | 38 | || plasmoid.location == PlasmaCore.Types.BottomEdge | ||
39 | || plasmoid.location == PlasmaCore.Types.LeftEdge) | 39 | || plasmoid.location == PlasmaCore.Types.LeftEdge) | ||
40 | readonly property bool vertical: (plasmoid.formFactor == PlasmaCore.Types.Vertical) | ||||
40 | 41 | | |||
41 | Plasmoid.switchWidth: units.gridUnit * 20 | 42 | Plasmoid.switchWidth: units.gridUnit * 20 | ||
42 | Plasmoid.switchHeight: units.gridUnit * 30 | 43 | Plasmoid.switchHeight: units.gridUnit * 30 | ||
43 | 44 | | |||
44 | Plasmoid.fullRepresentation: FullRepresentation {} | 45 | Plasmoid.fullRepresentation: FullRepresentation {} | ||
45 | 46 | | |||
46 | Plasmoid.icon: plasmoid.configuration.icon | 47 | Plasmoid.icon: plasmoid.configuration.icon | ||
47 | 48 | | |||
48 | Plasmoid.compactRepresentation: MouseArea { | 49 | Plasmoid.compactRepresentation: MouseArea { | ||
49 | //AppletQuickItem expects a layout to exist | 50 | id: compactRoot | ||
50 | //setting even a default property forces it to be created | 51 | | ||
51 | Layout.fillWidth: false | | |||
52 | Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1 | 52 | Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1 | ||
53 | Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1 | 53 | Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1 | ||
54 | hoverEnabled: true | 54 | hoverEnabled: true | ||
55 | onClicked: plasmoid.expanded = !plasmoid.expanded | 55 | onClicked: plasmoid.expanded = !plasmoid.expanded | ||
56 | 56 | | |||
57 | onWidthChanged: updateSizeHints() | ||||
58 | onHeightChanged: updateSizeHints() | ||||
59 | | ||||
60 | function updateSizeHints() { | ||||
61 | if (kickoff.vertical) { | ||||
62 | var scaledHeight = Math.floor(parent.width * (buttonIcon.implicitHeight / buttonIcon.implicitWidth)); | ||||
63 | compactRoot.Layout.minimumHeight = scaledHeight; | ||||
64 | compactRoot.Layout.maximumHeight = scaledHeight; | ||||
65 | compactRoot.Layout.minimumWidth = units.iconSizes.small; | ||||
66 | compactRoot.Layout.maximumWidth = inPanel ? units.iconSizeHints.panel : -1; | ||||
67 | } else { | ||||
68 | var scaledWidth = Math.floor(parent.height * (buttonIcon.implicitWidth / buttonIcon.implicitHeight)); | ||||
69 | compactRoot.Layout.minimumWidth = scaledWidth; | ||||
70 | compactRoot.Layout.maximumWidth = scaledWidth; | ||||
71 | compactRoot.Layout.minimumHeight = units.iconSizes.small; | ||||
72 | compactRoot.Layout.maximumHeight = inPanel ? units.iconSizeHints.panel : -1; | ||||
73 | } | ||||
74 | } | ||||
75 | | ||||
76 | Connections { | ||||
77 | target: units.iconSizeHints | ||||
78 | | ||||
79 | onPanelChanged: compactRoot.updateSizeHints() | ||||
80 | } | ||||
81 | | ||||
57 | DropArea { | 82 | DropArea { | ||
58 | id: compactDragArea | 83 | id: compactDragArea | ||
59 | anchors.fill: parent | 84 | anchors.fill: parent | ||
60 | } | 85 | } | ||
61 | 86 | | |||
62 | Timer { | 87 | Timer { | ||
63 | id: expandOnDragTimer | 88 | id: expandOnDragTimer | ||
64 | interval: 250 | 89 | interval: 250 | ||
65 | running: compactDragArea.containsDrag | 90 | running: compactDragArea.containsDrag | ||
66 | onTriggered: plasmoid.expanded = true | 91 | onTriggered: plasmoid.expanded = true | ||
67 | } | 92 | } | ||
68 | 93 | | |||
69 | PlasmaCore.IconItem { | 94 | PlasmaCore.IconItem { | ||
95 | id: buttonIcon | ||||
96 | | ||||
97 | readonly property double aspectRatio: (vertical ? implicitHeight / implicitWidth | ||||
98 | : implicitWidth / implicitHeight) | ||||
99 | | ||||
70 | anchors.fill: parent | 100 | anchors.fill: parent | ||
71 | source: plasmoid.icon | 101 | source: plasmoid.icon | ||
72 | active: parent.containsMouse || compactDragArea.containsDrag | 102 | active: parent.containsMouse || compactDragArea.containsDrag | ||
73 | smooth: true | 103 | smooth: true | ||
104 | roundToIconSize: aspectRatio === 1 | ||||
105 | | ||||
106 | onSourceChanged: updateSizeHints() | ||||
74 | } | 107 | } | ||
75 | } | 108 | } | ||
76 | 109 | | |||
77 | property Item dragSource: null | 110 | property Item dragSource: null | ||
78 | 111 | | |||
79 | Kicker.ProcessRunner { | 112 | Kicker.ProcessRunner { | ||
80 | id: processRunner; | 113 | id: processRunner; | ||
81 | } | 114 | } | ||
Show All 14 Lines |