mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-03 20:32:07 -04:00
* feat: switch auto location in weather widget to use GeoClue2 instead of simple IP check * nix: enable GeoClue2 service by default * lint: fix line endings * fix: fall back to IP location if GeoClue is not available
52 lines
1.1 KiB
QML
52 lines
1.1 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import qs.Common
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
readonly property bool locationAvailable: DMSService.isConnected && (DMSService.capabilities.length === 0 || DMSService.capabilities.includes("location"))
|
|
|
|
property var latitude: 0.0
|
|
property var longitude: 0.0
|
|
|
|
signal locationChanged(var data)
|
|
|
|
Component.onCompleted: {
|
|
console.info("LocationService: Initializing...");
|
|
getState();
|
|
}
|
|
|
|
Connections {
|
|
target: DMSService
|
|
|
|
function onLocationStateUpdate(data) {
|
|
if (locationAvailable) {
|
|
handleStateUpdate(data);
|
|
}
|
|
}
|
|
}
|
|
|
|
function handleStateUpdate(data) {
|
|
root.latitude = data.latitude;
|
|
root.longitude = data.longitude;
|
|
|
|
root.locationChanged(data)
|
|
}
|
|
|
|
function getState() {
|
|
if (!locationAvailable)
|
|
return;
|
|
|
|
DMSService.sendRequest("location.getState", null, response => {
|
|
if (response.result) {
|
|
handleStateUpdate(response.result);
|
|
}
|
|
});
|
|
}
|
|
}
|