-
Notifications
You must be signed in to change notification settings - Fork 34
/
LauncherIcon.qml
101 lines (86 loc) · 2.46 KB
/
LauncherIcon.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import QtQuick
import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore
import org.kde.draganddrop as DragAndDrop
import org.kde.kirigami as Kirigami
import org.kde.plasma.plasmoid
MouseArea {
id: launcherIcon
readonly property bool inPanel: (plasmoid.location == PlasmaCore.Types.TopEdge
|| plasmoid.location == PlasmaCore.Types.RightEdge
|| plasmoid.location == PlasmaCore.Types.BottomEdge
|| plasmoid.location == PlasmaCore.Types.LeftEdge)
Layout.minimumWidth: {
switch (plasmoid.formFactor) {
case PlasmaCore.Types.Vertical:
return 0
case PlasmaCore.Types.Horizontal:
return height
default:
return Kirigami.Units.gridUnit * 3
}
}
Layout.minimumHeight: {
switch (plasmoid.formFactor) {
case PlasmaCore.Types.Vertical:
return width
case PlasmaCore.Types.Horizontal:
return 0
default:
return Kirigami.Units.gridUnit * 3
}
}
readonly property int maxSize: Math.max(width, height)
property int size: {
if (inPanel) {
if (plasmoid.configuration.fixedPanelIcon) {
// Was PlasmaCore.Units.iconSizeHints.panel in Plasma5
// In Plasma6 https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1390/diffs
return 48 // Kickoff uses this hardcoded number
} else {
return maxSize
}
} else {
return -1
}
}
Layout.maximumWidth: size
Layout.maximumHeight: size
property int iconSize: Math.min(width, height)
property alias iconSource: icon.source
Kirigami.Icon {
id: icon
anchors.centerIn: parent
source: "start-here-kde-symbolic"
width: launcherIcon.iconSize
height: launcherIcon.iconSize
active: launcherIcon.containsMouse && !justOpenedTimer.running
smooth: true
}
// Debugging
// Rectangle { anchors.fill: parent; border.color: "#ff0"; color: "transparent"; border.width: 1; }
// Rectangle { anchors.fill: icon; border.color: "#f00"; color: "transparent"; border.width: 1; }
Accessible.name: Plasmoid.title
Accessible.role: Accessible.Button
hoverEnabled: true
// cursorShape: Qt.PointingHandCursor
property bool wasExpanded
onPressed: wasExpanded = widget.expanded
onClicked: widget.expanded = !wasExpanded
property alias activateOnDrag: dropArea.enabled
DragAndDrop.DropArea {
id: dropArea
anchors.fill: parent
}
onContainsMouseChanged: {
if (!containsMouse) {
dragHoverTimer.stop()
}
}
Timer {
id: dragHoverTimer
interval: 250 // Same as taskmanager's activationTimer in MouseHandler.qml
running: dropArea.containsDrag
onTriggered: widget.expanded = true
}
}