From 4d2a65dc7e26d4388561c3b5bb38a03a6c947421 Mon Sep 17 00:00:00 2001 From: loner <2788892716@qq.com> Date: Wed, 6 Aug 2025 11:01:42 +0800 Subject: [PATCH 1/3] fix(uptime): replace 'uptime -p' with /proc/uptime parsing On NixOS, the default `uptime` command from coreutils does not support the `-p` option. This replaces the previous `bash`-based solution with a call to `/proc/uptime`, and parses the result in JavaScript to produce a human-readable format like: "up 1 day, 2 hours, 5 minutes" This makes uptime reporting fully compatible with NixOS and more portable. --- Services/UserInfoService.qml | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Services/UserInfoService.qml b/Services/UserInfoService.qml index c369832d..5f600066 100644 --- a/Services/UserInfoService.qml +++ b/Services/UserInfoService.qml @@ -41,7 +41,7 @@ Singleton { running: false onExited: (exitCode) => { if (exitCode !== 0) { - + root.username = "User"; root.fullName = "User"; root.hostname = "System"; @@ -55,7 +55,7 @@ Singleton { root.username = parts[0] || ""; root.fullName = parts[1] || parts[0] || ""; root.hostname = parts[2] || ""; - + } } } @@ -66,20 +66,35 @@ Singleton { Process { id: uptimeProcess - command: ["bash", "-c", "uptime -p | sed 's/up //'"] + command: ["cat", "/proc/uptime"] running: false + onExited: (exitCode) => { if (exitCode !== 0) { - root.uptime = "Unknown"; } } stdout: StdioCollector { onStreamFinished: { - root.uptime = text.trim() || "Unknown"; + const seconds = parseInt(text.split(" ")[0]); + const days = Math.floor(seconds / 86400); + const hours = Math.floor((seconds % 86400) / 3600); + const minutes = Math.floor((seconds % 3600) / 60); + + const parts = []; + if (days > 0) + parts.push(`${days} day${days === 1 ? "" : "s"}`); + if (hours > 0) + parts.push(`${hours} hour${hours === 1 ? "" : "s"}`); + if (minutes > 0) + parts.push(`${minutes} minute${minutes === 1 ? "" : "s"}`); + + if (parts.length > 0) + root.uptime = "up " + parts.join(", "); + else + root.uptime = `up ${seconds} seconds`; } } - - } + } } From 18aa557ef1cb12e3d9aec7261d830bb799ead42d Mon Sep 17 00:00:00 2001 From: bbedward Date: Wed, 6 Aug 2025 11:47:24 -0400 Subject: [PATCH 2/3] config refacotr: separate settings.json, session.json, appusage.json --- Common/AppUsageHistoryData.qml | 128 ++++++++++++ Common/Colors.qml | 28 +-- Common/SessionData.qml | 179 ++++++++++++++++ Common/{Prefs.qml => SettingsData.qml} | 196 ------------------ Common/Theme.qml | 38 ++-- Modals/FileBrowserModal.qml | 9 +- Modals/SpotlightModal.qml | 14 +- Modules/AppDrawer/AppDrawerPopout.qml | 14 +- Modules/AppDrawer/AppLauncher.qml | 4 +- Modules/CentcomCenter/CentcomPopout.qml | 4 +- Modules/CentcomCenter/Events.qml | 2 +- Modules/CentcomCenter/Weather.qml | 4 +- Modules/ControlCenter/ControlCenterPopout.qml | 8 +- Modules/ControlCenter/DisplayTab.qml | 20 +- Modules/Dock/Dock.qml | 10 +- Modules/Dock/DockAppButton.qml | 6 +- Modules/Dock/DockApps.qml | 10 +- Modules/Dock/DockContextMenu.qml | 4 +- Modules/Lock/LockScreenContent.qml | 8 +- .../Center/NotificationHeader.qml | 6 +- Modules/ProcessList/ProcessListItem.qml | 8 +- Modules/ProcessList/ProcessListView.qml | 8 +- Modules/ProcessList/SystemOverview.qml | 12 +- Modules/ProcessList/SystemTab.qml | 48 ++--- Modules/Settings/AppearanceTab.qml | 70 +++---- Modules/Settings/LauncherTab.qml | 50 ++--- Modules/Settings/PersonalizationTab.qml | 20 +- Modules/Settings/TimeWeatherTab.qml | 26 +-- Modules/Settings/WidgetsTab.qml | 110 +++++----- Modules/TopBar/Clock.qml | 6 +- Modules/TopBar/LauncherButton.qml | 10 +- Modules/TopBar/Media.qml | 6 +- Modules/TopBar/NotificationCenterButton.qml | 4 +- Modules/TopBar/TopBar.qml | 16 +- Modules/TopBar/Weather.qml | 4 +- Modules/TopBar/WorkspaceSwitcher.qml | 14 +- Modules/WallpaperBackground.qml | 4 +- Services/NetworkService.qml | 4 +- Services/NotificationService.qml | 8 +- Services/PortalService.qml | 4 +- Services/WeatherService.qml | 26 +-- Widgets/DankGridView.qml | 2 +- Widgets/DankListView.qml | 2 +- Widgets/DankSections.qml | 8 +- Widgets/StyledText.qml | 6 +- 45 files changed, 639 insertions(+), 529 deletions(-) create mode 100644 Common/AppUsageHistoryData.qml create mode 100644 Common/SessionData.qml rename Common/{Prefs.qml => SettingsData.qml} (83%) diff --git a/Common/AppUsageHistoryData.qml b/Common/AppUsageHistoryData.qml new file mode 100644 index 00000000..9b5fd280 --- /dev/null +++ b/Common/AppUsageHistoryData.qml @@ -0,0 +1,128 @@ +pragma Singleton +pragma ComponentBehavior: Bound + +import QtCore +import QtQuick +import Quickshell +import Quickshell.Io + +Singleton { + + id: root + + property var appUsageRanking: {} + + readonly property string _configUrl: StandardPaths.writableLocation(StandardPaths.ConfigLocation) + readonly property string _configDir: _configUrl.startsWith("file://") ? _configUrl.substring(7) : _configUrl + + Component.onCompleted: { + loadSettings(); + } + + function loadSettings() { + parseSettings(settingsFile.text()); + } + + function parseSettings(content) { + try { + if (content && content.trim()) { + var settings = JSON.parse(content); + appUsageRanking = settings.appUsageRanking || {}; + } + } catch (e) { + } + } + + function saveSettings() { + settingsFile.setText(JSON.stringify({ + "appUsageRanking": appUsageRanking + }, null, 2)); + } + + function addAppUsage(app) { + if (!app) + return; + + var appId = app.id || (app.execString || app.exec || ""); + if (!appId) + return; + + var currentRanking = Object.assign({}, appUsageRanking); + + if (currentRanking[appId]) { + currentRanking[appId].usageCount = (currentRanking[appId].usageCount || 1) + 1; + currentRanking[appId].lastUsed = Date.now(); + currentRanking[appId].icon = app.icon || currentRanking[appId].icon || "application-x-executable"; + currentRanking[appId].name = app.name || currentRanking[appId].name || ""; + } else { + currentRanking[appId] = { + "name": app.name || "", + "exec": app.execString || app.exec || "", + "icon": app.icon || "application-x-executable", + "comment": app.comment || "", + "usageCount": 1, + "lastUsed": Date.now() + }; + } + + appUsageRanking = currentRanking; + saveSettings(); + } + + function getAppUsageRanking() { + return appUsageRanking; + } + + function getRankedApps() { + var apps = []; + for (var appId in appUsageRanking) { + var appData = appUsageRanking[appId]; + apps.push({ + id: appId, + name: appData.name, + exec: appData.exec, + icon: appData.icon, + comment: appData.comment, + usageCount: appData.usageCount, + lastUsed: appData.lastUsed + }); + } + + return apps.sort(function(a, b) { + if (a.usageCount !== b.usageCount) + return b.usageCount - a.usageCount; + return a.name.localeCompare(b.name); + }); + } + + function cleanupAppUsageRanking(availableAppIds) { + var currentRanking = Object.assign({}, appUsageRanking); + var hasChanges = false; + + for (var appId in currentRanking) { + if (availableAppIds.indexOf(appId) === -1) { + delete currentRanking[appId]; + hasChanges = true; + } + } + + if (hasChanges) { + appUsageRanking = currentRanking; + saveSettings(); + } + } + + FileView { + id: settingsFile + + path: StandardPaths.writableLocation(StandardPaths.ConfigLocation) + "/DankMaterialShell/appusage.json" + blockLoading: true + blockWrites: true + watchChanges: true + onLoaded: { + parseSettings(settingsFile.text()); + } + onLoadFailed: (error) => { + } + } +} \ No newline at end of file diff --git a/Common/Colors.qml b/Common/Colors.qml index 6e560546..3c35b525 100644 --- a/Common/Colors.qml +++ b/Common/Colors.qml @@ -17,7 +17,7 @@ Singleton { readonly property string _configUrl: StandardPaths.writableLocation(StandardPaths.ConfigLocation) readonly property string configDir: _configUrl.startsWith("file://") ? _configUrl.substring(7) : _configUrl readonly property string shellDir: Qt.resolvedUrl(".").toString().replace("file://", "").replace("/Common/", "") - readonly property string wallpaperPath: Prefs.wallpaperPath + readonly property string wallpaperPath: SessionData.wallpaperPath property bool matugenAvailable: false property bool gtkThemingEnabled: false property bool qtThemingEnabled: false @@ -71,7 +71,7 @@ Singleton { function getMatugenColor(path, fallback) { colorUpdateTrigger; - const colorMode = (typeof Theme !== "undefined" && Theme.isLightMode) ? "light" : "dark"; + const colorMode = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "light" : "dark"; let cur = matugenColors && matugenColors.colors && matugenColors.colors[colorMode]; for (const part of path.split(".")) { if (!cur || typeof cur !== "object" || !(part in cur)) @@ -90,8 +90,8 @@ Singleton { matugenCheck.running = true; checkGtkThemingAvailability(); checkQtThemingAvailability(); - if (typeof Theme !== "undefined") - Theme.isLightModeChanged.connect(root.onLightModeChanged); + if (typeof SessionData !== "undefined") + SessionData.isLightModeChanged.connect(root.onLightModeChanged); } Process { @@ -167,10 +167,10 @@ Singleton { generateNiriConfig(); generateGhosttyConfig(); - if (gtkThemingEnabled && typeof Prefs !== "undefined" && Prefs.gtkThemingEnabled) { + if (gtkThemingEnabled && typeof SettingsData !== "undefined" && SettingsData.gtkThemingEnabled) { generateGtkThemes(); } - if (qtThemingEnabled && typeof Prefs !== "undefined" && Prefs.qtThemingEnabled) { + if (qtThemingEnabled && typeof SettingsData !== "undefined" && SettingsData.qtThemingEnabled) { generateQtThemes(); } } @@ -270,10 +270,10 @@ palette = 15=${fg_b}`; return; } - const isLight = (typeof Theme !== "undefined" && Theme.isLightMode) ? "true" : "false"; - const iconTheme = (typeof Prefs !== "undefined" && Prefs.iconTheme) ? Prefs.iconTheme : "System Default"; - const gtkTheming = (typeof Prefs !== "undefined" && Prefs.gtkThemingEnabled) ? "true" : "false"; - const qtTheming = (typeof Prefs !== "undefined" && Prefs.qtThemingEnabled) ? "true" : "false"; + const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "true" : "false"; + const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default"; + const gtkTheming = (typeof SettingsData !== "undefined" && SettingsData.gtkThemingEnabled) ? "true" : "false"; + const qtTheming = (typeof SettingsData !== "undefined" && SettingsData.qtThemingEnabled) ? "true" : "false"; systemThemeGenerationInProgress = true; systemThemeGenerator.command = [shellDir + "/generate-themes.sh", wallpaperPath, shellDir, configDir, "generate", isLight, iconTheme, gtkTheming, qtTheming]; @@ -294,10 +294,10 @@ palette = 15=${fg_b}`; return; } - const isLight = (typeof Theme !== "undefined" && Theme.isLightMode) ? "true" : "false"; - const iconTheme = (typeof Prefs !== "undefined" && Prefs.iconTheme) ? Prefs.iconTheme : "System Default"; - const gtkTheming = (typeof Prefs !== "undefined" && Prefs.gtkThemingEnabled) ? "true" : "false"; - const qtTheming = (typeof Prefs !== "undefined" && Prefs.qtThemingEnabled) ? "true" : "false"; + const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "true" : "false"; + const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default"; + const gtkTheming = (typeof SettingsData !== "undefined" && SettingsData.gtkThemingEnabled) ? "true" : "false"; + const qtTheming = (typeof SettingsData !== "undefined" && SettingsData.qtThemingEnabled) ? "true" : "false"; systemThemeRestoreProcess.command = [shellDir + "/generate-themes.sh", "", shellDir, configDir, "restore", isLight, iconTheme, gtkTheming, qtTheming]; systemThemeRestoreProcess.running = true; diff --git a/Common/SessionData.qml b/Common/SessionData.qml new file mode 100644 index 00000000..ade99341 --- /dev/null +++ b/Common/SessionData.qml @@ -0,0 +1,179 @@ +pragma Singleton +pragma ComponentBehavior: Bound + +import QtCore +import QtQuick +import Quickshell +import Quickshell.Io + +Singleton { + + id: root + + property bool isLightMode: false + property string wallpaperPath: "" + property string wallpaperLastPath: "" + property string profileLastPath: "" + property bool doNotDisturb: false + property var pinnedApps: [] + + readonly property string _configUrl: StandardPaths.writableLocation(StandardPaths.ConfigLocation) + readonly property string _configDir: _configUrl.startsWith("file://") ? _configUrl.substring(7) : _configUrl + + Component.onCompleted: { + loadSettings(); + } + + function loadSettings() { + parseSettings(settingsFile.text()); + } + + function parseSettings(content) { + try { + if (content && content.trim()) { + var settings = JSON.parse(content); + isLightMode = settings.isLightMode !== undefined ? settings.isLightMode : false; + wallpaperPath = settings.wallpaperPath !== undefined ? settings.wallpaperPath : ""; + wallpaperLastPath = settings.wallpaperLastPath !== undefined ? settings.wallpaperLastPath : ""; + profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : ""; + doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false; + pinnedApps = settings.pinnedApps !== undefined ? settings.pinnedApps : []; + } + } catch (e) { + } + } + + function saveSettings() { + settingsFile.setText(JSON.stringify({ + "isLightMode": isLightMode, + "wallpaperPath": wallpaperPath, + "wallpaperLastPath": wallpaperLastPath, + "profileLastPath": profileLastPath, + "doNotDisturb": doNotDisturb, + "pinnedApps": pinnedApps + }, null, 2)); + } + + function setLightMode(lightMode) { + isLightMode = lightMode; + saveSettings(); + } + + function setDoNotDisturb(enabled) { + doNotDisturb = enabled; + saveSettings(); + } + + function setWallpaperPath(path) { + wallpaperPath = path; + saveSettings(); + } + + function setWallpaper(imagePath) { + wallpaperPath = imagePath; + saveSettings(); + + if (typeof Colors !== "undefined" && typeof SettingsData !== "undefined" && SettingsData.wallpaperDynamicTheming) { + Colors.extractColors(); + } + } + + function setWallpaperLastPath(path) { + wallpaperLastPath = path; + saveSettings(); + } + + function setProfileLastPath(path) { + profileLastPath = path; + saveSettings(); + } + + function setPinnedApps(apps) { + pinnedApps = apps; + saveSettings(); + } + + function addPinnedApp(appId) { + if (!appId) return; + var currentPinned = [...pinnedApps]; + if (currentPinned.indexOf(appId) === -1) { + currentPinned.push(appId); + setPinnedApps(currentPinned); + } + } + + function removePinnedApp(appId) { + if (!appId) return; + var currentPinned = pinnedApps.filter(id => id !== appId); + setPinnedApps(currentPinned); + } + + function isPinnedApp(appId) { + return appId && pinnedApps.indexOf(appId) !== -1; + } + + FileView { + id: settingsFile + + path: StandardPaths.writableLocation(StandardPaths.ConfigLocation) + "/DankMaterialShell/session.json" + blockLoading: true + blockWrites: true + watchChanges: true + onLoaded: { + parseSettings(settingsFile.text()); + } + onLoadFailed: (error) => { + } + } + + IpcHandler { + target: "wallpaper" + + function get(): string { + return root.wallpaperPath || "" + } + + function set(path: string): string { + if (!path) { + return "ERROR: No path provided" + } + + var absolutePath = path.startsWith("/") ? path : StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/" + path + + try { + root.setWallpaper(absolutePath) + return "SUCCESS: Wallpaper set to " + absolutePath + } catch (e) { + return "ERROR: Failed to set wallpaper: " + e.toString() + } + } + + function clear(): string { + root.setWallpaper("") + return "SUCCESS: Wallpaper cleared" + } + } + + IpcHandler { + target: "theme" + + function toggle(): string { + root.setLightMode(!root.isLightMode) + return root.isLightMode ? "light" : "dark" + } + + function light(): string { + root.setLightMode(true) + return "light" + } + + function dark(): string { + root.setLightMode(false) + return "dark" + } + + function getMode(): string { + return root.isLightMode ? "light" : "dark" + } + } +} \ No newline at end of file diff --git a/Common/Prefs.qml b/Common/SettingsData.qml similarity index 83% rename from Common/Prefs.qml rename to Common/SettingsData.qml index 59a4b834..3405bc2e 100644 --- a/Common/Prefs.qml +++ b/Common/SettingsData.qml @@ -13,12 +13,10 @@ Singleton { property int themeIndex: 0 property bool themeIsDynamic: false - property bool isLightMode: false property real topBarTransparency: 0.75 property real topBarWidgetTransparency: 0.85 property real popupTransparency: 0.92 property real dockTransparency: 1.0 - property var appUsageRanking: {} property bool use24HourClock: true property bool useFahrenheit: false property bool nightModeEnabled: false @@ -74,11 +72,7 @@ Singleton { property string osLogoColorOverride: "" property real osLogoBrightness: 0.5 property real osLogoContrast: 1.0 - property string wallpaperPath: "" property bool wallpaperDynamicTheming: true - property string wallpaperLastPath: "" - property string profileLastPath: "" - property bool doNotDisturb: false property bool weatherEnabled: true property string fontFamily: "Inter Variable" property string monoFontFamily: "Fira Code" @@ -86,7 +80,6 @@ Singleton { property bool gtkThemingEnabled: false property bool qtThemingEnabled: false property bool showDock: false - property var pinnedApps: [] property bool dockAutoHide: false readonly property string defaultFontFamily: "Inter Variable" @@ -140,12 +133,10 @@ Singleton { var settings = JSON.parse(content); themeIndex = settings.themeIndex !== undefined ? settings.themeIndex : 0; themeIsDynamic = settings.themeIsDynamic !== undefined ? settings.themeIsDynamic : false; - isLightMode = settings.isLightMode !== undefined ? settings.isLightMode : false; topBarTransparency = settings.topBarTransparency !== undefined ? (settings.topBarTransparency > 1 ? settings.topBarTransparency / 100 : settings.topBarTransparency) : 0.75; topBarWidgetTransparency = settings.topBarWidgetTransparency !== undefined ? (settings.topBarWidgetTransparency > 1 ? settings.topBarWidgetTransparency / 100 : settings.topBarWidgetTransparency) : 0.85; popupTransparency = settings.popupTransparency !== undefined ? (settings.popupTransparency > 1 ? settings.popupTransparency / 100 : settings.popupTransparency) : 0.92; dockTransparency = settings.dockTransparency !== undefined ? (settings.dockTransparency > 1 ? settings.dockTransparency / 100 : settings.dockTransparency) : 1.0; - appUsageRanking = settings.appUsageRanking || {}; use24HourClock = settings.use24HourClock !== undefined ? settings.use24HourClock : true; useFahrenheit = settings.useFahrenheit !== undefined ? settings.useFahrenheit : false; nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false; @@ -194,18 +185,13 @@ Singleton { osLogoColorOverride = settings.osLogoColorOverride !== undefined ? settings.osLogoColorOverride : ""; osLogoBrightness = settings.osLogoBrightness !== undefined ? settings.osLogoBrightness : 0.5; osLogoContrast = settings.osLogoContrast !== undefined ? settings.osLogoContrast : 1.0; - wallpaperPath = settings.wallpaperPath !== undefined ? settings.wallpaperPath : ""; wallpaperDynamicTheming = settings.wallpaperDynamicTheming !== undefined ? settings.wallpaperDynamicTheming : true; - wallpaperLastPath = settings.wallpaperLastPath !== undefined ? settings.wallpaperLastPath : ""; - profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : ""; - doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false; fontFamily = settings.fontFamily !== undefined ? settings.fontFamily : defaultFontFamily; monoFontFamily = settings.monoFontFamily !== undefined ? settings.monoFontFamily : defaultMonoFontFamily; fontWeight = settings.fontWeight !== undefined ? settings.fontWeight : Font.Normal; gtkThemingEnabled = settings.gtkThemingEnabled !== undefined ? settings.gtkThemingEnabled : false; qtThemingEnabled = settings.qtThemingEnabled !== undefined ? settings.qtThemingEnabled : false; showDock = settings.showDock !== undefined ? settings.showDock : false; - pinnedApps = settings.pinnedApps !== undefined ? settings.pinnedApps : []; dockAutoHide = settings.dockAutoHide !== undefined ? settings.dockAutoHide : false; applyStoredTheme(); detectAvailableIconThemes(); @@ -224,12 +210,10 @@ Singleton { settingsFile.setText(JSON.stringify({ "themeIndex": themeIndex, "themeIsDynamic": themeIsDynamic, - "isLightMode": isLightMode, "topBarTransparency": topBarTransparency, "topBarWidgetTransparency": topBarWidgetTransparency, "popupTransparency": popupTransparency, "dockTransparency": dockTransparency, - "appUsageRanking": appUsageRanking, "use24HourClock": use24HourClock, "useFahrenheit": useFahrenheit, "nightModeEnabled": nightModeEnabled, @@ -264,18 +248,13 @@ Singleton { "osLogoColorOverride": osLogoColorOverride, "osLogoBrightness": osLogoBrightness, "osLogoContrast": osLogoContrast, - "wallpaperPath": wallpaperPath, "wallpaperDynamicTheming": wallpaperDynamicTheming, - "wallpaperLastPath": wallpaperLastPath, - "profileLastPath": profileLastPath, - "doNotDisturb": doNotDisturb, "fontFamily": fontFamily, "monoFontFamily": monoFontFamily, "fontWeight": fontWeight, "gtkThemingEnabled": gtkThemingEnabled, "qtThemingEnabled": qtThemingEnabled, "showDock": showDock, - "pinnedApps": pinnedApps, "dockAutoHide": dockAutoHide }, null, 2)); } @@ -302,12 +281,10 @@ Singleton { function applyStoredTheme() { if (typeof Theme !== "undefined") { - Theme.isLightMode = isLightMode; Theme.switchTheme(themeIndex, themeIsDynamic, false); } else { Qt.callLater(() => { if (typeof Theme !== "undefined") { - Theme.isLightMode = isLightMode; Theme.switchTheme(themeIndex, themeIsDynamic, false); } }); @@ -320,13 +297,6 @@ Singleton { saveSettings(); } - function setLightMode(lightMode) { - isLightMode = lightMode; - if (typeof Theme !== "undefined") { - Theme.isLightMode = lightMode; - } - saveSettings(); - } function setTopBarTransparency(transparency) { topBarTransparency = transparency; @@ -348,78 +318,9 @@ Singleton { saveSettings(); } - function addAppUsage(app) { - if (!app) - return; - var appId = app.id || (app.execString || app.exec || ""); - if (!appId) - return; - var currentRanking = Object.assign({}, appUsageRanking); - - if (currentRanking[appId]) { - currentRanking[appId].usageCount = (currentRanking[appId].usageCount || 1) + 1; - currentRanking[appId].lastUsed = Date.now(); - currentRanking[appId].icon = app.icon || currentRanking[appId].icon || "application-x-executable"; - currentRanking[appId].name = app.name || currentRanking[appId].name || ""; - } else { - currentRanking[appId] = { - "name": app.name || "", - "exec": app.execString || app.exec || "", - "icon": app.icon || "application-x-executable", - "comment": app.comment || "", - "usageCount": 1, - "lastUsed": Date.now() - }; - } - - appUsageRanking = currentRanking; - saveSettings(); - } - function getAppUsageRanking() { - return appUsageRanking; - } - - function getRankedApps() { - var apps = []; - for (var appId in appUsageRanking) { - var appData = appUsageRanking[appId]; - apps.push({ - id: appId, - name: appData.name, - exec: appData.exec, - icon: appData.icon, - comment: appData.comment, - usageCount: appData.usageCount, - lastUsed: appData.lastUsed - }); - } - - return apps.sort(function(a, b) { - if (a.usageCount !== b.usageCount) - return b.usageCount - a.usageCount; - return a.name.localeCompare(b.name); - }); - } - - function cleanupAppUsageRanking(availableAppIds) { - var currentRanking = Object.assign({}, appUsageRanking); - var hasChanges = false; - - for (var appId in currentRanking) { - if (availableAppIds.indexOf(appId) === -1) { - delete currentRanking[appId]; - hasChanges = true; - } - } - - if (hasChanges) { - appUsageRanking = currentRanking; - saveSettings(); - } - } // New preference setters function setClockFormat(use24Hour) { @@ -770,37 +671,14 @@ Singleton { saveSettings(); } - function setWallpaperPath(path) { - wallpaperPath = path; - saveSettings(); - - if (wallpaperDynamicTheming && path && typeof Theme !== "undefined") { - Theme.switchTheme(themeIndex, true, true); - } - } function setWallpaperDynamicTheming(enabled) { wallpaperDynamicTheming = enabled; saveSettings(); - if (enabled && wallpaperPath && typeof Theme !== "undefined") { - Theme.switchTheme(themeIndex, true, true); - } } - function setWallpaper(imagePath) { - wallpaperPath = imagePath; - saveSettings(); - - if (wallpaperDynamicTheming && typeof Colors !== "undefined") { - Colors.extractColors(); - } - } - function setDoNotDisturb(enabled) { - doNotDisturb = enabled; - saveSettings(); - } function setFontFamily(family) { fontFamily = family; @@ -832,30 +710,6 @@ Singleton { saveSettings(); } - function setPinnedApps(apps) { - pinnedApps = apps; - pinnedAppsChanged(); // Explicitly emit the signal - saveSettings(); - } - - function addPinnedApp(appId) { - if (!appId) return; - var currentPinned = [...pinnedApps]; - if (currentPinned.indexOf(appId) === -1) { - currentPinned.push(appId); - setPinnedApps(currentPinned); - } - } - - function removePinnedApp(appId) { - if (!appId) return; - var currentPinned = pinnedApps.filter(id => id !== appId); - setPinnedApps(currentPinned); - } - - function isPinnedApp(appId) { - return appId && pinnedApps.indexOf(appId) !== -1; - } function setDockAutoHide(enabled) { @@ -942,54 +796,4 @@ Singleton { } } - IpcHandler { - target: "wallpaper" - - function get(): string { - return root.wallpaperPath || "" - } - - function set(path: string): string { - if (!path) { - return "ERROR: No path provided" - } - - var absolutePath = path.startsWith("/") ? path : StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/" + path - - try { - root.setWallpaper(absolutePath) - return "SUCCESS: Wallpaper set to " + absolutePath - } catch (e) { - return "ERROR: Failed to set wallpaper: " + e.toString() - } - } - - function clear(): string { - root.setWallpaper("") - return "SUCCESS: Wallpaper cleared" - } - } - - IpcHandler { - target: "theme" - - function toggle(): string { - root.setLightMode(!root.isLightMode) - return root.isLightMode ? "light" : "dark" - } - - function light(): string { - root.setLightMode(true) - return "light" - } - - function dark(): string { - root.setLightMode(false) - return "dark" - } - - function getMode(): string { - return root.isLightMode ? "light" : "dark" - } - } } diff --git a/Common/Theme.qml b/Common/Theme.qml index 4b5571d4..f2cff908 100644 --- a/Common/Theme.qml +++ b/Common/Theme.qml @@ -424,8 +424,8 @@ Singleton { if (isDynamicTheme) { currentThemeIndex = 10; isDynamicTheme = true; - if (typeof Prefs !== "undefined") - Prefs.setTheme(currentThemeIndex, isDynamicTheme); + if (typeof SettingsData !== "undefined") + SettingsData.setTheme(currentThemeIndex, isDynamicTheme); } } @@ -442,14 +442,14 @@ Singleton { currentThemeIndex = themeIndex; isDynamicTheme = false; } - if (savePrefs && typeof Prefs !== "undefined") - Prefs.setTheme(currentThemeIndex, isDynamicTheme); + if (savePrefs && typeof SettingsData !== "undefined") + SettingsData.setTheme(currentThemeIndex, isDynamicTheme); } function toggleLightMode(savePrefs = true) { isLightMode = !isLightMode; - if (savePrefs && typeof Prefs !== "undefined") - Prefs.setLightMode(isLightMode); + if (savePrefs && typeof SessionData !== "undefined") + SessionData.setLightMode(isLightMode); } function getCurrentThemeArray() { @@ -592,23 +592,23 @@ Singleton { if (typeof Colors !== "undefined") Colors.colorsUpdated.connect(root.onColorsUpdated); - if (typeof Prefs !== "undefined") { - if (Prefs.popupTransparency !== undefined) - root.popupTransparency = Prefs.popupTransparency; + if (typeof SettingsData !== "undefined") { + if (SettingsData.popupTransparency !== undefined) + root.popupTransparency = SettingsData.popupTransparency; - if (Prefs.topBarWidgetTransparency !== undefined) - root.widgetTransparency = Prefs.topBarWidgetTransparency; + if (SettingsData.topBarWidgetTransparency !== undefined) + root.widgetTransparency = SettingsData.topBarWidgetTransparency; - if (Prefs.popupTransparencyChanged) - Prefs.popupTransparencyChanged.connect(function() { - if (typeof Prefs !== "undefined" && Prefs.popupTransparency !== undefined) - root.popupTransparency = Prefs.popupTransparency; + if (SettingsData.popupTransparencyChanged) + SettingsData.popupTransparencyChanged.connect(function() { + if (typeof SettingsData !== "undefined" && SettingsData.popupTransparency !== undefined) + root.popupTransparency = SettingsData.popupTransparency; }); - if (Prefs.topBarWidgetTransparencyChanged) - Prefs.topBarWidgetTransparencyChanged.connect(function() { - if (typeof Prefs !== "undefined" && Prefs.topBarWidgetTransparency !== undefined) - root.widgetTransparency = Prefs.topBarWidgetTransparency; + if (SettingsData.topBarWidgetTransparencyChanged) + SettingsData.topBarWidgetTransparencyChanged.connect(function() { + if (typeof SettingsData !== "undefined" && SettingsData.topBarWidgetTransparency !== undefined) + root.widgetTransparency = SettingsData.topBarWidgetTransparency; }); } } diff --git a/Modals/FileBrowserModal.qml b/Modals/FileBrowserModal.qml index 0e5d9607..37a9b4ad 100644 --- a/Modals/FileBrowserModal.qml +++ b/Modals/FileBrowserModal.qml @@ -39,9 +39,9 @@ DankModal { function getLastPath() { var lastPath = ""; if (browserType === "wallpaper") { - lastPath = Prefs.wallpaperLastPath; + lastPath = SessionData.wallpaperLastPath; } else if (browserType === "profile") { - lastPath = Prefs.profileLastPath; + lastPath = SessionData.profileLastPath; } if (lastPath && lastPath !== "") { @@ -52,11 +52,10 @@ DankModal { function saveLastPath(path) { if (browserType === "wallpaper") { - Prefs.wallpaperLastPath = path; + SessionData.setWallpaperLastPath(path); } else if (browserType === "profile") { - Prefs.profileLastPath = path; + SessionData.setProfileLastPath(path); } - Prefs.saveSettings(); } Component.onCompleted: { diff --git a/Modals/SpotlightModal.qml b/Modals/SpotlightModal.qml index d13c107c..4e1af430 100644 --- a/Modals/SpotlightModal.qml +++ b/Modals/SpotlightModal.qml @@ -59,11 +59,11 @@ DankModal { AppLauncher { id: appLauncher - viewMode: Prefs.spotlightModalViewMode + viewMode: SettingsData.spotlightModalViewMode gridColumns: 4 onAppLaunched: hide() onViewModeSelected: function(mode) { - Prefs.setSpotlightModalViewMode(mode); + SettingsData.setSpotlightModalViewMode(mode); } } @@ -426,7 +426,7 @@ DankModal { name: { if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) return "push_pin" var appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "" - return Prefs.isPinnedApp(appId) ? "keep_off" : "push_pin" + return SessionData.isPinnedApp(appId) ? "keep_off" : "push_pin" } size: Theme.iconSize - 2 color: Theme.surfaceText @@ -438,7 +438,7 @@ DankModal { text: { if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) return "Pin to Dock" var appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "" - return Prefs.isPinnedApp(appId) ? "Unpin from Dock" : "Pin to Dock" + return SessionData.isPinnedApp(appId) ? "Unpin from Dock" : "Pin to Dock" } font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceText @@ -455,10 +455,10 @@ DankModal { onClicked: { if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) return var appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "" - if (Prefs.isPinnedApp(appId)) { - Prefs.removePinnedApp(appId) + if (SessionData.isPinnedApp(appId)) { + SessionData.removePinnedApp(appId) } else { - Prefs.addPinnedApp(appId) + SessionData.addPinnedApp(appId) } contextMenu.close() } diff --git a/Modules/AppDrawer/AppDrawerPopout.qml b/Modules/AppDrawer/AppDrawerPopout.qml index 7d2145e9..b7db8088 100644 --- a/Modules/AppDrawer/AppDrawerPopout.qml +++ b/Modules/AppDrawer/AppDrawerPopout.qml @@ -62,11 +62,11 @@ PanelWindow { AppLauncher { id: appLauncher - viewMode: Prefs.appLauncherViewMode + viewMode: SettingsData.appLauncherViewMode gridColumns: 4 onAppLaunched: appDrawerPopout.hide() onViewModeSelected: function(mode) { - Prefs.setAppLauncherViewMode(mode); + SettingsData.setAppLauncherViewMode(mode); } } @@ -514,7 +514,7 @@ PanelWindow { return "push_pin"; var appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || ""; - return Prefs.isPinnedApp(appId) ? "keep_off" : "push_pin"; + return SessionData.isPinnedApp(appId) ? "keep_off" : "push_pin"; } size: Theme.iconSize - 2 color: Theme.surfaceText @@ -528,7 +528,7 @@ PanelWindow { return "Pin to Dock"; var appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || ""; - return Prefs.isPinnedApp(appId) ? "Unpin from Dock" : "Pin to Dock"; + return SessionData.isPinnedApp(appId) ? "Unpin from Dock" : "Pin to Dock"; } font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceText @@ -549,10 +549,10 @@ PanelWindow { return ; var appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || ""; - if (Prefs.isPinnedApp(appId)) - Prefs.removePinnedApp(appId); + if (SessionData.isPinnedApp(appId)) + SessionData.removePinnedApp(appId); else - Prefs.addPinnedApp(appId); + SessionData.addPinnedApp(appId); contextMenu.close(); } } diff --git a/Modules/AppDrawer/AppLauncher.qml b/Modules/AppDrawer/AppLauncher.qml index d3ff2d36..1ffaf7a4 100644 --- a/Modules/AppDrawer/AppLauncher.qml +++ b/Modules/AppDrawer/AppLauncher.qml @@ -29,7 +29,7 @@ Item { property var categoryIcons: categories.map((category) => { return AppSearchService.getCategoryIcon(category); }) - property var appUsageRanking: Prefs.appUsageRanking + property var appUsageRanking: AppUsageHistoryData.appUsageRanking property alias model: filteredModel property var _watchApplications: AppSearchService.applications @@ -144,7 +144,7 @@ Item { appData.desktopEntry.execute(); appLaunched(appData); - Prefs.addAppUsage(appData.desktopEntry); + AppUsageHistoryData.addAppUsage(appData.desktopEntry); } function setCategory(category) { diff --git a/Modules/CentcomCenter/CentcomPopout.qml b/Modules/CentcomCenter/CentcomPopout.qml index f95ff9c6..01e52628 100644 --- a/Modules/CentcomCenter/CentcomPopout.qml +++ b/Modules/CentcomCenter/CentcomPopout.qml @@ -227,13 +227,13 @@ PanelWindow { Weather { width: parent.width height: 140 - visible: Prefs.weatherEnabled + visible: SettingsData.weatherEnabled } SystemInfo { width: parent.width height: 140 - visible: !Prefs.weatherEnabled + visible: !SettingsData.weatherEnabled } } diff --git a/Modules/CentcomCenter/Events.qml b/Modules/CentcomCenter/Events.qml index ff4f67f5..d738a6cd 100644 --- a/Modules/CentcomCenter/Events.qml +++ b/Modules/CentcomCenter/Events.qml @@ -204,7 +204,7 @@ Rectangle { if (modelData.allDay) { return "All day"; } else { - let timeFormat = Prefs.use24HourClock ? "H:mm" : "h:mm AP"; + let timeFormat = SettingsData.use24HourClock ? "H:mm" : "h:mm AP"; let startTime = Qt.formatTime(modelData.start, timeFormat); if (modelData.start.toDateString() !== modelData.end.toDateString() || modelData.start.getTime() !== modelData.end.getTime()) return startTime + " – " + Qt.formatTime(modelData.end, timeFormat); diff --git a/Modules/CentcomCenter/Weather.qml b/Modules/CentcomCenter/Weather.qml index 913269ed..58fd72b4 100644 --- a/Modules/CentcomCenter/Weather.qml +++ b/Modules/CentcomCenter/Weather.qml @@ -67,7 +67,7 @@ Rectangle { anchors.verticalCenter: parent.verticalCenter StyledText { - text: (Prefs.useFahrenheit ? WeatherService.weather.tempF : WeatherService.weather.temp) + "°" + (Prefs.useFahrenheit ? "F" : "C") + text: (SettingsData.useFahrenheit ? WeatherService.weather.tempF : WeatherService.weather.temp) + "°" + (SettingsData.useFahrenheit ? "F" : "C") font.pixelSize: Theme.fontSizeXLarge color: Theme.surfaceText font.weight: Font.Light @@ -78,7 +78,7 @@ Rectangle { cursorShape: Qt.PointingHandCursor onClicked: { if (WeatherService.weather.available) - Prefs.setTemperatureUnit(!Prefs.useFahrenheit); + SettingsData.setTemperatureUnit(!SettingsData.useFahrenheit); } enabled: WeatherService.weather.available diff --git a/Modules/ControlCenter/ControlCenterPopout.qml b/Modules/ControlCenter/ControlCenterPopout.qml index a3413bd7..17dd8b1a 100644 --- a/Modules/ControlCenter/ControlCenterPopout.qml +++ b/Modules/ControlCenter/ControlCenterPopout.qml @@ -763,9 +763,9 @@ PanelWindow { width: parent.width text: "Night Mode" description: "Apply warm color temperature to reduce eye strain" - checked: Prefs.nightModeEnabled + checked: SettingsData.nightModeEnabled onToggled: (checked) => { - Prefs.setNightModeEnabled(checked); + SettingsData.setNightModeEnabled(checked); } } @@ -773,9 +773,9 @@ PanelWindow { width: parent.width text: "Light Mode" description: "Use light theme instead of dark theme" - checked: Prefs.isLightMode + checked: SessionData.isLightMode onToggled: (checked) => { - Prefs.setLightMode(checked); + SessionData.setLightMode(checked); Theme.isLightMode = checked; PortalService.setLightMode(checked); } diff --git a/Modules/ControlCenter/DisplayTab.qml b/Modules/ControlCenter/DisplayTab.qml index 440ac87e..3ccc0d04 100644 --- a/Modules/ControlCenter/DisplayTab.qml +++ b/Modules/ControlCenter/DisplayTab.qml @@ -88,25 +88,25 @@ ScrollView { width: (parent.width - Theme.spacingM) / 2 height: 80 radius: Theme.cornerRadius - color: Prefs.nightModeEnabled ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : (nightModeToggle.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08)) - border.color: Prefs.nightModeEnabled ? Theme.primary : "transparent" - border.width: Prefs.nightModeEnabled ? 1 : 0 + color: SettingsData.nightModeEnabled ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : (nightModeToggle.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08)) + border.color: SettingsData.nightModeEnabled ? Theme.primary : "transparent" + border.width: SettingsData.nightModeEnabled ? 1 : 0 Column { anchors.centerIn: parent spacing: Theme.spacingS DankIcon { - name: Prefs.nightModeEnabled ? "nightlight" : "dark_mode" + name: SettingsData.nightModeEnabled ? "nightlight" : "dark_mode" size: Theme.iconSizeLarge - color: Prefs.nightModeEnabled ? Theme.primary : Theme.surfaceText + color: SettingsData.nightModeEnabled ? Theme.primary : Theme.surfaceText anchors.horizontalCenter: parent.horizontalCenter } StyledText { text: "Night Mode" font.pixelSize: Theme.fontSizeMedium - color: Prefs.nightModeEnabled ? Theme.primary : Theme.surfaceText + color: SettingsData.nightModeEnabled ? Theme.primary : Theme.surfaceText font.weight: Font.Medium anchors.horizontalCenter: parent.horizontalCenter } @@ -120,12 +120,12 @@ ScrollView { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - if (Prefs.nightModeEnabled) { + if (SettingsData.nightModeEnabled) { nightModeDisableProcess.running = true; - Prefs.setNightModeEnabled(false); + SettingsData.setNightModeEnabled(false); } else { nightModeEnableProcess.running = true; - Prefs.setNightModeEnabled(true); + SettingsData.setNightModeEnabled(true); } } } @@ -196,7 +196,7 @@ ScrollView { onExited: (exitCode) => { if (exitCode !== 0) { - Prefs.setNightModeEnabled(false); + SettingsData.setNightModeEnabled(false); } } } diff --git a/Modules/Dock/Dock.qml b/Modules/Dock/Dock.qml index 93e3a4df..2019dd3c 100644 --- a/Modules/Dock/Dock.qml +++ b/Modules/Dock/Dock.qml @@ -17,8 +17,8 @@ PanelWindow { property var modelData property var contextMenu property var windowsMenu - property bool autoHide: Prefs.dockAutoHide - property real backgroundTransparency: Prefs.dockTransparency + property bool autoHide: SettingsData.dockAutoHide + property real backgroundTransparency: SettingsData.dockTransparency property bool contextMenuOpen: (contextMenu && contextMenu.visible && contextMenu.screen === modelData) || (windowsMenu && windowsMenu.visible && windowsMenu.screen === modelData) @@ -32,14 +32,14 @@ PanelWindow { property bool reveal: (!autoHide || dockMouseArea.containsMouse || dockApps.requestDockShow || contextMenuOpen) && !windowIsFullscreen Connections { - target: Prefs + target: SettingsData function onDockTransparencyChanged() { - dock.backgroundTransparency = Prefs.dockTransparency; + dock.backgroundTransparency = SettingsData.dockTransparency; } } screen: modelData - visible: Prefs.showDock + visible: SettingsData.showDock color: "transparent" anchors { diff --git a/Modules/Dock/DockAppButton.qml b/Modules/Dock/DockAppButton.qml index 10074f07..f13c9dff 100644 --- a/Modules/Dock/DockAppButton.qml +++ b/Modules/Dock/DockAppButton.qml @@ -170,7 +170,7 @@ Item { if (appData && appData.appId) { var desktopEntry = DesktopEntries.byId(appData.appId) if (desktopEntry) { - Prefs.addAppUsage({ + AppUsageHistoryData.addAppUsage({ id: appData.appId, name: desktopEntry.name || appData.appId, icon: desktopEntry.icon || "", @@ -190,7 +190,7 @@ Item { if (appData && appData.appId) { var desktopEntry = DesktopEntries.byId(appData.appId) if (desktopEntry) { - Prefs.addAppUsage({ + AppUsageHistoryData.addAppUsage({ id: appData.appId, name: desktopEntry.name || appData.appId, icon: desktopEntry.icon || "", @@ -225,7 +225,7 @@ Item { if (!appData || !appData.appId) return "" var desktopEntry = DesktopEntries.byId(appData.appId) if (desktopEntry && desktopEntry.icon) { - var iconPath = Quickshell.iconPath(desktopEntry.icon, Prefs.iconTheme === "System Default" ? "" : Prefs.iconTheme) + var iconPath = Quickshell.iconPath(desktopEntry.icon, SettingsData.iconTheme === "System Default" ? "" : SettingsData.iconTheme) return iconPath } return "" diff --git a/Modules/Dock/DockApps.qml b/Modules/Dock/DockApps.qml index 82320f25..a710f219 100644 --- a/Modules/Dock/DockApps.qml +++ b/Modules/Dock/DockApps.qml @@ -19,13 +19,13 @@ Item { function movePinnedApp(fromIndex, toIndex) { if (fromIndex === toIndex) return - var currentPinned = [...Prefs.pinnedApps] + var currentPinned = [...SessionData.pinnedApps] if (fromIndex < 0 || fromIndex >= currentPinned.length || toIndex < 0 || toIndex >= currentPinned.length) return var movedApp = currentPinned.splice(fromIndex, 1)[0] currentPinned.splice(toIndex, 0, movedApp) - Prefs.setPinnedApps(currentPinned) + SessionData.setPinnedApps(currentPinned) } Row { @@ -46,7 +46,7 @@ Item { var items = [] var runningApps = NiriService.getRunningAppIds() - var pinnedApps = [...Prefs.pinnedApps] + var pinnedApps = [...SessionData.pinnedApps] var addedApps = new Set() pinnedApps.forEach(appId => { @@ -63,7 +63,7 @@ Item { } }) root.pinnedAppCount = pinnedApps.length - var appUsageRanking = Prefs.appUsageRanking || {} + var appUsageRanking = AppUsageHistoryData.appUsageRanking || {} var allUnpinnedApps = [] for (var appId in appUsageRanking) { @@ -151,7 +151,7 @@ Item { } Connections { - target: Prefs + target: SessionData function onPinnedAppsChanged() { dockModel.updateModel() } } } \ No newline at end of file diff --git a/Modules/Dock/DockContextMenu.qml b/Modules/Dock/DockContextMenu.qml index 466dafc3..00b9a40d 100644 --- a/Modules/Dock/DockContextMenu.qml +++ b/Modules/Dock/DockContextMenu.qml @@ -160,9 +160,9 @@ PanelWindow { onClicked: { if (!root.appData) return if (root.appData.isPinned) { - Prefs.removePinnedApp(root.appData.appId) + SessionData.removePinnedApp(root.appData.appId) } else { - Prefs.addPinnedApp(root.appData.appId) + SessionData.addPinnedApp(root.appData.appId) } root.close() } diff --git a/Modules/Lock/LockScreenContent.qml b/Modules/Lock/LockScreenContent.qml index e4e0c8a0..e7f426b6 100644 --- a/Modules/Lock/LockScreenContent.qml +++ b/Modules/Lock/LockScreenContent.qml @@ -70,7 +70,7 @@ Item { Image { id: wallpaperBackground anchors.fill: parent - source: Prefs.wallpaperPath || "" + source: SessionData.wallpaperPath || "" fillMode: Image.PreserveAspectCrop smooth: true asynchronous: true @@ -114,7 +114,7 @@ Item { id: clockText anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top - text: Prefs.use24HourClock ? Qt.formatTime(new Date(), "H:mm") : Qt.formatTime(new Date(), "h:mm AP") + text: SettingsData.use24HourClock ? Qt.formatTime(new Date(), "H:mm") : Qt.formatTime(new Date(), "h:mm AP") font.pixelSize: 120 font.weight: Font.Light color: "white" @@ -124,7 +124,7 @@ Item { interval: 1000 running: true repeat: true - onTriggered: parent.text = Prefs.use24HourClock ? Qt.formatTime(new Date(), "H:mm") : Qt.formatTime(new Date(), "h:mm AP") + onTriggered: parent.text = SettingsData.use24HourClock ? Qt.formatTime(new Date(), "H:mm") : Qt.formatTime(new Date(), "h:mm AP") } } @@ -517,7 +517,7 @@ Item { anchors.right: parent.right anchors.margins: Theme.spacingXL text: WeatherService.weather.available && WeatherService.weather.city && WeatherService.weather.city !== "Unknown" ? - `${WeatherService.weather.city} ${(Prefs.useFahrenheit ? WeatherService.weather.tempF : WeatherService.weather.temp)}°${(Prefs.useFahrenheit ? "F" : "C")}` : + `${WeatherService.weather.city} ${(SettingsData.useFahrenheit ? WeatherService.weather.tempF : WeatherService.weather.temp)}°${(SettingsData.useFahrenheit ? "F" : "C")}` : "" font.pixelSize: Theme.fontSizeMedium color: "white" diff --git a/Modules/Notifications/Center/NotificationHeader.qml b/Modules/Notifications/Center/NotificationHeader.qml index 10246174..d6e44dca 100644 --- a/Modules/Notifications/Center/NotificationHeader.qml +++ b/Modules/Notifications/Center/NotificationHeader.qml @@ -26,11 +26,11 @@ Item { DankActionButton { id: doNotDisturbButton - iconName: Prefs.doNotDisturb ? "notifications_off" : "notifications" - iconColor: Prefs.doNotDisturb ? Theme.error : Theme.surfaceText + iconName: SessionData.doNotDisturb ? "notifications_off" : "notifications" + iconColor: SessionData.doNotDisturb ? Theme.error : Theme.surfaceText buttonSize: 28 anchors.verticalCenter: parent.verticalCenter - onClicked: Prefs.setDoNotDisturb(!Prefs.doNotDisturb) + onClicked: SessionData.setDoNotDisturb(!SessionData.doNotDisturb) Rectangle { id: doNotDisturbTooltip diff --git a/Modules/ProcessList/ProcessListItem.qml b/Modules/ProcessList/ProcessListItem.qml index 23996398..ca5ca726 100644 --- a/Modules/ProcessList/ProcessListItem.qml +++ b/Modules/ProcessList/ProcessListItem.qml @@ -68,7 +68,7 @@ Rectangle { StyledText { text: process ? process.displayName : "" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Medium color: Theme.surfaceText width: 250 @@ -100,7 +100,7 @@ Rectangle { StyledText { text: SysMonitorService.formatCpuUsage(process ? process.cpu : 0) font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: { if (process && process.cpu > 80) @@ -138,7 +138,7 @@ Rectangle { StyledText { text: SysMonitorService.formatMemoryUsage(process ? process.memoryKB : 0) font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: { if (process && process.memoryKB > 1024 * 1024) @@ -157,7 +157,7 @@ Rectangle { StyledText { text: process ? process.pid.toString() : "" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Theme.surfaceText opacity: 0.7 width: 50 diff --git a/Modules/ProcessList/ProcessListView.qml b/Modules/ProcessList/ProcessListView.qml index 9ee71708..f17c0619 100644 --- a/Modules/ProcessList/ProcessListView.qml +++ b/Modules/ProcessList/ProcessListView.qml @@ -35,7 +35,7 @@ Column { StyledText { text: "Process" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: SysMonitorService.sortBy === "name" ? Font.Bold : Font.Medium color: Theme.surfaceText opacity: SysMonitorService.sortBy === "name" ? 1 : 0.7 @@ -76,7 +76,7 @@ Column { StyledText { text: "CPU" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: SysMonitorService.sortBy === "cpu" ? Font.Bold : Font.Medium color: Theme.surfaceText opacity: SysMonitorService.sortBy === "cpu" ? 1 : 0.7 @@ -117,7 +117,7 @@ Column { StyledText { text: "RAM" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: SysMonitorService.sortBy === "memory" ? Font.Bold : Font.Medium color: Theme.surfaceText opacity: SysMonitorService.sortBy === "memory" ? 1 : 0.7 @@ -158,7 +158,7 @@ Column { StyledText { text: "PID" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: SysMonitorService.sortBy === "pid" ? Font.Bold : Font.Medium color: Theme.surfaceText opacity: SysMonitorService.sortBy === "pid" ? 1 : 0.7 diff --git a/Modules/ProcessList/SystemOverview.qml b/Modules/ProcessList/SystemOverview.qml index 04d6a93a..53025a6e 100644 --- a/Modules/ProcessList/SystemOverview.qml +++ b/Modules/ProcessList/SystemOverview.qml @@ -54,7 +54,7 @@ Row { StyledText { text: SysMonitorService.totalCpuUsage.toFixed(1) + "%" font.pixelSize: Theme.fontSizeLarge - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText } @@ -62,7 +62,7 @@ Row { StyledText { text: SysMonitorService.cpuCount + " cores" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Theme.surfaceText opacity: 0.7 } @@ -126,7 +126,7 @@ Row { StyledText { text: SysMonitorService.formatSystemMemory(SysMonitorService.usedMemoryKB) font.pixelSize: Theme.fontSizeLarge - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText } @@ -134,7 +134,7 @@ Row { StyledText { text: "of " + SysMonitorService.formatSystemMemory(SysMonitorService.totalMemoryKB) font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Theme.surfaceText opacity: 0.7 } @@ -182,7 +182,7 @@ Row { StyledText { text: SysMonitorService.totalSwapKB > 0 ? SysMonitorService.formatSystemMemory(SysMonitorService.usedSwapKB) : "None" font.pixelSize: Theme.fontSizeLarge - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText } @@ -190,7 +190,7 @@ Row { StyledText { text: SysMonitorService.totalSwapKB > 0 ? "of " + SysMonitorService.formatSystemMemory(SysMonitorService.totalSwapKB) : "No swap configured" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Theme.surfaceText opacity: 0.7 } diff --git a/Modules/ProcessList/SystemTab.qml b/Modules/ProcessList/SystemTab.qml index 469277c3..fff8baea 100644 --- a/Modules/ProcessList/SystemTab.qml +++ b/Modules/ProcessList/SystemTab.qml @@ -53,7 +53,7 @@ ScrollView { StyledText { text: SysMonitorService.hostname font.pixelSize: Theme.fontSizeXLarge - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Light color: Theme.surfaceText verticalAlignment: Text.AlignVCenter @@ -62,7 +62,7 @@ ScrollView { StyledText { text: SysMonitorService.distribution + " • " + SysMonitorService.architecture + " • " + SysMonitorService.kernelVersion font.pixelSize: Theme.fontSizeMedium - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7) verticalAlignment: Text.AlignVCenter } @@ -70,7 +70,7 @@ ScrollView { StyledText { text: "Up " + UserInfoService.uptime + " • Boot: " + SysMonitorService.bootTime font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6) verticalAlignment: Text.AlignVCenter } @@ -78,7 +78,7 @@ ScrollView { StyledText { text: "Load: " + SysMonitorService.loadAverage + " • " + SysMonitorService.processCount + " processes, " + SysMonitorService.threadCount + " threads" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6) verticalAlignment: Text.AlignVCenter } @@ -128,7 +128,7 @@ ScrollView { StyledText { text: "Hardware" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.primary anchors.verticalCenter: parent.verticalCenter @@ -139,7 +139,7 @@ ScrollView { StyledText { text: SysMonitorService.cpuModel font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Medium color: Theme.surfaceText width: parent.width @@ -152,7 +152,7 @@ ScrollView { StyledText { text: SysMonitorService.motherboard font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.8) width: parent.width elide: Text.ElideRight @@ -164,7 +164,7 @@ ScrollView { StyledText { text: "BIOS " + SysMonitorService.biosVersion font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7) width: parent.width elide: Text.ElideRight @@ -206,7 +206,7 @@ ScrollView { StyledText { text: "Memory" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.secondary anchors.verticalCenter: parent.verticalCenter @@ -217,7 +217,7 @@ ScrollView { StyledText { text: SysMonitorService.formatSystemMemory(SysMonitorService.totalMemoryKB) + " Total" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Medium color: Theme.surfaceText width: parent.width @@ -228,7 +228,7 @@ ScrollView { StyledText { text: SysMonitorService.formatSystemMemory(SysMonitorService.usedMemoryKB) + " Used • " + SysMonitorService.formatSystemMemory(SysMonitorService.totalMemoryKB - SysMonitorService.usedMemoryKB) + " Available" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7) width: parent.width elide: Text.ElideRight @@ -280,7 +280,7 @@ ScrollView { StyledText { text: "Storage & Disks" font.pixelSize: Theme.fontSizeLarge - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText anchors.verticalCenter: parent.verticalCenter @@ -300,7 +300,7 @@ ScrollView { StyledText { text: "Device" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText width: parent.width * 0.25 @@ -311,7 +311,7 @@ ScrollView { StyledText { text: "Mount" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText width: parent.width * 0.2 @@ -322,7 +322,7 @@ ScrollView { StyledText { text: "Size" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText width: parent.width * 0.15 @@ -333,7 +333,7 @@ ScrollView { StyledText { text: "Used" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText width: parent.width * 0.15 @@ -344,7 +344,7 @@ ScrollView { StyledText { text: "Available" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText width: parent.width * 0.15 @@ -355,7 +355,7 @@ ScrollView { StyledText { text: "Use%" font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily font.weight: Font.Bold color: Theme.surfaceText width: parent.width * 0.1 @@ -390,7 +390,7 @@ ScrollView { StyledText { text: modelData.device font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Theme.surfaceText width: parent.width * 0.25 elide: Text.ElideRight @@ -401,7 +401,7 @@ ScrollView { StyledText { text: modelData.mount font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Theme.surfaceText width: parent.width * 0.2 elide: Text.ElideRight @@ -412,7 +412,7 @@ ScrollView { StyledText { text: modelData.size font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Theme.surfaceText width: parent.width * 0.15 elide: Text.ElideRight @@ -423,7 +423,7 @@ ScrollView { StyledText { text: modelData.used font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Theme.surfaceText width: parent.width * 0.15 elide: Text.ElideRight @@ -434,7 +434,7 @@ ScrollView { StyledText { text: modelData.avail font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: Theme.surfaceText width: parent.width * 0.15 elide: Text.ElideRight @@ -445,7 +445,7 @@ ScrollView { StyledText { text: modelData.percent font.pixelSize: Theme.fontSizeSmall - font.family: Prefs.monoFontFamily + font.family: SettingsData.monoFontFamily color: { const percent = parseInt(modelData.percent); if (percent > 90) diff --git a/Modules/Settings/AppearanceTab.qml b/Modules/Settings/AppearanceTab.qml index 38bdefe6..f4a485c6 100644 --- a/Modules/Settings/AppearanceTab.qml +++ b/Modules/Settings/AppearanceTab.qml @@ -60,9 +60,9 @@ ScrollView { width: parent.width text: "Night Mode" description: "Apply warm color temperature to reduce eye strain" - checked: Prefs.nightModeEnabled + checked: SettingsData.nightModeEnabled onToggled: (checked) => { - Prefs.setNightModeEnabled(checked); + SettingsData.setNightModeEnabled(checked); if (checked) nightModeEnableProcess.running = true; else @@ -74,9 +74,9 @@ ScrollView { width: parent.width text: "Light Mode" description: "Use light theme instead of dark theme" - checked: Prefs.isLightMode + checked: SessionData.isLightMode onToggled: (checked) => { - Prefs.setLightMode(checked); + SessionData.setLightMode(checked); Theme.isLightMode = checked; PortalService.setLightMode(checked); } @@ -86,17 +86,17 @@ ScrollView { width: parent.width text: "Icon Theme" description: "Select icon theme" - currentValue: Prefs.iconTheme + currentValue: SettingsData.iconTheme enableFuzzySearch: true popupWidthOffset: 100 maxPopupHeight: 400 options: { - Prefs.detectAvailableIconThemes(); - return Prefs.availableIconThemes; + SettingsData.detectAvailableIconThemes(); + return SettingsData.availableIconThemes; } onValueChanged: (value) => { - Prefs.setIconTheme(value); - if (value !== "System Default" && !Prefs.qt5ctAvailable && !Prefs.qt6ctAvailable) + SettingsData.setIconTheme(value); + if (value !== "System Default" && !SettingsData.qt5ctAvailable && !SettingsData.qt6ctAvailable) ToastService.showWarning("qt5ct or qt6ct not found - Qt app themes may not update without these tools"); } @@ -107,16 +107,16 @@ ScrollView { text: "Font Family" description: "Select system font family" currentValue: { - if (Prefs.fontFamily === Prefs.defaultFontFamily) - return "Default (" + Prefs.defaultFontFamily + ")"; + if (SettingsData.fontFamily === SettingsData.defaultFontFamily) + return "Default (" + SettingsData.defaultFontFamily + ")"; else - return Prefs.fontFamily || "Default (" + Prefs.defaultFontFamily + ")"; + return SettingsData.fontFamily || "Default (" + SettingsData.defaultFontFamily + ")"; } enableFuzzySearch: true popupWidthOffset: 100 maxPopupHeight: 400 options: { - var fonts = ["Default (" + Prefs.defaultFontFamily + ")"]; + var fonts = ["Default (" + SettingsData.defaultFontFamily + ")"]; var availableFonts = Qt.fontFamilies(); var rootFamilies = []; var seenFamilies = new Set(); @@ -125,7 +125,7 @@ ScrollView { if (fontName.startsWith(".")) continue; - if (fontName === Prefs.defaultFontFamily) + if (fontName === SettingsData.defaultFontFamily) continue; var rootName = fontName.replace(/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i, "").replace(/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i, "").replace(/ (UI|Display|Text|Mono|Sans|Serif)$/i, function(match, suffix) { @@ -140,9 +140,9 @@ ScrollView { } onValueChanged: (value) => { if (value.startsWith("Default (")) - Prefs.setFontFamily(Prefs.defaultFontFamily); + SettingsData.setFontFamily(SettingsData.defaultFontFamily); else - Prefs.setFontFamily(value); + SettingsData.setFontFamily(value); } } @@ -151,7 +151,7 @@ ScrollView { text: "Font Weight" description: "Select font weight" currentValue: { - switch (Prefs.fontWeight) { + switch (SettingsData.fontWeight) { case Font.Thin: return "Thin"; case Font.ExtraLight: @@ -209,7 +209,7 @@ ScrollView { weight = Font.Normal; break; } - Prefs.setFontWeight(weight); + SettingsData.setFontWeight(weight); } } @@ -218,10 +218,10 @@ ScrollView { text: "Monospace Font" description: "Select monospace font for process list and technical displays" currentValue: { - if (Prefs.monoFontFamily === Prefs.defaultMonoFontFamily) + if (SettingsData.monoFontFamily === SettingsData.defaultMonoFontFamily) return "Default"; - return Prefs.monoFontFamily || "Default"; + return SettingsData.monoFontFamily || "Default"; } enableFuzzySearch: true popupWidthOffset: 100 @@ -236,7 +236,7 @@ ScrollView { if (fontName.startsWith(".")) continue; - if (fontName === Prefs.defaultMonoFontFamily) + if (fontName === SettingsData.defaultMonoFontFamily) continue; var lowerName = fontName.toLowerCase(); @@ -252,9 +252,9 @@ ScrollView { } onValueChanged: (value) => { if (value === "Default") - Prefs.setMonoFontFamily(Prefs.defaultMonoFontFamily); + SettingsData.setMonoFontFamily(SettingsData.defaultMonoFontFamily); else - Prefs.setMonoFontFamily(value); + SettingsData.setMonoFontFamily(value); } } @@ -312,13 +312,13 @@ ScrollView { DankSlider { width: parent.width height: 24 - value: Math.round(Prefs.topBarTransparency * 100) + value: Math.round(SettingsData.topBarTransparency * 100) minimum: 0 maximum: 100 unit: "" showValue: true onSliderValueChanged: (newValue) => { - Prefs.setTopBarTransparency(newValue / 100); + SettingsData.setTopBarTransparency(newValue / 100); } } @@ -338,13 +338,13 @@ ScrollView { DankSlider { width: parent.width height: 24 - value: Math.round(Prefs.topBarWidgetTransparency * 100) + value: Math.round(SettingsData.topBarWidgetTransparency * 100) minimum: 0 maximum: 100 unit: "" showValue: true onSliderValueChanged: (newValue) => { - Prefs.setTopBarWidgetTransparency(newValue / 100); + SettingsData.setTopBarWidgetTransparency(newValue / 100); } } @@ -364,13 +364,13 @@ ScrollView { DankSlider { width: parent.width height: 24 - value: Math.round(Prefs.popupTransparency * 100) + value: Math.round(SettingsData.popupTransparency * 100) minimum: 0 maximum: 100 unit: "" showValue: true onSliderValueChanged: (newValue) => { - Prefs.setPopupTransparency(newValue / 100); + SettingsData.setPopupTransparency(newValue / 100); } } @@ -790,9 +790,9 @@ ScrollView { text: "Theme GTK Applications" description: Colors.gtkThemingEnabled ? "File managers, text editors, and system dialogs will match your theme" : "GTK theming not available (install gsettings)" enabled: Colors.gtkThemingEnabled - checked: Colors.gtkThemingEnabled && Prefs.gtkThemingEnabled + checked: Colors.gtkThemingEnabled && SettingsData.gtkThemingEnabled onToggled: function(checked) { - Prefs.setGtkThemingEnabled(checked); + SettingsData.setGtkThemingEnabled(checked); if (checked && Theme.isDynamicTheme) Colors.generateGtkThemes(); @@ -804,9 +804,9 @@ ScrollView { text: "Theme Qt Applications" description: Colors.qtThemingEnabled ? "Qt applications will match your theme colors" : "Qt theming not available (install qt5ct or qt6ct)" enabled: Colors.qtThemingEnabled - checked: Colors.qtThemingEnabled && Prefs.qtThemingEnabled + checked: Colors.qtThemingEnabled && SettingsData.qtThemingEnabled onToggled: function(checked) { - Prefs.setQtThemingEnabled(checked); + SettingsData.setQtThemingEnabled(checked); if (checked && Theme.isDynamicTheme) Colors.generateQtThemes(); @@ -826,7 +826,7 @@ ScrollView { running: false onExited: (exitCode) => { if (exitCode !== 0) - Prefs.setNightModeEnabled(true); + SettingsData.setNightModeEnabled(true); } } @@ -838,7 +838,7 @@ ScrollView { running: false onExited: (exitCode) => { if (exitCode !== 0) - Prefs.setNightModeEnabled(false); + SettingsData.setNightModeEnabled(false); } } diff --git a/Modules/Settings/LauncherTab.qml b/Modules/Settings/LauncherTab.qml index 27fad8f2..23ac4473 100644 --- a/Modules/Settings/LauncherTab.qml +++ b/Modules/Settings/LauncherTab.qml @@ -37,16 +37,16 @@ ScrollView { width: parent.width text: "Use OS Logo" description: "Display operating system logo instead of apps icon" - checked: Prefs.useOSLogo + checked: SettingsData.useOSLogo onToggled: (checked) => { - return Prefs.setUseOSLogo(checked); + return SettingsData.setUseOSLogo(checked); } } Row { width: parent.width - Theme.spacingL spacing: Theme.spacingL - visible: Prefs.useOSLogo + visible: SettingsData.useOSLogo opacity: visible ? 1 : 0 anchors.left: parent.left anchors.leftMargin: Theme.spacingL @@ -66,7 +66,7 @@ ScrollView { width: 100 height: 28 placeholderText: "#ffffff" - text: Prefs.osLogoColorOverride + text: SettingsData.osLogoColorOverride maximumLength: 7 font.pixelSize: Theme.fontSizeSmall topPadding: Theme.spacingXS @@ -74,9 +74,9 @@ ScrollView { onEditingFinished: { var color = text.trim(); if (color === "" || /^#[0-9A-Fa-f]{6}$/.test(color)) - Prefs.setOSLogoColorOverride(color); + SettingsData.setOSLogoColorOverride(color); else - text = Prefs.osLogoColorOverride; + text = SettingsData.osLogoColorOverride; } } @@ -98,11 +98,11 @@ ScrollView { height: 20 minimum: 0 maximum: 100 - value: Math.round(Prefs.osLogoBrightness * 100) + value: Math.round(SettingsData.osLogoBrightness * 100) unit: "%" showValue: true onSliderValueChanged: (newValue) => { - Prefs.setOSLogoBrightness(newValue / 100); + SettingsData.setOSLogoBrightness(newValue / 100); } } @@ -124,11 +124,11 @@ ScrollView { height: 20 minimum: 0 maximum: 200 - value: Math.round(Prefs.osLogoContrast * 100) + value: Math.round(SettingsData.osLogoContrast * 100) unit: "%" showValue: true onSliderValueChanged: (newValue) => { - Prefs.setOSLogoContrast(newValue / 100); + SettingsData.setOSLogoContrast(newValue / 100); } } @@ -187,9 +187,9 @@ ScrollView { width: parent.width text: "Show Dock" description: "Display a dock at the bottom of the screen with pinned and running applications" - checked: Prefs.showDock + checked: SettingsData.showDock onToggled: (checked) => { - Prefs.setShowDock(checked) + SettingsData.setShowDock(checked) } } @@ -197,11 +197,11 @@ ScrollView { width: parent.width text: "Auto-hide Dock" description: "Hide the dock when not in use and reveal it when hovering near the bottom of the screen" - checked: Prefs.dockAutoHide - visible: Prefs.showDock + checked: SettingsData.dockAutoHide + visible: SettingsData.showDock opacity: visible ? 1 : 0 onToggled: (checked) => { - Prefs.setDockAutoHide(checked) + SettingsData.setDockAutoHide(checked) } Behavior on opacity { @@ -215,7 +215,7 @@ ScrollView { Column { width: parent.width spacing: Theme.spacingS - visible: Prefs.showDock + visible: SettingsData.showDock opacity: visible ? 1 : 0 StyledText { @@ -228,13 +228,13 @@ ScrollView { DankSlider { width: parent.width height: 24 - value: Math.round(Prefs.dockTransparency * 100) + value: Math.round(SettingsData.dockTransparency * 100) minimum: 0 maximum: 100 unit: "" showValue: true onSliderValueChanged: (newValue) => { - Prefs.setDockTransparency(newValue / 100); + SettingsData.setDockTransparency(newValue / 100); } } @@ -262,8 +262,8 @@ ScrollView { property var rankedAppsModel: { var apps = []; - for (var appId in Prefs.appUsageRanking) { - var appData = Prefs.appUsageRanking[appId]; + for (var appId in AppUsageHistoryData.appUsageRanking) { + var appData = AppUsageHistoryData.appUsageRanking[appId]; apps.push({ "id": appId, "name": appData.name, @@ -320,9 +320,9 @@ ScrollView { hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) anchors.verticalCenter: parent.verticalCenter onClicked: { - Prefs.appUsageRanking = { + AppUsageHistoryData.appUsageRanking = { }; - Prefs.saveSettings(); + SettingsData.saveSettings(); } } @@ -438,10 +438,10 @@ ScrollView { hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) onClicked: { var currentRanking = Object.assign({ - }, Prefs.appUsageRanking); + }, AppUsageHistoryData.appUsageRanking); delete currentRanking[modelData.id]; - Prefs.appUsageRanking = currentRanking; - Prefs.saveSettings(); + AppUsageHistoryData.appUsageRanking = currentRanking; + SettingsData.saveSettings(); } } diff --git a/Modules/Settings/PersonalizationTab.qml b/Modules/Settings/PersonalizationTab.qml index 44b9fcb3..f61bbe4d 100644 --- a/Modules/Settings/PersonalizationTab.qml +++ b/Modules/Settings/PersonalizationTab.qml @@ -334,9 +334,9 @@ ScrollView { CachingImage { anchors.fill: parent anchors.margins: 1 - imagePath: Prefs.wallpaperPath || "" + imagePath: SessionData.wallpaperPath || "" fillMode: Image.PreserveAspectCrop - visible: Prefs.wallpaperPath !== "" + visible: SessionData.wallpaperPath !== "" maxCacheSize: 160 layer.enabled: true @@ -365,7 +365,7 @@ ScrollView { name: "image" size: Theme.iconSizeLarge + 8 color: Theme.surfaceVariantText - visible: Prefs.wallpaperPath === "" + visible: SessionData.wallpaperPath === "" } } @@ -376,7 +376,7 @@ ScrollView { anchors.verticalCenter: parent.verticalCenter StyledText { - text: Prefs.wallpaperPath ? Prefs.wallpaperPath.split('/').pop() : "No wallpaper selected" + text: SessionData.wallpaperPath ? SessionData.wallpaperPath.split('/').pop() : "No wallpaper selected" font.pixelSize: Theme.fontSizeLarge color: Theme.surfaceText elide: Text.ElideMiddle @@ -384,12 +384,12 @@ ScrollView { } StyledText { - text: Prefs.wallpaperPath ? Prefs.wallpaperPath : "" + text: SessionData.wallpaperPath ? SessionData.wallpaperPath : "" font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceVariantText elide: Text.ElideMiddle width: parent.width - visible: Prefs.wallpaperPath !== "" + visible: SessionData.wallpaperPath !== "" } Row { @@ -437,7 +437,7 @@ ScrollView { height: 32 radius: Theme.cornerRadius color: Theme.surfaceVariant - opacity: Prefs.wallpaperPath !== "" ? 1 : 0.5 + opacity: SessionData.wallpaperPath !== "" ? 1 : 0.5 Row { anchors.centerIn: parent @@ -461,10 +461,10 @@ ScrollView { MouseArea { anchors.fill: parent - enabled: Prefs.wallpaperPath !== "" + enabled: SessionData.wallpaperPath !== "" cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor onClicked: { - Prefs.setWallpaperPath(""); + SessionData.setWallpaper(""); } } @@ -593,7 +593,7 @@ ScrollView { browserType: "wallpaper" fileExtensions: ["*.jpg", "*.jpeg", "*.png", "*.bmp", "*.gif", "*.webp"] onFileSelected: (path) => { - Prefs.setWallpaperPath(path); + SessionData.setWallpaper(path); visible = false; } onDialogClosed: {} diff --git a/Modules/Settings/TimeWeatherTab.qml b/Modules/Settings/TimeWeatherTab.qml index 5d0e45aa..3e46417d 100644 --- a/Modules/Settings/TimeWeatherTab.qml +++ b/Modules/Settings/TimeWeatherTab.qml @@ -55,9 +55,9 @@ ScrollView { width: parent.width text: "24-Hour Format" description: "Use 24-hour time format instead of 12-hour AM/PM" - checked: Prefs.use24HourClock + checked: SettingsData.use24HourClock onToggled: (checked) => { - return Prefs.setClockFormat(checked); + return SettingsData.setClockFormat(checked); } } @@ -105,9 +105,9 @@ ScrollView { width: parent.width text: "Enable Weather" description: "Show weather information in top bar and centcom center" - checked: Prefs.weatherEnabled + checked: SettingsData.weatherEnabled onToggled: (checked) => { - return Prefs.setWeatherEnabled(checked); + return SettingsData.setWeatherEnabled(checked); } } @@ -115,10 +115,10 @@ ScrollView { width: parent.width text: "Fahrenheit" description: "Use Fahrenheit instead of Celsius for temperature" - checked: Prefs.useFahrenheit - enabled: Prefs.weatherEnabled + checked: SettingsData.useFahrenheit + enabled: SettingsData.weatherEnabled onToggled: (checked) => { - return Prefs.setTemperatureUnit(checked); + return SettingsData.setTemperatureUnit(checked); } } @@ -126,17 +126,17 @@ ScrollView { width: parent.width text: "Auto Location" description: "Allow wttr.in to determine location based on IP address" - checked: Prefs.useAutoLocation - enabled: Prefs.weatherEnabled + checked: SettingsData.useAutoLocation + enabled: SettingsData.weatherEnabled onToggled: (checked) => { - return Prefs.setAutoLocation(checked); + return SettingsData.setAutoLocation(checked); } } Column { width: parent.width spacing: Theme.spacingXS - visible: !Prefs.useAutoLocation && Prefs.weatherEnabled + visible: !SettingsData.useAutoLocation && SettingsData.weatherEnabled StyledText { text: "Location" @@ -147,10 +147,10 @@ ScrollView { DankLocationSearch { width: parent.width - currentLocation: Prefs.weatherLocation + currentLocation: SettingsData.weatherLocation placeholderText: "New York, NY" onLocationSelected: (displayName, coordinates) => { - Prefs.setWeatherLocation(displayName, coordinates); + SettingsData.setWeatherLocation(displayName, coordinates); } } diff --git a/Modules/Settings/WidgetsTab.qml b/Modules/Settings/WidgetsTab.qml index 13455246..fc3a8b65 100644 --- a/Modules/Settings/WidgetsTab.qml +++ b/Modules/Settings/WidgetsTab.qml @@ -141,54 +141,54 @@ ScrollView { var widgets = []; if (targetSection === "left") { - widgets = Prefs.topBarLeftWidgets.slice(); + widgets = SettingsData.topBarLeftWidgets.slice(); widgets.push(widgetObj); - Prefs.setTopBarLeftWidgets(widgets); + SettingsData.setTopBarLeftWidgets(widgets); } else if (targetSection === "center") { - widgets = Prefs.topBarCenterWidgets.slice(); + widgets = SettingsData.topBarCenterWidgets.slice(); widgets.push(widgetObj); - Prefs.setTopBarCenterWidgets(widgets); + SettingsData.setTopBarCenterWidgets(widgets); } else if (targetSection === "right") { - widgets = Prefs.topBarRightWidgets.slice(); + widgets = SettingsData.topBarRightWidgets.slice(); widgets.push(widgetObj); - Prefs.setTopBarRightWidgets(widgets); + SettingsData.setTopBarRightWidgets(widgets); } } function removeWidgetFromSection(sectionId, itemId) { var widgets = []; if (sectionId === "left") { - widgets = Prefs.topBarLeftWidgets.slice(); + widgets = SettingsData.topBarLeftWidgets.slice(); widgets = widgets.filter((widget) => { var widgetId = typeof widget === "string" ? widget : widget.id; return widgetId !== itemId; }); - Prefs.setTopBarLeftWidgets(widgets); + SettingsData.setTopBarLeftWidgets(widgets); } else if (sectionId === "center") { - widgets = Prefs.topBarCenterWidgets.slice(); + widgets = SettingsData.topBarCenterWidgets.slice(); widgets = widgets.filter((widget) => { var widgetId = typeof widget === "string" ? widget : widget.id; return widgetId !== itemId; }); - Prefs.setTopBarCenterWidgets(widgets); + SettingsData.setTopBarCenterWidgets(widgets); } else if (sectionId === "right") { - widgets = Prefs.topBarRightWidgets.slice(); + widgets = SettingsData.topBarRightWidgets.slice(); widgets = widgets.filter((widget) => { var widgetId = typeof widget === "string" ? widget : widget.id; return widgetId !== itemId; }); - Prefs.setTopBarRightWidgets(widgets); + SettingsData.setTopBarRightWidgets(widgets); } } function handleItemEnabledChanged(sectionId, itemId, enabled) { var widgets = []; if (sectionId === "left") - widgets = Prefs.topBarLeftWidgets.slice(); + widgets = SettingsData.topBarLeftWidgets.slice(); else if (sectionId === "center") - widgets = Prefs.topBarCenterWidgets.slice(); + widgets = SettingsData.topBarCenterWidgets.slice(); else if (sectionId === "right") - widgets = Prefs.topBarRightWidgets.slice(); + widgets = SettingsData.topBarRightWidgets.slice(); for (var i = 0; i < widgets.length; i++) { var widget = widgets[i]; var widgetId = typeof widget === "string" ? widget : widget.id; @@ -205,30 +205,30 @@ ScrollView { } } if (sectionId === "left") - Prefs.setTopBarLeftWidgets(widgets); + SettingsData.setTopBarLeftWidgets(widgets); else if (sectionId === "center") - Prefs.setTopBarCenterWidgets(widgets); + SettingsData.setTopBarCenterWidgets(widgets); else if (sectionId === "right") - Prefs.setTopBarRightWidgets(widgets); + SettingsData.setTopBarRightWidgets(widgets); } function handleItemOrderChanged(sectionId, newOrder) { if (sectionId === "left") - Prefs.setTopBarLeftWidgets(newOrder); + SettingsData.setTopBarLeftWidgets(newOrder); else if (sectionId === "center") - Prefs.setTopBarCenterWidgets(newOrder); + SettingsData.setTopBarCenterWidgets(newOrder); else if (sectionId === "right") - Prefs.setTopBarRightWidgets(newOrder); + SettingsData.setTopBarRightWidgets(newOrder); } function handleSpacerSizeChanged(sectionId, itemId, newSize) { var widgets = []; if (sectionId === "left") - widgets = Prefs.topBarLeftWidgets.slice(); + widgets = SettingsData.topBarLeftWidgets.slice(); else if (sectionId === "center") - widgets = Prefs.topBarCenterWidgets.slice(); + widgets = SettingsData.topBarCenterWidgets.slice(); else if (sectionId === "right") - widgets = Prefs.topBarRightWidgets.slice(); + widgets = SettingsData.topBarRightWidgets.slice(); for (var i = 0; i < widgets.length; i++) { var widget = widgets[i]; var widgetId = typeof widget === "string" ? widget : widget.id; @@ -246,22 +246,22 @@ ScrollView { } } if (sectionId === "left") - Prefs.setTopBarLeftWidgets(widgets); + SettingsData.setTopBarLeftWidgets(widgets); else if (sectionId === "center") - Prefs.setTopBarCenterWidgets(widgets); + SettingsData.setTopBarCenterWidgets(widgets); else if (sectionId === "right") - Prefs.setTopBarRightWidgets(widgets); + SettingsData.setTopBarRightWidgets(widgets); } function getItemsForSection(sectionId) { var widgets = []; var widgetData = []; if (sectionId === "left") - widgetData = Prefs.topBarLeftWidgets || []; + widgetData = SettingsData.topBarLeftWidgets || []; else if (sectionId === "center") - widgetData = Prefs.topBarCenterWidgets || []; + widgetData = SettingsData.topBarCenterWidgets || []; else if (sectionId === "right") - widgetData = Prefs.topBarRightWidgets || []; + widgetData = SettingsData.topBarRightWidgets || []; widgetData.forEach((widget) => { var widgetId = typeof widget === "string" ? widget : widget.id; var widgetEnabled = typeof widget === "string" ? true : widget.enabled; @@ -285,23 +285,23 @@ ScrollView { contentHeight: column.implicitHeight + Theme.spacingXL clip: true Component.onCompleted: { - if (!Prefs.topBarLeftWidgets || Prefs.topBarLeftWidgets.length === 0) - Prefs.setTopBarLeftWidgets(defaultLeftWidgets); + if (!SettingsData.topBarLeftWidgets || SettingsData.topBarLeftWidgets.length === 0) + SettingsData.setTopBarLeftWidgets(defaultLeftWidgets); - if (!Prefs.topBarCenterWidgets || Prefs.topBarCenterWidgets.length === 0) - Prefs.setTopBarCenterWidgets(defaultCenterWidgets); + if (!SettingsData.topBarCenterWidgets || SettingsData.topBarCenterWidgets.length === 0) + SettingsData.setTopBarCenterWidgets(defaultCenterWidgets); - if (!Prefs.topBarRightWidgets || Prefs.topBarRightWidgets.length === 0) - Prefs.setTopBarRightWidgets(defaultRightWidgets); + if (!SettingsData.topBarRightWidgets || SettingsData.topBarRightWidgets.length === 0) + SettingsData.setTopBarRightWidgets(defaultRightWidgets); ["left", "center", "right"].forEach((sectionId) => { var widgets = []; if (sectionId === "left") - widgets = Prefs.topBarLeftWidgets.slice(); + widgets = SettingsData.topBarLeftWidgets.slice(); else if (sectionId === "center") - widgets = Prefs.topBarCenterWidgets.slice(); + widgets = SettingsData.topBarCenterWidgets.slice(); else if (sectionId === "right") - widgets = Prefs.topBarRightWidgets.slice(); + widgets = SettingsData.topBarRightWidgets.slice(); var updated = false; for (var i = 0; i < widgets.length; i++) { var widget = widgets[i]; @@ -315,11 +315,11 @@ ScrollView { } if (updated) { if (sectionId === "left") - Prefs.setTopBarLeftWidgets(widgets); + SettingsData.setTopBarLeftWidgets(widgets); else if (sectionId === "center") - Prefs.setTopBarCenterWidgets(widgets); + SettingsData.setTopBarCenterWidgets(widgets); else if (sectionId === "right") - Prefs.setTopBarRightWidgets(widgets); + SettingsData.setTopBarRightWidgets(widgets); } }); } @@ -393,9 +393,9 @@ ScrollView { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - Prefs.setTopBarLeftWidgets(defaultLeftWidgets); - Prefs.setTopBarCenterWidgets(defaultCenterWidgets); - Prefs.setTopBarRightWidgets(defaultRightWidgets); + SettingsData.setTopBarLeftWidgets(defaultLeftWidgets); + SettingsData.setTopBarCenterWidgets(defaultCenterWidgets); + SettingsData.setTopBarRightWidgets(defaultRightWidgets); } } @@ -473,9 +473,9 @@ ScrollView { } onCompactModeChanged: (widgetId, enabled) => { if (widgetId === "clock") { - Prefs.setClockCompactMode(enabled); + SettingsData.setClockCompactMode(enabled); } else if (widgetId === "music") { - Prefs.setMediaCompactMode(enabled); + SettingsData.setMediaCompactMode(enabled); } } } @@ -506,9 +506,9 @@ ScrollView { } onCompactModeChanged: (widgetId, enabled) => { if (widgetId === "clock") { - Prefs.setClockCompactMode(enabled); + SettingsData.setClockCompactMode(enabled); } else if (widgetId === "music") { - Prefs.setMediaCompactMode(enabled); + SettingsData.setMediaCompactMode(enabled); } } } @@ -539,9 +539,9 @@ ScrollView { } onCompactModeChanged: (widgetId, enabled) => { if (widgetId === "clock") { - Prefs.setClockCompactMode(enabled); + SettingsData.setClockCompactMode(enabled); } else if (widgetId === "music") { - Prefs.setMediaCompactMode(enabled); + SettingsData.setMediaCompactMode(enabled); } } } @@ -588,9 +588,9 @@ ScrollView { width: parent.width text: "Workspace Index Numbers" description: "Show workspace index numbers in the top bar workspace switcher" - checked: Prefs.showWorkspaceIndex + checked: SettingsData.showWorkspaceIndex onToggled: (checked) => { - return Prefs.setShowWorkspaceIndex(checked); + return SettingsData.setShowWorkspaceIndex(checked); } } @@ -598,9 +598,9 @@ ScrollView { width: parent.width text: "Workspace Padding" description: "Always show a minimum of 3 workspaces, even if fewer are available" - checked: Prefs.showWorkspacePadding + checked: SettingsData.showWorkspacePadding onToggled: (checked) => { - return Prefs.setShowWorkspacePadding(checked); + return SettingsData.setShowWorkspacePadding(checked); } } diff --git a/Modules/TopBar/Clock.qml b/Modules/TopBar/Clock.qml index 24dcff08..bd2a70e2 100644 --- a/Modules/TopBar/Clock.qml +++ b/Modules/TopBar/Clock.qml @@ -32,7 +32,7 @@ Rectangle { spacing: Theme.spacingS StyledText { - text: Prefs.use24HourClock ? Qt.formatTime(root.currentDate, "H:mm") : Qt.formatTime(root.currentDate, "h:mm AP") + text: SettingsData.use24HourClock ? Qt.formatTime(root.currentDate, "H:mm") : Qt.formatTime(root.currentDate, "h:mm AP") font.pixelSize: Theme.fontSizeMedium - 1 color: Theme.surfaceText anchors.verticalCenter: parent.verticalCenter @@ -43,7 +43,7 @@ Rectangle { font.pixelSize: Theme.fontSizeSmall color: Theme.outlineButton anchors.verticalCenter: parent.verticalCenter - visible: !Prefs.clockCompactMode + visible: !SettingsData.clockCompactMode } StyledText { @@ -51,7 +51,7 @@ Rectangle { font.pixelSize: Theme.fontSizeMedium - 1 color: Theme.surfaceText anchors.verticalCenter: parent.verticalCenter - visible: !Prefs.clockCompactMode + visible: !SettingsData.clockCompactMode } } diff --git a/Modules/TopBar/LauncherButton.qml b/Modules/TopBar/LauncherButton.qml index 6601724a..8386e8fe 100644 --- a/Modules/TopBar/LauncherButton.qml +++ b/Modules/TopBar/LauncherButton.qml @@ -22,17 +22,17 @@ Rectangle { } SystemLogo { - visible: Prefs.useOSLogo + visible: SettingsData.useOSLogo anchors.centerIn: parent width: Theme.iconSize - 3 height: Theme.iconSize - 3 - colorOverride: Prefs.osLogoColorOverride - brightnessOverride: Prefs.osLogoBrightness - contrastOverride: Prefs.osLogoContrast + colorOverride: SettingsData.osLogoColorOverride + brightnessOverride: SettingsData.osLogoBrightness + contrastOverride: SettingsData.osLogoContrast } DankIcon { - visible: !Prefs.useOSLogo + visible: !SettingsData.useOSLogo anchors.centerIn: parent name: "apps" size: Theme.iconSize - 6 diff --git a/Modules/TopBar/Media.qml b/Modules/TopBar/Media.qml index 9cce891b..8bc9a108 100644 --- a/Modules/TopBar/Media.qml +++ b/Modules/TopBar/Media.qml @@ -33,7 +33,7 @@ Rectangle { PropertyChanges { target: root opacity: 1 - width: Prefs.mediaCompactMode ? compactContentWidth : normalContentWidth + width: SettingsData.mediaCompactMode ? compactContentWidth : normalContentWidth } }, @@ -100,8 +100,8 @@ Rectangle { id: mediaText anchors.verticalCenter: parent.verticalCenter - width: Prefs.mediaCompactMode ? 60 : 140 - visible: !Prefs.mediaCompactMode + width: SettingsData.mediaCompactMode ? 60 : 140 + visible: !SettingsData.mediaCompactMode text: { if (!activePlayer || !activePlayer.trackTitle) return ""; diff --git a/Modules/TopBar/NotificationCenterButton.qml b/Modules/TopBar/NotificationCenterButton.qml index a29991bd..eafeb188 100644 --- a/Modules/TopBar/NotificationCenterButton.qml +++ b/Modules/TopBar/NotificationCenterButton.qml @@ -23,9 +23,9 @@ Rectangle { DankIcon { anchors.centerIn: parent - name: Prefs.doNotDisturb ? "notifications_off" : "notifications" + name: SessionData.doNotDisturb ? "notifications_off" : "notifications" size: Theme.iconSize - 6 - color: Prefs.doNotDisturb ? Theme.error : (notificationArea.containsMouse || root.isActive ? Theme.primary : Theme.surfaceText) + color: SessionData.doNotDisturb ? Theme.error : (notificationArea.containsMouse || root.isActive ? Theme.primary : Theme.surfaceText) } Rectangle { diff --git a/Modules/TopBar/TopBar.qml b/Modules/TopBar/TopBar.qml index 43e89ef1..f7aa1a82 100644 --- a/Modules/TopBar/TopBar.qml +++ b/Modules/TopBar/TopBar.qml @@ -18,7 +18,7 @@ PanelWindow { property var modelData property string screenName: modelData.name - property real backgroundTransparency: Prefs.topBarTransparency + property real backgroundTransparency: SettingsData.topBarTransparency readonly property int notificationCount: NotificationService.notifications.length screen: modelData @@ -29,7 +29,7 @@ PanelWindow { if (fonts.indexOf("Material Symbols Rounded") === -1) ToastService.showError("Please install Material Symbols Rounded and Restart your Shell. See README.md for instructions"); - Prefs.forceTopBarLayoutRefresh.connect(function() { + SettingsData.forceTopBarLayoutRefresh.connect(function() { Qt.callLater(() => { leftSection.visible = false; centerSection.visible = false; @@ -45,10 +45,10 @@ PanelWindow { Connections { function onTopBarTransparencyChanged() { - root.backgroundTransparency = Prefs.topBarTransparency; + root.backgroundTransparency = SettingsData.topBarTransparency; } - target: Prefs + target: SettingsData } Connections { @@ -246,7 +246,7 @@ PanelWindow { anchors.verticalCenter: parent.verticalCenter Repeater { - model: Prefs.topBarLeftWidgetsModel + model: SettingsData.topBarLeftWidgetsModel Loader { property string widgetId: model.widgetId @@ -367,7 +367,7 @@ PanelWindow { Repeater { id: centerRepeater - model: Prefs.topBarCenterWidgetsModel + model: SettingsData.topBarCenterWidgetsModel Loader { property string widgetId: model.widgetId @@ -401,7 +401,7 @@ PanelWindow { Qt.callLater(centerSection.updateLayout); } - target: Prefs.topBarCenterWidgetsModel + target: SettingsData.topBarCenterWidgetsModel } } @@ -415,7 +415,7 @@ PanelWindow { anchors.verticalCenter: parent.verticalCenter Repeater { - model: Prefs.topBarRightWidgetsModel + model: SettingsData.topBarRightWidgetsModel Loader { property string widgetId: model.widgetId diff --git a/Modules/TopBar/Weather.qml b/Modules/TopBar/Weather.qml index f3c1d3af..64eab012 100644 --- a/Modules/TopBar/Weather.qml +++ b/Modules/TopBar/Weather.qml @@ -12,7 +12,7 @@ Rectangle { signal clicked() - visible: Prefs.weatherEnabled + visible: SettingsData.weatherEnabled width: visible ? Math.min(100, weatherRow.implicitWidth + Theme.spacingS * 2) : 0 height: 30 radius: Theme.cornerRadius @@ -39,7 +39,7 @@ Rectangle { } StyledText { - text: (Prefs.useFahrenheit ? WeatherService.weather.tempF : WeatherService.weather.temp) + "°" + (Prefs.useFahrenheit ? "F" : "C") + text: (SettingsData.useFahrenheit ? WeatherService.weather.tempF : WeatherService.weather.temp) + "°" + (SettingsData.useFahrenheit ? "F" : "C") font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceText anchors.verticalCenter: parent.verticalCenter diff --git a/Modules/TopBar/WorkspaceSwitcher.qml b/Modules/TopBar/WorkspaceSwitcher.qml index 74f0cf73..4a6a9c02 100644 --- a/Modules/TopBar/WorkspaceSwitcher.qml +++ b/Modules/TopBar/WorkspaceSwitcher.qml @@ -12,7 +12,7 @@ Rectangle { property int currentWorkspace: getDisplayActiveWorkspace() property var workspaceList: { var baseList = getDisplayWorkspaces(); - return Prefs.showWorkspacePadding ? padWorkspaces(baseList) : baseList; + return SettingsData.showWorkspacePadding ? padWorkspaces(baseList) : baseList; } function padWorkspaces(list) { @@ -54,7 +54,7 @@ Rectangle { return 1; } - width: Prefs.showWorkspacePadding ? Math.max(120, workspaceRow.implicitWidth + Theme.spacingL * 2) : workspaceRow.implicitWidth + Theme.spacingL * 2 + width: SettingsData.showWorkspacePadding ? Math.max(120, workspaceRow.implicitWidth + Theme.spacingL * 2) : workspaceRow.implicitWidth + Theme.spacingL * 2 height: 30 radius: Theme.cornerRadiusLarge color: { @@ -65,7 +65,7 @@ Rectangle { Connections { function onAllWorkspacesChanged() { - root.workspaceList = Prefs.showWorkspacePadding ? root.padWorkspaces(root.getDisplayWorkspaces()) : root.getDisplayWorkspaces(); + root.workspaceList = SettingsData.showWorkspacePadding ? root.padWorkspaces(root.getDisplayWorkspaces()) : root.getDisplayWorkspaces(); root.currentWorkspace = root.getDisplayActiveWorkspace(); } @@ -75,7 +75,7 @@ Rectangle { function onNiriAvailableChanged() { if (NiriService.niriAvailable) { - root.workspaceList = Prefs.showWorkspacePadding ? root.padWorkspaces(root.getDisplayWorkspaces()) : root.getDisplayWorkspaces(); + root.workspaceList = SettingsData.showWorkspacePadding ? root.padWorkspaces(root.getDisplayWorkspaces()) : root.getDisplayWorkspaces(); root.currentWorkspace = root.getDisplayActiveWorkspace(); } } @@ -86,10 +86,10 @@ Rectangle { Connections { function onShowWorkspacePaddingChanged() { var baseList = root.getDisplayWorkspaces(); - root.workspaceList = Prefs.showWorkspacePadding ? root.padWorkspaces(baseList) : baseList; + root.workspaceList = SettingsData.showWorkspacePadding ? root.padWorkspaces(baseList) : baseList; } - target: Prefs + target: SettingsData } Row { @@ -127,7 +127,7 @@ Rectangle { } StyledText { - visible: Prefs.showWorkspaceIndex + visible: SettingsData.showWorkspaceIndex anchors.centerIn: parent text: isPlaceholder ? sequentialNumber : sequentialNumber color: isActive ? Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95) : isPlaceholder ? Theme.surfaceTextAlpha : Theme.surfaceTextMedium diff --git a/Modules/WallpaperBackground.qml b/Modules/WallpaperBackground.qml index cea9b289..44d31d71 100644 --- a/Modules/WallpaperBackground.qml +++ b/Modules/WallpaperBackground.qml @@ -6,7 +6,7 @@ import qs.Common import qs.Widgets LazyLoader { - active: Prefs.wallpaperPath !== "" + active: SessionData.wallpaperPath !== "" Variants { model: Quickshell.screens @@ -32,7 +32,7 @@ LazyLoader { id: root anchors.fill: parent - property string source: Prefs.wallpaperPath || "" + property string source: SessionData.wallpaperPath || "" property Image current: one onSourceChanged: { diff --git a/Services/NetworkService.qml b/Services/NetworkService.qml index fb8cb3f2..ddc94ae0 100644 --- a/Services/NetworkService.qml +++ b/Services/NetworkService.qml @@ -55,7 +55,7 @@ Singleton { } Component.onCompleted: { - root.userPreference = Prefs.networkPreference + root.userPreference = SettingsData.networkPreference if (root.networkStatus === "wifi" && root.wifiEnabled) { updateCurrentWifiInfo() @@ -402,7 +402,7 @@ Singleton { root.userPreference = preference root.changingPreference = true root.targetPreference = preference - Prefs.setNetworkPreference(preference) + SettingsData.setNetworkPreference(preference) if (preference === "wifi") { // Set WiFi to low route metric (high priority), ethernet to high route metric (low priority) diff --git a/Services/NotificationService.qml b/Services/NotificationService.qml index 44463600..53d8ef0b 100644 --- a/Services/NotificationService.qml +++ b/Services/NotificationService.qml @@ -57,7 +57,7 @@ Singleton { onNotification: notif => { notif.tracked = true; - const shouldShowPopup = !root.popupsDisabled && !Prefs.doNotDisturb; + const shouldShowPopup = !root.popupsDisabled && !SessionData.doNotDisturb; const wrapper = notifComponent.createObject(root, { popup: shouldShowPopup, notification: notif @@ -226,7 +226,7 @@ Singleton { function processQueue() { if (addGateBusy) return; if (popupsDisabled) return; - if (Prefs.doNotDisturb) return; + if (SessionData.doNotDisturb) return; if (notificationQueue.length === 0) return; const [next, ...rest] = notificationQueue; @@ -420,9 +420,9 @@ Singleton { Connections { - target: Prefs + target: SessionData function onDoNotDisturbChanged() { - if (Prefs.doNotDisturb) { + if (SessionData.doNotDisturb) { // Hide all current popups when DND is enabled for (const notif of visibleNotifications) { notif.popup = false; diff --git a/Services/PortalService.qml b/Services/PortalService.qml index 4ef90db7..038c3a8b 100644 --- a/Services/PortalService.qml +++ b/Services/PortalService.qml @@ -149,8 +149,8 @@ Singleton { var shouldBeLightMode = (root.systemColorScheme === 2) if (Theme.isLightMode !== shouldBeLightMode) { Theme.isLightMode = shouldBeLightMode - if (typeof Prefs !== "undefined") { - Prefs.setLightMode(shouldBeLightMode) + if (typeof SessionData !== "undefined") { + SessionData.setLightMode(shouldBeLightMode) } } } diff --git a/Services/WeatherService.qml b/Services/WeatherService.qml index 7b0c8133..5000118e 100644 --- a/Services/WeatherService.qml +++ b/Services/WeatherService.qml @@ -92,13 +92,13 @@ Singleton { } function getWeatherUrl() { - if (Prefs.useAutoLocation) { + if (SettingsData.useAutoLocation) { const url = "wttr.in/?format=j1" console.log("Using auto location, URL:", url) return url } - const location = Prefs.weatherCoordinates || "40.7128,-74.0060" + const location = SettingsData.weatherCoordinates || "40.7128,-74.0060" const url = `wttr.in/${encodeURIComponent(location)}?format=j1` console.log("Using manual location:", location, "URL:", url) return url @@ -107,7 +107,7 @@ Singleton { function addRef() { refCount++; - if (refCount === 1 && !weather.available && Prefs.weatherEnabled) { + if (refCount === 1 && !weather.available && SettingsData.weatherEnabled) { // Start fetching when first consumer appears and weather is enabled fetchWeather(); } @@ -120,7 +120,7 @@ Singleton { function fetchWeather() { // Only fetch if someone is consuming the data and weather is enabled - if (root.refCount === 0 || !Prefs.weatherEnabled) { + if (root.refCount === 0 || !SettingsData.weatherEnabled) { return; } @@ -246,7 +246,7 @@ Singleton { Timer { id: updateTimer interval: root.updateInterval - running: root.refCount > 0 && !IdleService.isIdle && Prefs.weatherEnabled + running: root.refCount > 0 && !IdleService.isIdle && SettingsData.weatherEnabled repeat: true triggeredOnStart: true onTriggered: { @@ -261,7 +261,7 @@ 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 && Prefs.weatherEnabled) { + if (root.refCount > 0 && !root.weather.available && SettingsData.weatherEnabled) { // Trigger immediate update when coming back from idle if no data and weather enabled root.fetchWeather() } @@ -291,7 +291,7 @@ Singleton { } Component.onCompleted: { - Prefs.weatherCoordinatesChanged.connect(() => { + SettingsData.weatherCoordinatesChanged.connect(() => { console.log("Weather location changed, force refreshing weather") root.weather = { available: false, @@ -311,13 +311,13 @@ Singleton { root.forceRefresh() }) - Prefs.weatherLocationChanged.connect(() => { + SettingsData.weatherLocationChanged.connect(() => { console.log("Weather location display name changed") const currentWeather = Object.assign({}, root.weather) root.weather = currentWeather }) - Prefs.useAutoLocationChanged.connect(() => { + SettingsData.useAutoLocationChanged.connect(() => { console.log("Auto location setting changed, force refreshing weather") root.weather = { available: false, @@ -337,12 +337,12 @@ Singleton { root.forceRefresh() }) - Prefs.weatherEnabledChanged.connect(() => { - console.log("Weather enabled setting changed:", Prefs.weatherEnabled) - if (Prefs.weatherEnabled && root.refCount > 0 && !root.weather.available) { + SettingsData.weatherEnabledChanged.connect(() => { + console.log("Weather enabled setting changed:", SettingsData.weatherEnabled) + if (SettingsData.weatherEnabled && root.refCount > 0 && !root.weather.available) { // Start fetching when weather is re-enabled root.forceRefresh() - } else if (!Prefs.weatherEnabled) { + } else if (!SettingsData.weatherEnabled) { // Stop all timers when weather is disabled updateTimer.stop() retryTimer.stop() diff --git a/Widgets/DankGridView.qml b/Widgets/DankGridView.qml index d4288b2c..ca8291a5 100644 --- a/Widgets/DankGridView.qml +++ b/Widgets/DankGridView.qml @@ -102,7 +102,7 @@ GridView { id: iconImg anchors.fill: parent - source: (model.icon) ? Quickshell.iconPath(model.icon, Prefs.iconTheme === "System Default" ? "" : Prefs.iconTheme) : "" + source: (model.icon) ? Quickshell.iconPath(model.icon, SettingsData.iconTheme === "System Default" ? "" : SettingsData.iconTheme) : "" smooth: true asynchronous: true visible: status === Image.Ready diff --git a/Widgets/DankListView.qml b/Widgets/DankListView.qml index c4d29d8f..70e223cb 100644 --- a/Widgets/DankListView.qml +++ b/Widgets/DankListView.qml @@ -89,7 +89,7 @@ ListView { id: iconImg anchors.fill: parent - source: (model.icon) ? Quickshell.iconPath(model.icon, Prefs.iconTheme === "System Default" ? "" : Prefs.iconTheme) : "" + source: (model.icon) ? Quickshell.iconPath(model.icon, SettingsData.iconTheme === "System Default" ? "" : SettingsData.iconTheme) : "" smooth: true asynchronous: true visible: status === Image.Ready diff --git a/Widgets/DankSections.qml b/Widgets/DankSections.qml index 9b410caa..74f87e6d 100644 --- a/Widgets/DankSections.qml +++ b/Widgets/DankSections.qml @@ -141,14 +141,14 @@ Column { id: compactModeButton anchors.fill: parent buttonSize: 32 - iconName: (modelData.id === "clock" && Prefs.clockCompactMode) || (modelData.id === "music" && Prefs.mediaCompactMode) ? "zoom_out" : "zoom_in" + iconName: (modelData.id === "clock" && SettingsData.clockCompactMode) || (modelData.id === "music" && SettingsData.mediaCompactMode) ? "zoom_out" : "zoom_in" iconSize: 18 - iconColor: ((modelData.id === "clock" && Prefs.clockCompactMode) || (modelData.id === "music" && Prefs.mediaCompactMode)) ? Theme.primary : Theme.outline + iconColor: ((modelData.id === "clock" && SettingsData.clockCompactMode) || (modelData.id === "music" && SettingsData.mediaCompactMode)) ? Theme.primary : Theme.outline onClicked: { if (modelData.id === "clock") { - root.compactModeChanged("clock", !Prefs.clockCompactMode); + root.compactModeChanged("clock", !SettingsData.clockCompactMode); } else if (modelData.id === "music") { - root.compactModeChanged("music", !Prefs.mediaCompactMode); + root.compactModeChanged("music", !SettingsData.mediaCompactMode); } } } diff --git a/Widgets/StyledText.qml b/Widgets/StyledText.qml index 836a46dc..8a95df65 100644 --- a/Widgets/StyledText.qml +++ b/Widgets/StyledText.qml @@ -10,8 +10,8 @@ Text { color: Theme.surfaceText font.pixelSize: Appearance.fontSize.normal font.family: { - var requestedFont = isMonospace ? Prefs.monoFontFamily : Prefs.fontFamily; - var defaultFont = isMonospace ? Prefs.defaultMonoFontFamily : Prefs.defaultFontFamily; + var requestedFont = isMonospace ? SettingsData.monoFontFamily : SettingsData.fontFamily; + var defaultFont = isMonospace ? SettingsData.defaultMonoFontFamily : SettingsData.defaultFontFamily; if (requestedFont === defaultFont) { var availableFonts = Qt.fontFamilies(); if (!availableFonts.includes(requestedFont)) @@ -20,7 +20,7 @@ Text { } return requestedFont; } - font.weight: Prefs.fontWeight + font.weight: SettingsData.fontWeight wrapMode: Text.WordWrap elide: Text.ElideRight verticalAlignment: Text.AlignVCenter From 055fee576c1aa9bcb9c66584fc9dafa3d6b1de62 Mon Sep 17 00:00:00 2001 From: bbedward Date: Wed, 6 Aug 2025 12:00:09 -0400 Subject: [PATCH 3/3] switch to state dir and dock fixes --- Common/AppUsageHistoryData.qml | 5 +-- Common/SessionData.qml | 5 +-- Modules/AppDrawer/AppLauncher.qml | 2 +- Modules/Dock/DockApps.qml | 54 +++++++++++++++++++------------ Modules/Settings/LauncherTab.qml | 9 +++--- 5 files changed, 40 insertions(+), 35 deletions(-) diff --git a/Common/AppUsageHistoryData.qml b/Common/AppUsageHistoryData.qml index 9b5fd280..1c65e0f8 100644 --- a/Common/AppUsageHistoryData.qml +++ b/Common/AppUsageHistoryData.qml @@ -12,9 +12,6 @@ Singleton { property var appUsageRanking: {} - readonly property string _configUrl: StandardPaths.writableLocation(StandardPaths.ConfigLocation) - readonly property string _configDir: _configUrl.startsWith("file://") ? _configUrl.substring(7) : _configUrl - Component.onCompleted: { loadSettings(); } @@ -115,7 +112,7 @@ Singleton { FileView { id: settingsFile - path: StandardPaths.writableLocation(StandardPaths.ConfigLocation) + "/DankMaterialShell/appusage.json" + path: StandardPaths.writableLocation(StandardPaths.GenericStateLocation) + "/DankMaterialShell/appusage.json" blockLoading: true blockWrites: true watchChanges: true diff --git a/Common/SessionData.qml b/Common/SessionData.qml index ade99341..32e89d42 100644 --- a/Common/SessionData.qml +++ b/Common/SessionData.qml @@ -17,9 +17,6 @@ Singleton { property bool doNotDisturb: false property var pinnedApps: [] - readonly property string _configUrl: StandardPaths.writableLocation(StandardPaths.ConfigLocation) - readonly property string _configDir: _configUrl.startsWith("file://") ? _configUrl.substring(7) : _configUrl - Component.onCompleted: { loadSettings(); } @@ -115,7 +112,7 @@ Singleton { FileView { id: settingsFile - path: StandardPaths.writableLocation(StandardPaths.ConfigLocation) + "/DankMaterialShell/session.json" + path: StandardPaths.writableLocation(StandardPaths.GenericStateLocation) + "/DankMaterialShell/session.json" blockLoading: true blockWrites: true watchChanges: true diff --git a/Modules/AppDrawer/AppLauncher.qml b/Modules/AppDrawer/AppLauncher.qml index 1ffaf7a4..280508ab 100644 --- a/Modules/AppDrawer/AppLauncher.qml +++ b/Modules/AppDrawer/AppLauncher.qml @@ -29,7 +29,7 @@ Item { property var categoryIcons: categories.map((category) => { return AppSearchService.getCategoryIcon(category); }) - property var appUsageRanking: AppUsageHistoryData.appUsageRanking + property var appUsageRanking: AppUsageHistoryData.appUsageRanking || {} property alias model: filteredModel property var _watchApplications: AppSearchService.applications diff --git a/Modules/Dock/DockApps.qml b/Modules/Dock/DockApps.qml index a710f219..4d0b5f07 100644 --- a/Modules/Dock/DockApps.qml +++ b/Modules/Dock/DockApps.qml @@ -19,7 +19,7 @@ Item { function movePinnedApp(fromIndex, toIndex) { if (fromIndex === toIndex) return - var currentPinned = [...SessionData.pinnedApps] + var currentPinned = [...(SessionData.pinnedApps || [])] if (fromIndex < 0 || fromIndex >= currentPinned.length || toIndex < 0 || toIndex >= currentPinned.length) return var movedApp = currentPinned.splice(fromIndex, 1)[0] @@ -46,9 +46,10 @@ Item { var items = [] var runningApps = NiriService.getRunningAppIds() - var pinnedApps = [...SessionData.pinnedApps] + var pinnedApps = [...(SessionData.pinnedApps || [])] var addedApps = new Set() + pinnedApps.forEach(appId => { var lowerAppId = appId.toLowerCase() if (!addedApps.has(lowerAppId)) { @@ -64,28 +65,39 @@ Item { }) root.pinnedAppCount = pinnedApps.length var appUsageRanking = AppUsageHistoryData.appUsageRanking || {} - var allUnpinnedApps = [] - - for (var appId in appUsageRanking) { - var lowerAppId = appId.toLowerCase() - if (!addedApps.has(lowerAppId)) { - allUnpinnedApps.push({ - appId: appId, - lastUsed: appUsageRanking[appId].lastUsed || 0, - usageCount: appUsageRanking[appId].usageCount || 0 - }) - } - } - - allUnpinnedApps.sort((a, b) => b.lastUsed - a.lastUsed) var unpinnedApps = [] - var recentToAdd = Math.min(3, allUnpinnedApps.length) - for (var i = 0; i < recentToAdd; i++) { - var appId = allUnpinnedApps[i].appId + var unpinnedAppsSet = new Set() + + // First: Add ALL currently running apps that aren't pinned + runningApps.forEach(appId => { var lowerAppId = appId.toLowerCase() - unpinnedApps.push(appId) - addedApps.add(lowerAppId) + if (!addedApps.has(lowerAppId)) { + unpinnedApps.push(appId) + unpinnedAppsSet.add(lowerAppId) + } + }) + + // Then: Fill remaining slots up to 3 with recently used apps + var remainingSlots = Math.max(0, 3 - unpinnedApps.length) + if (remainingSlots > 0) { + // Sort recent apps by usage + var recentApps = [] + for (var appId in appUsageRanking) { + var lowerAppId = appId.toLowerCase() + if (!addedApps.has(lowerAppId) && !unpinnedAppsSet.has(lowerAppId)) { + recentApps.push({ + appId: appId, + lastUsed: appUsageRanking[appId].lastUsed || 0 + }) + } + } + recentApps.sort((a, b) => b.lastUsed - a.lastUsed) + + var recentToAdd = Math.min(remainingSlots, recentApps.length) + for (var i = 0; i < recentToAdd; i++) { + unpinnedApps.push(recentApps[i].appId) + } } if (pinnedApps.length > 0 && unpinnedApps.length > 0) { items.push({ diff --git a/Modules/Settings/LauncherTab.qml b/Modules/Settings/LauncherTab.qml index 23ac4473..4d721647 100644 --- a/Modules/Settings/LauncherTab.qml +++ b/Modules/Settings/LauncherTab.qml @@ -262,8 +262,8 @@ ScrollView { property var rankedAppsModel: { var apps = []; - for (var appId in AppUsageHistoryData.appUsageRanking) { - var appData = AppUsageHistoryData.appUsageRanking[appId]; + for (var appId in (AppUsageHistoryData.appUsageRanking || {})) { + var appData = (AppUsageHistoryData.appUsageRanking || {})[appId]; apps.push({ "id": appId, "name": appData.name, @@ -320,8 +320,7 @@ ScrollView { hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) anchors.verticalCenter: parent.verticalCenter onClicked: { - AppUsageHistoryData.appUsageRanking = { - }; + AppUsageHistoryData.appUsageRanking = {}; SettingsData.saveSettings(); } } @@ -438,7 +437,7 @@ ScrollView { hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) onClicked: { var currentRanking = Object.assign({ - }, AppUsageHistoryData.appUsageRanking); + }, AppUsageHistoryData.appUsageRanking || {}); delete currentRanking[modelData.id]; AppUsageHistoryData.appUsageRanking = currentRanking; SettingsData.saveSettings();