mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
add disable weather option
This commit is contained in:
@@ -77,6 +77,7 @@ Singleton {
|
||||
property string wallpaperLastPath: ""
|
||||
property string profileLastPath: ""
|
||||
property bool doNotDisturb: false
|
||||
property bool weatherEnabled: true
|
||||
property string fontFamily: "Inter Variable"
|
||||
property string monoFontFamily: "Fira Code"
|
||||
property int fontWeight: Font.Normal
|
||||
@@ -149,6 +150,7 @@ Singleton {
|
||||
weatherLocation = settings.weatherLocation !== undefined ? settings.weatherLocation : "New York, NY";
|
||||
weatherCoordinates = settings.weatherCoordinates !== undefined ? settings.weatherCoordinates : "40.7128,-74.0060";
|
||||
useAutoLocation = settings.useAutoLocation !== undefined ? settings.useAutoLocation : false;
|
||||
weatherEnabled = settings.weatherEnabled !== undefined ? settings.weatherEnabled : true;
|
||||
showLauncherButton = settings.showLauncherButton !== undefined ? settings.showLauncherButton : true;
|
||||
showWorkspaceSwitcher = settings.showWorkspaceSwitcher !== undefined ? settings.showWorkspaceSwitcher : true;
|
||||
showFocusedWindow = settings.showFocusedWindow !== undefined ? settings.showFocusedWindow : true;
|
||||
@@ -230,6 +232,7 @@ Singleton {
|
||||
"weatherLocation": weatherLocation,
|
||||
"weatherCoordinates": weatherCoordinates,
|
||||
"useAutoLocation": useAutoLocation,
|
||||
"weatherEnabled": weatherEnabled,
|
||||
"showLauncherButton": showLauncherButton,
|
||||
"showWorkspaceSwitcher": showWorkspaceSwitcher,
|
||||
"showFocusedWindow": showFocusedWindow,
|
||||
@@ -569,6 +572,11 @@ Singleton {
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function setWeatherEnabled(enabled) {
|
||||
weatherEnabled = enabled;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
// Network preference setter
|
||||
function setNetworkPreference(preference) {
|
||||
networkPreference = preference;
|
||||
|
||||
@@ -200,7 +200,7 @@ PanelWindow {
|
||||
width: parent.width
|
||||
height: {
|
||||
let widgetHeight = 160; // Media widget
|
||||
widgetHeight += 140 + Theme.spacingM; // Weather widget with spacing
|
||||
widgetHeight += 140 + Theme.spacingM; // Weather/SystemInfo widget with spacing
|
||||
let calendarHeight = 300; // Calendar
|
||||
return Math.max(widgetHeight, calendarHeight);
|
||||
}
|
||||
@@ -225,6 +225,13 @@ PanelWindow {
|
||||
Weather {
|
||||
width: parent.width
|
||||
height: 140
|
||||
visible: Prefs.weatherEnabled
|
||||
}
|
||||
|
||||
SystemInfo {
|
||||
width: parent.width
|
||||
height: 140
|
||||
visible: !Prefs.weatherEnabled
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
136
Modules/CentcomCenter/SystemInfo.qml
Normal file
136
Modules/CentcomCenter/SystemInfo.qml
Normal file
@@ -0,0 +1,136 @@
|
||||
import QtQuick
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
radius: Theme.cornerRadiusLarge
|
||||
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.4)
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
||||
border.width: 1
|
||||
|
||||
Ref {
|
||||
service: SysMonitorService
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingM
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
|
||||
SystemLogo {
|
||||
width: 48
|
||||
height: 48
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width - 48 - Theme.spacingM
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.hostname
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
width: parent.width
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.distribution + " • " + SysMonitorService.architecture
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
width: parent.width
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
StyledText {
|
||||
text: "Uptime " + formatUptime(UserInfoService.uptime)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
width: parent.width
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "Load: " + SysMonitorService.loadAverage
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
width: parent.width
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.processCount + " proc, " + SysMonitorService.threadCount + " threads"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.8)
|
||||
width: parent.width
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function formatUptime(uptime) {
|
||||
if (!uptime) return "0m"
|
||||
|
||||
// Parse the uptime string - handle formats like "1 week, 4 days, 3:45" or "4 days, 3:45" or "3:45"
|
||||
var uptimeStr = uptime.toString().trim()
|
||||
|
||||
// Check for weeks and days - need to add them together
|
||||
var weekMatch = uptimeStr.match(/(\d+)\s+weeks?/)
|
||||
var dayMatch = uptimeStr.match(/(\d+)\s+days?/)
|
||||
|
||||
if (weekMatch) {
|
||||
var weeks = parseInt(weekMatch[1])
|
||||
var totalDays = weeks * 7
|
||||
if (dayMatch) {
|
||||
var days = parseInt(dayMatch[1])
|
||||
totalDays += days
|
||||
}
|
||||
return totalDays + "d"
|
||||
} else if (dayMatch) {
|
||||
var days = parseInt(dayMatch[1])
|
||||
return days + "d"
|
||||
}
|
||||
|
||||
// If it's just hours:minutes, show the largest unit
|
||||
var timeMatch = uptimeStr.match(/(\d+):(\d+)/)
|
||||
if (timeMatch) {
|
||||
var hours = parseInt(timeMatch[1])
|
||||
var minutes = parseInt(timeMatch[2])
|
||||
if (hours > 0) {
|
||||
return hours + "h"
|
||||
} else {
|
||||
return minutes + "m"
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback - return as is but truncated
|
||||
return uptimeStr.length > 8 ? uptimeStr.substring(0, 8) + "…" : uptimeStr
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,11 +101,22 @@ ScrollView {
|
||||
|
||||
}
|
||||
|
||||
DankToggle {
|
||||
width: parent.width
|
||||
text: "Enable Weather"
|
||||
description: "Show weather information in top bar and centcom center"
|
||||
checked: Prefs.weatherEnabled
|
||||
onToggled: (checked) => {
|
||||
return Prefs.setWeatherEnabled(checked);
|
||||
}
|
||||
}
|
||||
|
||||
DankToggle {
|
||||
width: parent.width
|
||||
text: "Fahrenheit"
|
||||
description: "Use Fahrenheit instead of Celsius for temperature"
|
||||
checked: Prefs.useFahrenheit
|
||||
enabled: Prefs.weatherEnabled
|
||||
onToggled: (checked) => {
|
||||
return Prefs.setTemperatureUnit(checked);
|
||||
}
|
||||
@@ -116,6 +127,7 @@ ScrollView {
|
||||
text: "Auto Location"
|
||||
description: "Allow wttr.in to determine location based on IP address"
|
||||
checked: Prefs.useAutoLocation
|
||||
enabled: Prefs.weatherEnabled
|
||||
onToggled: (checked) => {
|
||||
return Prefs.setAutoLocation(checked);
|
||||
}
|
||||
@@ -124,7 +136,7 @@ ScrollView {
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXS
|
||||
visible: !Prefs.useAutoLocation
|
||||
visible: !Prefs.useAutoLocation && Prefs.weatherEnabled
|
||||
|
||||
StyledText {
|
||||
text: "Location"
|
||||
|
||||
@@ -11,6 +11,7 @@ Rectangle {
|
||||
|
||||
signal clicked()
|
||||
|
||||
visible: Prefs.weatherEnabled
|
||||
width: visible ? Math.min(100, weatherRow.implicitWidth + Theme.spacingS * 2) : 0
|
||||
height: 30
|
||||
radius: Theme.cornerRadius
|
||||
|
||||
@@ -107,8 +107,8 @@ Singleton {
|
||||
function addRef() {
|
||||
refCount++;
|
||||
|
||||
if (refCount === 1 && !weather.available) {
|
||||
// Start fetching when first consumer appears
|
||||
if (refCount === 1 && !weather.available && Prefs.weatherEnabled) {
|
||||
// Start fetching when first consumer appears and weather is enabled
|
||||
fetchWeather();
|
||||
}
|
||||
}
|
||||
@@ -119,8 +119,8 @@ Singleton {
|
||||
}
|
||||
|
||||
function fetchWeather() {
|
||||
// Only fetch if someone is consuming the data
|
||||
if (root.refCount === 0) {
|
||||
// Only fetch if someone is consuming the data and weather is enabled
|
||||
if (root.refCount === 0 || !Prefs.weatherEnabled) {
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ Singleton {
|
||||
Timer {
|
||||
id: updateTimer
|
||||
interval: root.updateInterval
|
||||
running: root.refCount > 0 && !IdleService.isIdle
|
||||
running: root.refCount > 0 && !IdleService.isIdle && Prefs.weatherEnabled
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
@@ -261,8 +261,8 @@ Singleton {
|
||||
console.log("WeatherService: System idle, pausing weather updates")
|
||||
} else {
|
||||
console.log("WeatherService: System active, resuming weather updates")
|
||||
if (root.refCount > 0 && !root.weather.available) {
|
||||
// Trigger immediate update when coming back from idle if no data
|
||||
if (root.refCount > 0 && !root.weather.available && Prefs.weatherEnabled) {
|
||||
// Trigger immediate update when coming back from idle if no data and weather enabled
|
||||
root.fetchWeather()
|
||||
}
|
||||
}
|
||||
@@ -336,5 +336,21 @@ Singleton {
|
||||
root.lastFetchTime = 0
|
||||
root.forceRefresh()
|
||||
})
|
||||
|
||||
Prefs.weatherEnabledChanged.connect(() => {
|
||||
console.log("Weather enabled setting changed:", Prefs.weatherEnabled)
|
||||
if (Prefs.weatherEnabled && root.refCount > 0 && !root.weather.available) {
|
||||
// Start fetching when weather is re-enabled
|
||||
root.forceRefresh()
|
||||
} else if (!Prefs.weatherEnabled) {
|
||||
// Stop all timers when weather is disabled
|
||||
updateTimer.stop()
|
||||
retryTimer.stop()
|
||||
persistentRetryTimer.stop()
|
||||
if (weatherFetcher.running) {
|
||||
weatherFetcher.running = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user