Add default fallback city (fixes #199), add beginning of UpdateService
Weather: always fallback to "Tokyo" if the city name is empty UpdateService: simple versioning control
This commit is contained in:
parent
7141a91994
commit
c6e56d4264
6 changed files with 46 additions and 29 deletions
|
|
@ -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(".")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
30
Services/UpdateService.qml
Normal file
30
Services/UpdateService.qml
Normal file
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue