Weather: change how default city is set

This commit is contained in:
Ly-sec 2025-09-03 13:50:16 +02:00
parent c6e56d4264
commit 40b57c2df0
4 changed files with 12 additions and 12 deletions

View file

@ -16,11 +16,16 @@ ColumnLayout {
NTextInput {
label: "Location name"
description: "Choose a known location near you."
text: Settings.data.location.name || "Tokyo"
text: Settings.data.location.name || Settings.defaultLocation
placeholderText: "Enter the location name"
onEditingFinished: {
// Verify the location has really changed to avoid extra resets
var newLocation = text.trim()
// If empty, set to default location
if (newLocation === "") {
newLocation = Settings.defaultLocation
text = Settings.defaultLocation // Update the input field to show the default
}
if (newLocation != Settings.data.location.name) {
Settings.data.location.name = newLocation
LocationService.resetWeather()

View file

@ -37,10 +37,8 @@ NBox {
spacing: Style.marginXXS * scaling
NText {
text: {
// Use the location name or fallback to default if empty
const locationName = Settings.data.location.name || "Tokyo"
// Ensure the name is not too long if one had to specify the country
const chunks = locationName.split(",")
const chunks = Settings.data.location.name.split(",")
return chunks[0]
}
font.pointSize: Style.fontSizeL * scaling