70 lines
1.5 KiB
QML
70 lines
1.5 KiB
QML
import QtQuick
|
||
import Quickshell
|
||
import qs.Ui
|
||
|
||
BarWidget {
|
||
id: root
|
||
moduleName: "local.omarchy-citizen"
|
||
|
||
readonly property bool opened: panelLoader.item
|
||
? panelLoader.item.opened === true
|
||
: false
|
||
|
||
readonly property bool popoutSwitchClosing: panelLoader.item
|
||
? panelLoader.item.popoutSwitchClosing === true
|
||
: false
|
||
|
||
function open() {
|
||
if (panelLoader.item) panelLoader.item.open()
|
||
}
|
||
|
||
function close() {
|
||
if (panelLoader.item) panelLoader.item.close()
|
||
}
|
||
|
||
function toggle() {
|
||
if (panelLoader.item) panelLoader.item.toggle()
|
||
}
|
||
|
||
function closeForPopoutSwitch() {
|
||
if (panelLoader.item) panelLoader.item.closeForPopoutSwitch()
|
||
}
|
||
|
||
function injectPanel() {
|
||
if (!panelLoader.item) return
|
||
panelLoader.item.bar = root.bar
|
||
panelLoader.item.anchorItem = button
|
||
panelLoader.item.hostWidget = root
|
||
}
|
||
|
||
implicitWidth: button.implicitWidth
|
||
implicitHeight: button.implicitHeight
|
||
|
||
onBarChanged: injectPanel()
|
||
|
||
Loader {
|
||
id: panelLoader
|
||
active: true
|
||
source: Qt.resolvedUrl("Panel.qml")
|
||
visible: false
|
||
|
||
onLoaded: {
|
||
root.injectPanel()
|
||
Qt.callLater(root.injectPanel)
|
||
}
|
||
}
|
||
|
||
WidgetButton {
|
||
id: button
|
||
anchors.fill: parent
|
||
bar: root.bar
|
||
text: "✦SC"
|
||
tooltipText: "Omarchy Citizen – Plug & Play Star Citizen"
|
||
onPressed: function(buttonCode) {
|
||
if (buttonCode === Qt.LeftButton) root.toggle()
|
||
else if (buttonCode === Qt.RightButton && root.bar)
|
||
root.bar.run("xdg-open https://wiki.starcitizen-lug.org")
|
||
}
|
||
}
|
||
}
|