Changeset View
Changeset View
Standalone View
Standalone View
applets/kickoff/package/contents/ui/Kickoff.qml
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 33 | Item { | |||
---|---|---|---|---|---|
44 | 44 | | |||
45 | Plasmoid.fullRepresentation: FullRepresentation {} | 45 | Plasmoid.fullRepresentation: FullRepresentation {} | ||
46 | 46 | | |||
47 | Plasmoid.icon: plasmoid.configuration.icon | 47 | Plasmoid.icon: plasmoid.configuration.icon | ||
48 | 48 | | |||
49 | Plasmoid.compactRepresentation: MouseArea { | 49 | Plasmoid.compactRepresentation: MouseArea { | ||
50 | id: compactRoot | 50 | id: compactRoot | ||
51 | 51 | | |||
52 | Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1 | 52 | Layout.minimumWidth: root.vertical || !inPanel ? units.iconSizeHints.panel : -1 | ||
53 | Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1 | 53 | Layout.minimumHeight: root.vertical || inPanel ? -1 : units.iconSizeHints.panel | ||
54 | Layout.maximumWidth: inPanel ? Math.min(parent.width, units.iconSizeHints.panel) * buttonIcon.aspectRatio : -1 | ||||
55 | Layout.maximumHeight: inPanel ? Math.min(parent.height, units.iconSizeHints.panel) * buttonIcon.aspectRatio : -1 | ||||
56 | | ||||
54 | hoverEnabled: true | 57 | hoverEnabled: true | ||
55 | onClicked: plasmoid.expanded = !plasmoid.expanded | 58 | onClicked: plasmoid.expanded = !plasmoid.expanded | ||
56 | 59 | | |||
57 | onWidthChanged: updateSizeHints() | 60 | onWidthChanged: updateSizeHints() | ||
58 | onHeightChanged: updateSizeHints() | 61 | onHeightChanged: updateSizeHints() | ||
59 | 62 | | |||
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 | | ||||
82 | DropArea { | 63 | DropArea { | ||
83 | id: compactDragArea | 64 | id: compactDragArea | ||
84 | anchors.fill: parent | 65 | anchors.fill: parent | ||
85 | } | 66 | } | ||
86 | 67 | | |||
87 | Timer { | 68 | Timer { | ||
88 | id: expandOnDragTimer | 69 | id: expandOnDragTimer | ||
89 | interval: 250 | 70 | interval: 250 | ||
90 | running: compactDragArea.containsDrag | 71 | running: compactDragArea.containsDrag | ||
91 | onTriggered: plasmoid.expanded = true | 72 | onTriggered: plasmoid.expanded = true | ||
92 | } | 73 | } | ||
93 | 74 | | |||
94 | PlasmaCore.IconItem { | 75 | PlasmaCore.IconItem { | ||
95 | id: buttonIcon | 76 | id: buttonIcon | ||
96 | 77 | | |||
97 | readonly property double aspectRatio: (vertical ? implicitHeight / implicitWidth | 78 | readonly property double aspectRatio: (vertical ? implicitHeight / implicitWidth | ||
98 | : implicitWidth / implicitHeight) | 79 | : implicitWidth / implicitHeight) | ||
99 | 80 | | |||
100 | anchors.fill: parent | 81 | anchors.fill: parent | ||
101 | source: plasmoid.icon | 82 | source: plasmoid.icon | ||
102 | active: parent.containsMouse || compactDragArea.containsDrag | 83 | active: parent.containsMouse || compactDragArea.containsDrag | ||
103 | smooth: true | 84 | smooth: true | ||
104 | roundToIconSize: aspectRatio === 1 | 85 | roundToIconSize: aspectRatio === 1 | ||
105 | | ||||
106 | onSourceChanged: updateSizeHints() | | |||
107 | } | 86 | } | ||
108 | } | 87 | } | ||
109 | 88 | | |||
110 | property Item dragSource: null | 89 | property Item dragSource: null | ||
111 | 90 | | |||
112 | Kicker.ProcessRunner { | 91 | Kicker.ProcessRunner { | ||
113 | id: processRunner; | 92 | id: processRunner; | ||
114 | } | 93 | } | ||
Show All 14 Lines |