1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-30 09:32:05 -04:00
Files
DankMaterialShell/quickshell/Services/LocationService.qml
bbedward f76724f7cd logger: add a dedicated QML logging Singleton
- adds log.info/error/debug/warn/fatal
- adds ability to write logs to any file
- add CLI options in addition to env to set log levels
2026-04-29 15:42:30 -04:00

54 lines
1.2 KiB
QML

pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
Singleton {
id: root
readonly property bool locationAvailable: DMSService.isConnected && (DMSService.capabilities.length === 0 || DMSService.capabilities.includes("location"))
readonly property bool valid: latitude !== 0 || longitude !== 0
property var latitude: 0.0
property var longitude: 0.0
signal locationChanged(var data)
onLocationAvailableChanged: {
if (locationAvailable && !valid)
getState();
}
Connections {
target: DMSService
function onLocationStateUpdate(data) {
if (!locationAvailable)
return;
handleStateUpdate(data);
}
}
function handleStateUpdate(data) {
const lat = data.latitude;
const lon = data.longitude;
if (lat === 0 && lon === 0)
return;
root.latitude = lat;
root.longitude = lon;
root.locationChanged(data);
}
function getState() {
if (!locationAvailable)
return;
DMSService.sendRequest("location.getState", null, response => {
if (response.result)
handleStateUpdate(response.result);
});
}
}