mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-07 05:55:37 -05:00
weather: general improvements to setting
This commit is contained in:
@@ -22,8 +22,8 @@ Singleton {
|
|||||||
property bool useFahrenheit: false
|
property bool useFahrenheit: false
|
||||||
property bool nightModeEnabled: false
|
property bool nightModeEnabled: false
|
||||||
property string profileImage: ""
|
property string profileImage: ""
|
||||||
property string weatherLocationOverride: "New York, NY"
|
property string weatherLocation: "New York, NY"
|
||||||
property bool weatherLocationOverrideEnabled: false
|
property string weatherCoordinates: "40.7128,-74.0060"
|
||||||
property bool showFocusedWindow: true
|
property bool showFocusedWindow: true
|
||||||
property bool showWeather: true
|
property bool showWeather: true
|
||||||
property bool showMusic: true
|
property bool showMusic: true
|
||||||
@@ -105,8 +105,8 @@ Singleton {
|
|||||||
useFahrenheit = settings.useFahrenheit !== undefined ? settings.useFahrenheit : false;
|
useFahrenheit = settings.useFahrenheit !== undefined ? settings.useFahrenheit : false;
|
||||||
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false;
|
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false;
|
||||||
profileImage = settings.profileImage !== undefined ? settings.profileImage : "";
|
profileImage = settings.profileImage !== undefined ? settings.profileImage : "";
|
||||||
weatherLocationOverride = settings.weatherLocationOverride !== undefined ? settings.weatherLocationOverride : "New York, NY";
|
weatherLocation = settings.weatherLocation !== undefined ? settings.weatherLocation : "New York, NY";
|
||||||
weatherLocationOverrideEnabled = settings.weatherLocationOverrideEnabled !== undefined ? settings.weatherLocationOverrideEnabled : false;
|
weatherCoordinates = settings.weatherCoordinates !== undefined ? settings.weatherCoordinates : "40.7128,-74.0060";
|
||||||
showFocusedWindow = settings.showFocusedWindow !== undefined ? settings.showFocusedWindow : true;
|
showFocusedWindow = settings.showFocusedWindow !== undefined ? settings.showFocusedWindow : true;
|
||||||
showWeather = settings.showWeather !== undefined ? settings.showWeather : true;
|
showWeather = settings.showWeather !== undefined ? settings.showWeather : true;
|
||||||
showMusic = settings.showMusic !== undefined ? settings.showMusic : true;
|
showMusic = settings.showMusic !== undefined ? settings.showMusic : true;
|
||||||
@@ -157,8 +157,8 @@ Singleton {
|
|||||||
"useFahrenheit": useFahrenheit,
|
"useFahrenheit": useFahrenheit,
|
||||||
"nightModeEnabled": nightModeEnabled,
|
"nightModeEnabled": nightModeEnabled,
|
||||||
"profileImage": profileImage,
|
"profileImage": profileImage,
|
||||||
"weatherLocationOverride": weatherLocationOverride,
|
"weatherLocation": weatherLocation,
|
||||||
"weatherLocationOverrideEnabled": weatherLocationOverrideEnabled,
|
"weatherCoordinates": weatherCoordinates,
|
||||||
"showFocusedWindow": showFocusedWindow,
|
"showFocusedWindow": showFocusedWindow,
|
||||||
"showWeather": showWeather,
|
"showWeather": showWeather,
|
||||||
"showMusic": showMusic,
|
"showMusic": showMusic,
|
||||||
@@ -372,14 +372,10 @@ Singleton {
|
|||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Weather location override setter
|
// Weather location setter
|
||||||
function setWeatherLocationOverride(location) {
|
function setWeatherLocation(displayName, coordinates) {
|
||||||
weatherLocationOverride = location;
|
weatherLocation = displayName;
|
||||||
saveSettings();
|
weatherCoordinates = coordinates;
|
||||||
}
|
|
||||||
|
|
||||||
function setWeatherLocationOverrideEnabled(enabled) {
|
|
||||||
weatherLocationOverrideEnabled = enabled;
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,22 +114,9 @@ ScrollView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DankToggle {
|
|
||||||
width: parent.width
|
|
||||||
text: "Override Location"
|
|
||||||
description: "Use a specific location instead of auto-detection"
|
|
||||||
checked: Prefs.weatherLocationOverrideEnabled
|
|
||||||
onToggled: (checked) => {
|
|
||||||
return Prefs.setWeatherLocationOverrideEnabled(checked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Location input - only visible when override is enabled
|
|
||||||
Column {
|
Column {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingXS
|
||||||
visible: Prefs.weatherLocationOverrideEnabled
|
|
||||||
opacity: visible ? 1 : 0
|
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: "Location"
|
text: "Location"
|
||||||
@@ -140,29 +127,12 @@ ScrollView {
|
|||||||
|
|
||||||
DankLocationSearch {
|
DankLocationSearch {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
currentLocation: Prefs.weatherLocationOverride
|
currentLocation: Prefs.weatherLocation
|
||||||
placeholderText: "Search for a location..."
|
placeholderText: "New York, NY"
|
||||||
onLocationSelected: (displayName, coordinates) => {
|
onLocationSelected: (displayName, coordinates) => {
|
||||||
Prefs.setWeatherLocationOverride(coordinates);
|
Prefs.setWeatherLocation(displayName, coordinates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: "Examples: \"New York\", \"Tokyo\", \"90210\""
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceVariantText
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
width: parent.width
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Theme.mediumDuration
|
|
||||||
easing.type: Theme.emphasizedEasing
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getWeatherUrl() {
|
function getWeatherUrl() {
|
||||||
const location = Prefs.weatherLocationOverride || "New York, NY"
|
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 location:", location, "URL:", url)
|
||||||
return url
|
return url
|
||||||
@@ -269,10 +269,30 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// Watch for preference changes to refetch weather
|
Prefs.weatherCoordinatesChanged.connect(() => {
|
||||||
Prefs.weatherLocationOverrideChanged.connect(() => {
|
|
||||||
console.log("Weather location changed, force refreshing weather")
|
console.log("Weather location changed, force refreshing weather")
|
||||||
Qt.callLater(root.forceRefresh)
|
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()
|
||||||
|
})
|
||||||
|
|
||||||
|
Prefs.weatherLocationChanged.connect(() => {
|
||||||
|
console.log("Weather location display name changed")
|
||||||
|
const currentWeather = Object.assign({}, root.weather)
|
||||||
|
root.weather = currentWeather
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user