mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-07 05:55:37 -05:00
weather auto location option
This commit is contained in:
@@ -25,6 +25,7 @@ Singleton {
|
|||||||
property string profileImage: ""
|
property string profileImage: ""
|
||||||
property string weatherLocation: "New York, NY"
|
property string weatherLocation: "New York, NY"
|
||||||
property string weatherCoordinates: "40.7128,-74.0060"
|
property string weatherCoordinates: "40.7128,-74.0060"
|
||||||
|
property bool useAutoLocation: false
|
||||||
property bool showLauncherButton: true
|
property bool showLauncherButton: true
|
||||||
property bool showWorkspaceSwitcher: true
|
property bool showWorkspaceSwitcher: true
|
||||||
property bool showFocusedWindow: true
|
property bool showFocusedWindow: true
|
||||||
@@ -149,6 +150,7 @@ Singleton {
|
|||||||
profileImage = settings.profileImage !== undefined ? settings.profileImage : "";
|
profileImage = settings.profileImage !== undefined ? settings.profileImage : "";
|
||||||
weatherLocation = settings.weatherLocation !== undefined ? settings.weatherLocation : "New York, NY";
|
weatherLocation = settings.weatherLocation !== undefined ? settings.weatherLocation : "New York, NY";
|
||||||
weatherCoordinates = settings.weatherCoordinates !== undefined ? settings.weatherCoordinates : "40.7128,-74.0060";
|
weatherCoordinates = settings.weatherCoordinates !== undefined ? settings.weatherCoordinates : "40.7128,-74.0060";
|
||||||
|
useAutoLocation = settings.useAutoLocation !== undefined ? settings.useAutoLocation : false;
|
||||||
showLauncherButton = settings.showLauncherButton !== undefined ? settings.showLauncherButton : true;
|
showLauncherButton = settings.showLauncherButton !== undefined ? settings.showLauncherButton : true;
|
||||||
showWorkspaceSwitcher = settings.showWorkspaceSwitcher !== undefined ? settings.showWorkspaceSwitcher : true;
|
showWorkspaceSwitcher = settings.showWorkspaceSwitcher !== undefined ? settings.showWorkspaceSwitcher : true;
|
||||||
showFocusedWindow = settings.showFocusedWindow !== undefined ? settings.showFocusedWindow : true;
|
showFocusedWindow = settings.showFocusedWindow !== undefined ? settings.showFocusedWindow : true;
|
||||||
@@ -230,6 +232,7 @@ Singleton {
|
|||||||
"profileImage": profileImage,
|
"profileImage": profileImage,
|
||||||
"weatherLocation": weatherLocation,
|
"weatherLocation": weatherLocation,
|
||||||
"weatherCoordinates": weatherCoordinates,
|
"weatherCoordinates": weatherCoordinates,
|
||||||
|
"useAutoLocation": useAutoLocation,
|
||||||
"showLauncherButton": showLauncherButton,
|
"showLauncherButton": showLauncherButton,
|
||||||
"showWorkspaceSwitcher": showWorkspaceSwitcher,
|
"showWorkspaceSwitcher": showWorkspaceSwitcher,
|
||||||
"showFocusedWindow": showFocusedWindow,
|
"showFocusedWindow": showFocusedWindow,
|
||||||
@@ -568,6 +571,11 @@ Singleton {
|
|||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setAutoLocation(enabled) {
|
||||||
|
useAutoLocation = enabled;
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
// Network preference setter
|
// Network preference setter
|
||||||
function setNetworkPreference(preference) {
|
function setNetworkPreference(preference) {
|
||||||
networkPreference = preference;
|
networkPreference = preference;
|
||||||
|
|||||||
@@ -111,9 +111,20 @@ ScrollView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DankToggle {
|
||||||
|
width: parent.width
|
||||||
|
text: "Auto Location"
|
||||||
|
description: "Allow wttr.in to determine location based on IP address"
|
||||||
|
checked: Prefs.useAutoLocation
|
||||||
|
onToggled: (checked) => {
|
||||||
|
return Prefs.setAutoLocation(checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingXS
|
||||||
|
visible: !Prefs.useAutoLocation
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: "Location"
|
text: "Location"
|
||||||
|
|||||||
@@ -92,9 +92,15 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getWeatherUrl() {
|
function getWeatherUrl() {
|
||||||
|
if (Prefs.useAutoLocation) {
|
||||||
|
const url = "wttr.in/?format=j1"
|
||||||
|
console.log("Using auto location, URL:", url)
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|
||||||
const location = Prefs.weatherCoordinates || "40.7128,-74.0060"
|
const location = Prefs.weatherCoordinates || "40.7128,-74.0060"
|
||||||
const url = `wttr.in/${encodeURIComponent(location)}?format=j1`
|
const url = `wttr.in/${encodeURIComponent(location)}?format=j1`
|
||||||
console.log("Using location:", location, "URL:", url)
|
console.log("Using manual location:", location, "URL:", url)
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,5 +316,25 @@ Singleton {
|
|||||||
const currentWeather = Object.assign({}, root.weather)
|
const currentWeather = Object.assign({}, root.weather)
|
||||||
root.weather = currentWeather
|
root.weather = currentWeather
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Prefs.useAutoLocationChanged.connect(() => {
|
||||||
|
console.log("Auto location setting changed, force refreshing weather")
|
||||||
|
root.weather = {
|
||||||
|
available: false,
|
||||||
|
loading: true,
|
||||||
|
temp: 0,
|
||||||
|
tempF: 0,
|
||||||
|
city: "",
|
||||||
|
wCode: "113",
|
||||||
|
humidity: 0,
|
||||||
|
wind: "",
|
||||||
|
sunrise: "06:00",
|
||||||
|
sunset: "18:00",
|
||||||
|
uv: 0,
|
||||||
|
pressure: 0
|
||||||
|
}
|
||||||
|
root.lastFetchTime = 0
|
||||||
|
root.forceRefresh()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user