diff --git a/Modules/SettingsPanel/Tabs/AboutTab.qml b/Modules/SettingsPanel/Tabs/AboutTab.qml index 68aa555..a4cb10e 100644 --- a/Modules/SettingsPanel/Tabs/AboutTab.qml +++ b/Modules/SettingsPanel/Tabs/AboutTab.qml @@ -12,31 +12,9 @@ ColumnLayout { id: root property string latestVersion: GitHubService.latestVersion - property string currentVersion: "Unknown" // Fallback version + property string currentVersion: UpdateService.currentVersion property var contributors: GitHubService.contributors - Process { - id: currentVersionProcess - - command: ["sh", "-c", "cd " + Quickshell.shellDir + " && git describe --tags --abbrev=0 2>/dev/null || echo 'Unknown'"] - Component.onCompleted: { - running = true - } - - stdout: StdioCollector { - onStreamFinished: { - const version = text.trim() - if (version && version !== "Unknown") { - root.currentVersion = version - } else { - currentVersionProcess.command = ["sh", "-c", "cd " + Quickshell.shellDir - + " && cat package.json 2>/dev/null | grep '\"version\"' | cut -d'\"' -f4 || echo 'Unknown'"] - currentVersionProcess.running = true - } - } - } - } - NText { text: "Noctalia Shell" font.pointSize: Style.fontSizeXXXL * scaling @@ -89,7 +67,7 @@ ColumnLayout { border.color: Color.mPrimary border.width: Math.max(1, Style.borderS * scaling) visible: { - if (root.currentVersion === "Unknown" || root.latestVersion === "Unknown") + if (root.latestVersion === "Unknown") return false const latest = root.latestVersion.replace("v", "").split(".") diff --git a/Modules/SettingsPanel/Tabs/TimeWeatherTab.qml b/Modules/SettingsPanel/Tabs/TimeWeatherTab.qml index 4bf1b2c..bcf577c 100644 --- a/Modules/SettingsPanel/Tabs/TimeWeatherTab.qml +++ b/Modules/SettingsPanel/Tabs/TimeWeatherTab.qml @@ -16,7 +16,7 @@ ColumnLayout { NTextInput { label: "Location name" description: "Choose a known location near you." - text: Settings.data.location.name + text: Settings.data.location.name || "Tokyo" placeholderText: "Enter the location name" onEditingFinished: { // Verify the location has really changed to avoid extra resets diff --git a/Modules/SidePanel/Cards/WeatherCard.qml b/Modules/SidePanel/Cards/WeatherCard.qml index 3751478..03df3b3 100644 --- a/Modules/SidePanel/Cards/WeatherCard.qml +++ b/Modules/SidePanel/Cards/WeatherCard.qml @@ -37,8 +37,10 @@ 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 = Settings.data.location.name.split(",") + const chunks = locationName.split(",") return chunks[0] } font.pointSize: Style.fontSizeL * scaling diff --git a/Services/LocationService.qml b/Services/LocationService.qml index cfea5d7..e5858fa 100644 --- a/Services/LocationService.qml +++ b/Services/LocationService.qml @@ -136,13 +136,17 @@ Singleton { Logger.log("Location", "Location changed from", adapter.name, "to", Settings.data.location.name) } + // Ensure we always have a location name, fallback to default if empty + const locationName = Settings.data.location.name && Settings.data.location.name.trim( + ) !== "" ? Settings.data.location.name : "Tokyo" + if ((adapter.latitude === "") || (adapter.longitude === "") || locationChanged) { - _geocodeLocation(Settings.data.location.name, function (latitude, longitude, name, country) { - Logger.log("Location", "Geocoded", Settings.data.location.name, "to:", latitude, "/", longitude) + _geocodeLocation(locationName, function (latitude, longitude, name, country) { + Logger.log("Location", "Geocoded", locationName, "to:", latitude, "/", longitude) // Save location name - adapter.name = Settings.data.location.name + adapter.name = locationName // Save GPS coordinates adapter.latitude = latitude.toString() diff --git a/Services/UpdateService.qml b/Services/UpdateService.qml new file mode 100644 index 0000000..685bfae --- /dev/null +++ b/Services/UpdateService.qml @@ -0,0 +1,30 @@ +pragma Singleton + +import QtQuick +import Quickshell +import qs.Commons + +Singleton { + id: root + + // Public properties + property string baseVersion: "v2.4.1" + property bool isRelease: false + + property string currentVersion: isRelease ? baseVersion : baseVersion + "-dev" + + // Internal helpers + function getVersion() { + return root.currentVersion + } + + function checkForUpdates() { + // TODO: Implement update checking logic + Logger.log("UpdateService", "Checking for updates...") + } + + function init() { + // Ensure the singleton is created + Logger.log("UpdateService", "Version:", root.currentVersion) + } +} diff --git a/shell.qml b/shell.qml index 1e0f9ba..17050ee 100644 --- a/shell.qml +++ b/shell.qml @@ -107,6 +107,9 @@ ShellRoot { // Ensure our location singleton is created as soon as possible so we start fetching weather asap LocationService.init() + // Initialize UpdateService + UpdateService.init() + // Kickoff NightLight service NightLightService.apply() }