add WeatherService, WeatherApplet with hover panel and lock screen widget

This commit is contained in:
Damocles 2026-04-22 22:06:58 +02:00
parent 6f385130ff
commit 9285365732
8 changed files with 150 additions and 26 deletions

View file

@ -1,41 +1,53 @@
import QtQuick
import Quickshell.Io
import Quickshell
import "." as M
import "../services" as S
import "../applets" as C
M.BarSection {
id: root
spacing: S.Theme.moduleSpacing
tooltip: root.weatherTooltip
tooltip: ""
visible: S.Modules.weather.enable && S.WeatherService.available
property string weatherTooltip: ""
property bool _pinned: false
readonly property bool _anyHover: root._hovered || hoverPanel.panelHovered
readonly property bool _showPanel: _anyHover || _pinned
Process {
id: proc
running: true
command: ["wttrbar"].concat(S.Modules.weather.args)
stdout: StdioCollector {
onStreamFinished: {
try {
const data = JSON.parse(text);
label.icon = data.text ?? "";
root.weatherTooltip = data.tooltip ?? "";
} catch (e) {
label.icon = "";
root.weatherTooltip = "";
}
}
}
on_AnyHoverChanged: {
if (_anyHover)
_unpinTimer.stop();
else if (_pinned)
_unpinTimer.start();
}
Timer {
interval: S.Modules.weather.interval || 3600000
running: true
repeat: true
onTriggered: proc.running = true
id: _unpinTimer
interval: 500
onTriggered: root._pinned = false
}
M.BarIcon {
id: label
icon: S.WeatherService.icon
anchors.verticalCenter: parent.verticalCenter
TapHandler {
onTapped: root._pinned = !root._pinned
}
}
M.HoverPanel {
id: hoverPanel
showPanel: root._showPanel
screen: QsWindow.window?.screen ?? null
anchorItem: root
accentColor: root.accentColor
panelNamespace: "nova-weather"
panelTitle: "Weather"
contentWidth: 280
C.WeatherApplet {
width: hoverPanel.contentWidth
accentColor: root.accentColor
}
}
}