Repository navigation
Expand file tree
/
Copy pathBarWidget.qml
More file actions
67 lines (56 loc) · 1.74 KB
/
Copy pathBarWidget.qml
File metadata and controls
67 lines (56 loc) · 1.74 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
import QtQuick
import qs.Commons
import qs.Ui
// Third-party plugins can't patch core files (e.g. Clock.qml), so unlike
// an earlier version of this plugin, this widget owns its own bar icon
// and opens the panel itself — the same pattern weather/tailscale use.
BarWidget {
id: root
moduleName: "ssh.calendar"
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
}
// Shape contract for shell.summon/hide/toggle routing (Bar.findPanelWidget
// requires open/close/opened on the bar-widget root).
readonly property bool opened: panelLoader.item ? panelLoader.item.opened === true : false
function open() {
if (panelLoader.item && panelLoader.item.openFromHotkey) panelLoader.item.openFromHotkey()
}
function close() {
if (panelLoader.item && panelLoader.item.close) panelLoader.item.close()
}
function togglePanel() {
if (panelLoader.item && panelLoader.item.toggle) panelLoader.item.toggle()
}
implicitWidth: button.implicitWidth
implicitHeight: button.implicitHeight
onBarChanged: injectPanel()
onSettingsChanged: injectPanel()
Loader {
id: panelLoader
active: true
source: Qt.resolvedUrl("Panel.qml")
visible: false
onLoaded: {
root.injectPanel()
Qt.callLater(root.injectPanel)
}
}
BarIconButton {
id: button
anchors.fill: parent
bar: root.bar
text: "\uf133" // nf-fa-calendar
slotSize: Style.bar.statusSlot
active: root.opened
tooltipText: "Calendar"
onPressed: function(b) {
if (!root.bar) return
root.togglePanel()
}
}
}