Repository navigation
Expand file tree
/
Copy pathBarWidget.qml
More file actions
112 lines (96 loc) · 3.47 KB
/
Copy pathBarWidget.qml
File metadata and controls
112 lines (96 loc) · 3.47 KB
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
102
103
104
105
106
107
108
109
110
111
112
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Commons
import qs.Ui
BarWidget {
id: root
moduleName: "dkfiander.disparchy"
readonly property bool opened: panelLoader.item ? panelLoader.item.opened === true : false
readonly property int inFlight: panelLoader.item ? Number(panelLoader.item.inFlight || 0) : 0
readonly property bool popoutSwitchClosing: panelLoader.item ? panelLoader.item.popoutSwitchClosing === true : false
readonly property real openPanelIndicatorWidth: button.implicitWidth
readonly property real openPanelIndicatorHeight: Math.max(Style.space(10), Math.round(Style.bar.iconSlot * 0.55))
implicitWidth: button.implicitWidth
implicitHeight: button.implicitHeight
function open() {
if (panelLoader.item) panelLoader.item.open()
}
function close() {
if (panelLoader.item) panelLoader.item.close()
}
function togglePanel() {
if (panelLoader.item) panelLoader.item.toggle()
}
function closeForPopoutSwitch() {
if (panelLoader.item) panelLoader.item.closeForPopoutSwitch()
}
function injectPanel() {
var target = panelLoader.item
if (!target) return
if ("bar" in target) target.bar = root.bar
if ("settings" in target) target.settings = root.settings
if ("anchorItem" in target) target.anchorItem = button
if ("hostWidget" in target) target.hostWidget = root
}
onBarChanged: injectPanel()
onSettingsChanged: injectPanel()
Loader {
id: panelLoader
active: true
source: Qt.resolvedUrl("Panel.qml")
visible: false
onLoaded: {
root.injectPanel()
Qt.callLater(root.injectPanel)
}
}
IpcHandler {
target: "dkfiander.disparchy"
function open(): void { root.open() }
function close(): void { root.close() }
function show(): void { root.open() }
function hide(): void { root.close() }
function toggle(): void { root.togglePanel() }
function setup(): void { if (panelLoader.item) panelLoader.item.showSetup() }
function history(): void { if (panelLoader.item) panelLoader.item.showHistory() }
}
WidgetButton {
id: button
anchors.fill: parent
bar: root.bar
labelVisible: false
hasVisualContent: true
fixedWidth: Style.bar.iconSlot + Style.space(10)
tooltipText: root.inFlight > 0
? ("Disparchy · " + root.inFlight + " in flight")
: "Disparchy"
onPressed: root.togglePanel()
DisparchyIcon {
anchors.centerIn: parent
iconSize: Style.space(16)
color: root.inFlight > 0 ? Color.accent : Color.popups.text
busy: root.inFlight > 0
}
}
Rectangle {
visible: root.inFlight > 0
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin: Style.space(1)
anchors.topMargin: Style.space(1)
width: badge.implicitWidth + Style.space(6)
height: badge.implicitHeight + Style.space(2)
radius: Math.max(2, Style.cornerRadius)
color: Color.accent
Text {
id: badge
anchors.centerIn: parent
textFormat: Text.PlainText
text: String(root.inFlight)
color: Color.background
font.family: root.bar ? root.bar.fontFamily : Style.font.family
font.pixelSize: Style.font.caption
}
}
}