1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-01 19:18:28 -04:00

location: prevent calls when weather auto-locate is disabled

port 1.5

(cherry picked from commit fe561f2b5d)
This commit is contained in:
bbedward
2026-07-21 23:34:12 -04:00
committed by dms-ci[bot]
parent accdd0972c
commit 23daca0b57
2 changed files with 40 additions and 8 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ Singleton {
property bool screensaverInhibited: false property bool screensaverInhibited: false
property var screensaverInhibitors: [] property var screensaverInhibitors: []
property var activeSubscriptions: ["network", "network.credentials", "loginctl", "freedesktop", "freedesktop.screensaver", "gamma", "theme.auto", "wallpaper", "bluetooth", "bluetooth.pairing", "brightness", "wlroutput", "evdev", "browser", "dbus", "clipboard", "location", "sysupdate"] property var activeSubscriptions: ["network", "network.credentials", "loginctl", "freedesktop", "freedesktop.screensaver", "gamma", "theme.auto", "wallpaper", "bluetooth", "bluetooth.pairing", "brightness", "wlroutput", "evdev", "browser", "dbus", "clipboard", "sysupdate"]
Component.onCompleted: { Component.onCompleted: {
if (socketPath && socketPath.length > 0) { if (socketPath && socketPath.length > 0) {
+39 -7
View File
@@ -3,10 +3,13 @@ pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import Quickshell import Quickshell
import qs.Common
import qs.Services
Singleton { Singleton {
id: root id: root
readonly property bool wantsLocation: SettingsData.weatherEnabled && SettingsData.useAutoLocation
readonly property bool locationAvailable: DMSService.isConnected && DMSService.capabilities.includes("location") readonly property bool locationAvailable: DMSService.isConnected && DMSService.capabilities.includes("location")
readonly property bool valid: latitude !== 0 || longitude !== 0 readonly property bool valid: latitude !== 0 || longitude !== 0
@@ -15,19 +18,46 @@ Singleton {
signal locationChanged(var data) signal locationChanged(var data)
onLocationAvailableChanged: { onWantsLocationChanged: {
if (locationAvailable && !valid) if (wantsLocation) {
getState(); ensureSubscription();
} else if (DMSService.activeSubscriptions.includes("location")) {
DMSService.removeSubscription("location");
}
} }
onLocationAvailableChanged: ensureSubscription()
Component.onCompleted: ensureSubscription()
Connections { Connections {
target: DMSService target: DMSService
function onLocationStateUpdate(data) { function onConnectionStateChanged() {
if (!locationAvailable) if (DMSService.isConnected)
return; root.ensureSubscription();
handleStateUpdate(data);
} }
function onLocationStateUpdate(data) {
if (!root.wantsLocation)
return;
root.handleStateUpdate(data);
}
}
function ensureSubscription() {
if (!wantsLocation)
return;
if (!locationAvailable)
return;
if (DMSService.activeSubscriptions.includes("location"))
return;
if (DMSService.activeSubscriptions.includes("all"))
return;
DMSService.addSubscription("location");
if (!valid)
getState();
} }
function handleStateUpdate(data) { function handleStateUpdate(data) {
@@ -42,6 +72,8 @@ Singleton {
} }
function getState() { function getState() {
if (!wantsLocation)
return;
if (!locationAvailable) if (!locationAvailable)
return; return;