Weather wraps its panel in a BarWidget that only exposed togglePanel(), so it couldn't ride the new shell-routed hotkey path and was left on the stale-prone per-plugin target. Expose open/close/opened on the wrapper (open maps to the panel's hotkey path so the center hover reveal stays suppressed) and switch omarchy-notification-weather to the new syntax. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
78 lines
2.3 KiB
QML
78 lines
2.3 KiB
QML
import QtQuick
|
|
import qs.Commons
|
|
import qs.Ui
|
|
|
|
BarWidget {
|
|
id: root
|
|
moduleName: "omarchy.weather"
|
|
|
|
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
|
|
}
|
|
|
|
function refresh() {
|
|
if (panelLoader.item && panelLoader.item.refresh) panelLoader.item.refresh()
|
|
}
|
|
|
|
function togglePanel() {
|
|
if (panelLoader.item && panelLoader.item.toggle) panelLoader.item.toggle()
|
|
}
|
|
|
|
// Shape contract for shell.summon/hide/toggle routing (Bar.findPanelWidget
|
|
// requires open/close/opened on the bar-widget root). Open maps to the
|
|
// panel's hotkey path so summoning suppresses the center hover reveal,
|
|
// matching what the old per-plugin IpcHandler did.
|
|
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()
|
|
}
|
|
|
|
visible: panelLoader.item && panelLoader.item.label !== ""
|
|
implicitWidth: bar && bar.vertical ? button.implicitWidth : button.implicitWidth + Style.spacing.labelGap
|
|
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)
|
|
}
|
|
}
|
|
|
|
WidgetButton {
|
|
id: button
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
x: bar && bar.vertical ? Math.round((parent.width - width) / 2) : 0
|
|
width: implicitWidth
|
|
height: implicitHeight
|
|
bar: root.bar
|
|
text: panelLoader.item ? panelLoader.item.label : ""
|
|
active: panelLoader.item && panelLoader.item.klass === "active"
|
|
horizontalMargin: 2.5
|
|
// Tooltip suppressed because the panel is the detail view.
|
|
tooltipText: ""
|
|
|
|
onPressed: function(b) {
|
|
if (!root.bar) return
|
|
if (b === Qt.RightButton) root.bar.run("omarchy-notification-send \"$(omarchy-weather-status)\"")
|
|
else if (b === Qt.MiddleButton) root.refresh()
|
|
else root.togglePanel()
|
|
}
|
|
}
|
|
}
|