diff --git a/Common/SessionData.qml b/Common/SessionData.qml index 566c0a9a..d7ae9b87 100644 --- a/Common/SessionData.qml +++ b/Common/SessionData.qml @@ -223,37 +223,37 @@ Singleton { console.info("SessionData: Migrating configuration from undefined to version 1") if (typeof SettingsData !== "undefined") { if (settings.acMonitorTimeout !== undefined) { - SettingsData.setAcMonitorTimeout(settings.acMonitorTimeout) + SettingsData.set("acMonitorTimeout", settings.acMonitorTimeout) } if (settings.acLockTimeout !== undefined) { - SettingsData.setAcLockTimeout(settings.acLockTimeout) + SettingsData.set("acLockTimeout", settings.acLockTimeout) } if (settings.acSuspendTimeout !== undefined) { - SettingsData.setAcSuspendTimeout(settings.acSuspendTimeout) + SettingsData.set("acSuspendTimeout", settings.acSuspendTimeout) } if (settings.acHibernateTimeout !== undefined) { - SettingsData.setAcHibernateTimeout(settings.acHibernateTimeout) + SettingsData.set("acHibernateTimeout", settings.acHibernateTimeout) } if (settings.batteryMonitorTimeout !== undefined) { - SettingsData.setBatteryMonitorTimeout(settings.batteryMonitorTimeout) + SettingsData.set("batteryMonitorTimeout", settings.batteryMonitorTimeout) } if (settings.batteryLockTimeout !== undefined) { - SettingsData.setBatteryLockTimeout(settings.batteryLockTimeout) + SettingsData.set("batteryLockTimeout", settings.batteryLockTimeout) } if (settings.batterySuspendTimeout !== undefined) { - SettingsData.setBatterySuspendTimeout(settings.batterySuspendTimeout) + SettingsData.set("batterySuspendTimeout", settings.batterySuspendTimeout) } if (settings.batteryHibernateTimeout !== undefined) { - SettingsData.setBatteryHibernateTimeout(settings.batteryHibernateTimeout) + SettingsData.set("batteryHibernateTimeout", settings.batteryHibernateTimeout) } if (settings.lockBeforeSuspend !== undefined) { - SettingsData.setLockBeforeSuspend(settings.lockBeforeSuspend) + SettingsData.set("lockBeforeSuspend", settings.lockBeforeSuspend) } if (settings.loginctlLockIntegration !== undefined) { - SettingsData.setLoginctlLockIntegration(settings.loginctlLockIntegration) + SettingsData.set("loginctlLockIntegration", settings.loginctlLockIntegration) } if (settings.launchPrefix !== undefined) { - SettingsData.setLaunchPrefix(settings.launchPrefix) + SettingsData.set("launchPrefix", settings.launchPrefix) } } if (typeof CacheData !== "undefined") { diff --git a/Common/SettingsData.qml b/Common/SettingsData.qml index 54791bac..16d45d04 100644 --- a/Common/SettingsData.qml +++ b/Common/SettingsData.qml @@ -7,7 +7,10 @@ import QtQuick import Quickshell import Quickshell.Io import qs.Common +import qs.Common.settings import qs.Services +import "settings/SettingsSpec.js" as Spec +import "settings/SettingsStore.js" as Store Singleton { id: root @@ -299,17 +302,148 @@ Singleton { Component.onCompleted: { if (!isGreeterMode) { + Processes.settingsRoot = root loadSettings() initializeListModels() - fprintdDetectionProcess.running = true - pluginSettingsCheckProcess.running = true + Processes.detectFprintd() + Processes.checkPluginSettings() } } + function applyStoredTheme() { + if (typeof Theme !== "undefined") { + Theme.switchTheme(currentThemeName, false, false) + } else { + Qt.callLater(function() { + if (typeof Theme !== "undefined") { + Theme.switchTheme(currentThemeName, false, false) + } + }) + } + } + + function regenSystemThemes() { + if (typeof Theme !== "undefined") { + Theme.generateSystemThemesFromCurrentTheme() + } + } + + function updateNiriLayout() { + if (typeof NiriService !== "undefined" && typeof CompositorService !== "undefined" && CompositorService.isNiri) { + NiriService.generateNiriLayoutConfig() + } + } + + function applyStoredIconTheme() { + updateGtkIconTheme() + updateQtIconTheme() + } + + function updateGtkIconTheme() { + const gtkThemeName = (iconTheme === "System Default") ? systemDefaultIconTheme : iconTheme + if (gtkThemeName === "System Default" || gtkThemeName === "") return + + if (typeof DMSService !== "undefined" && DMSService.apiVersion >= 3 && typeof PortalService !== "undefined") { + PortalService.setSystemIconTheme(gtkThemeName) + } + + const configScript = `mkdir -p ${_configDir}/gtk-3.0 ${_configDir}/gtk-4.0 + +for config_dir in ${_configDir}/gtk-3.0 ${_configDir}/gtk-4.0; do + settings_file="$config_dir/settings.ini" + if [ -f "$settings_file" ]; then + if grep -q "^gtk-icon-theme-name=" "$settings_file"; then + sed -i 's/^gtk-icon-theme-name=.*/gtk-icon-theme-name=${gtkThemeName}/' "$settings_file" + else + if grep -q "\\[Settings\\]" "$settings_file"; then + sed -i '/\\[Settings\\]/a gtk-icon-theme-name=${gtkThemeName}' "$settings_file" + else + echo -e '\\n[Settings]\\ngtk-icon-theme-name=${gtkThemeName}' >> "$settings_file" + fi + fi + else + echo -e '[Settings]\\ngtk-icon-theme-name=${gtkThemeName}' > "$settings_file" + fi +done + +rm -rf ~/.cache/icon-cache ~/.cache/thumbnails 2>/dev/null || true +pkill -HUP -f 'gtk' 2>/dev/null || true` + + Quickshell.execDetached(["sh", "-lc", configScript]) + } + + function updateQtIconTheme() { + const qtThemeName = (iconTheme === "System Default") ? "" : iconTheme + if (!qtThemeName) return + + const home = _homeUrl.replace("file://", "").replace(/'/g, "'\\''") + const qtThemeNameEscaped = qtThemeName.replace(/'/g, "'\\''") + + const script = `mkdir -p ${_configDir}/qt5ct ${_configDir}/qt6ct ${_configDir}/environment.d 2>/dev/null || true +update_qt_icon_theme() { + local config_file="$1" + local theme_name="$2" + if [ -f "$config_file" ]; then + if grep -q "^\\[Appearance\\]" "$config_file"; then + if grep -q "^icon_theme=" "$config_file"; then + sed -i "s/^icon_theme=.*/icon_theme=$theme_name/" "$config_file" + else + sed -i "/^\\[Appearance\\]/a icon_theme=$theme_name" "$config_file" + fi + else + printf "\\n[Appearance]\\nicon_theme=%s\\n" "$theme_name" >> "$config_file" + fi + else + printf "[Appearance]\\nicon_theme=%s\\n" "$theme_name" > "$config_file" + fi +} +update_qt_icon_theme ${_configDir}/qt5ct/qt5ct.conf '${qtThemeNameEscaped}' +update_qt_icon_theme ${_configDir}/qt6ct/qt6ct.conf '${qtThemeNameEscaped}' +rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || true` + + Quickshell.execDetached(["sh", "-lc", script]) + } + + readonly property var _hooks: ({ + applyStoredTheme: applyStoredTheme, + regenSystemThemes: regenSystemThemes, + updateNiriLayout: updateNiriLayout, + applyStoredIconTheme: applyStoredIconTheme + }) + + function set(key, value) { + Spec.set(root, key, value, saveSettings, _hooks) + } + function loadSettings() { _loading = true - parseSettings(settingsFile.text()) - _loading = false + try { + const txt = settingsFile.text() + const obj = (txt && txt.trim()) ? JSON.parse(txt) : null + Store.parse(root, obj) + const shouldMigrate = Store.migrate(root, obj) + applyStoredTheme() + applyStoredIconTheme() + Processes.detectIcons() + Processes.detectQtTools() + if (obj && obj.configVersion === undefined) { + const cleaned = Store.cleanup(txt) + if (cleaned) { + settingsFile.setText(cleaned) + } + saveSettings() + } + if (shouldMigrate) { + savePluginSettings() + saveSettings() + } + } catch (e) { + console.warn("SettingsData: Failed to load settings:", e.message) + applyStoredTheme() + applyStoredIconTheme() + } finally { + _loading = false + } loadPluginSettings() } @@ -335,479 +469,18 @@ Singleton { } } - function parseSettings(content) { - _loading = true - var shouldMigrate = false - try { - if (content && content.trim()) { - var settings = JSON.parse(content) - if (settings.pluginSettings !== undefined) { - pluginSettings = settings.pluginSettings - shouldMigrate = true - } - if (settings.themeIndex !== undefined || settings.themeIsDynamic !== undefined) { - const themeNames = ["blue", "deepBlue", "purple", "green", "orange", "red", "cyan", "pink", "amber", "coral"] - if (settings.themeIsDynamic) { - currentThemeName = "dynamic" - } else if (settings.themeIndex >= 0 && settings.themeIndex < themeNames.length) { - currentThemeName = themeNames[settings.themeIndex] - } - console.info("Auto-migrated theme from index", settings.themeIndex, "to", currentThemeName) - } else { - currentThemeName = settings.currentThemeName !== undefined ? settings.currentThemeName : "blue" - } - customThemeFile = settings.customThemeFile !== undefined ? settings.customThemeFile : "" - matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot" - runUserMatugenTemplates = settings.runUserMatugenTemplates !== undefined ? settings.runUserMatugenTemplates : true - matugenTargetMonitor = settings.matugenTargetMonitor !== undefined ? settings.matugenTargetMonitor : "" - dankBarTransparency = settings.dankBarTransparency - !== undefined ? (settings.dankBarTransparency > 1 ? settings.dankBarTransparency - / 100 : settings.dankBarTransparency) : (settings.topBarTransparency !== undefined ? (settings.topBarTransparency > 1 ? settings.topBarTransparency / 100 : settings.topBarTransparency) : 1.0) - dankBarWidgetTransparency = settings.dankBarWidgetTransparency - !== undefined ? (settings.dankBarWidgetTransparency - > 1 ? settings.dankBarWidgetTransparency - / 100 : settings.dankBarWidgetTransparency) : (settings.topBarWidgetTransparency !== undefined ? (settings.topBarWidgetTransparency > 1 ? settings.topBarWidgetTransparency / 100 : settings.topBarWidgetTransparency) : 1.0) - popupTransparency = settings.popupTransparency !== undefined ? (settings.popupTransparency > 1 ? settings.popupTransparency / 100 : settings.popupTransparency) : 1.0 - dockTransparency = settings.dockTransparency !== undefined ? (settings.dockTransparency > 1 ? settings.dockTransparency / 100 : settings.dockTransparency) : 1 - use24HourClock = settings.use24HourClock !== undefined ? settings.use24HourClock : true - showSeconds = settings.showSeconds !== undefined ? settings.showSeconds : false - useFahrenheit = settings.useFahrenheit !== undefined ? settings.useFahrenheit : false - nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false - weatherLocation = settings.weatherLocation !== undefined ? settings.weatherLocation : "New York, NY" - weatherCoordinates = settings.weatherCoordinates !== undefined ? settings.weatherCoordinates : "40.7128,-74.0060" - useAutoLocation = settings.useAutoLocation !== undefined ? settings.useAutoLocation : false - weatherEnabled = settings.weatherEnabled !== undefined ? settings.weatherEnabled : true - showLauncherButton = settings.showLauncherButton !== undefined ? settings.showLauncherButton : true - showWorkspaceSwitcher = settings.showWorkspaceSwitcher !== undefined ? settings.showWorkspaceSwitcher : true - showFocusedWindow = settings.showFocusedWindow !== undefined ? settings.showFocusedWindow : true - showWeather = settings.showWeather !== undefined ? settings.showWeather : true - showMusic = settings.showMusic !== undefined ? settings.showMusic : true - showClipboard = settings.showClipboard !== undefined ? settings.showClipboard : true - showCpuUsage = settings.showCpuUsage !== undefined ? settings.showCpuUsage : true - showMemUsage = settings.showMemUsage !== undefined ? settings.showMemUsage : true - showCpuTemp = settings.showCpuTemp !== undefined ? settings.showCpuTemp : true - showGpuTemp = settings.showGpuTemp !== undefined ? settings.showGpuTemp : true - selectedGpuIndex = settings.selectedGpuIndex !== undefined ? settings.selectedGpuIndex : 0 - enabledGpuPciIds = settings.enabledGpuPciIds !== undefined ? settings.enabledGpuPciIds : [] - showSystemTray = settings.showSystemTray !== undefined ? settings.showSystemTray : true - showClock = settings.showClock !== undefined ? settings.showClock : true - showNotificationButton = settings.showNotificationButton !== undefined ? settings.showNotificationButton : true - showBattery = settings.showBattery !== undefined ? settings.showBattery : true - showControlCenterButton = settings.showControlCenterButton !== undefined ? settings.showControlCenterButton : true - controlCenterShowNetworkIcon = settings.controlCenterShowNetworkIcon !== undefined ? settings.controlCenterShowNetworkIcon : true - controlCenterShowBluetoothIcon = settings.controlCenterShowBluetoothIcon !== undefined ? settings.controlCenterShowBluetoothIcon : true - controlCenterShowAudioIcon = settings.controlCenterShowAudioIcon !== undefined ? settings.controlCenterShowAudioIcon : true - controlCenterWidgets = settings.controlCenterWidgets !== undefined ? settings.controlCenterWidgets : [{ - "id": "volumeSlider", - "enabled": true, - "width": 50 - }, { - "id": "brightnessSlider", - "enabled": true, - "width": 50 - }, { - "id": "wifi", - "enabled": true, - "width": 50 - }, { - "id": "bluetooth", - "enabled": true, - "width": 50 - }, { - "id": "audioOutput", - "enabled": true, - "width": 50 - }, { - "id": "audioInput", - "enabled": true, - "width": 50 - }, { - "id": "nightMode", - "enabled": true, - "width": 50 - }, { - "id": "darkMode", - "enabled": true, - "width": 50 - }] - showWorkspaceIndex = settings.showWorkspaceIndex !== undefined ? settings.showWorkspaceIndex : false - showWorkspacePadding = settings.showWorkspacePadding !== undefined ? settings.showWorkspacePadding : false - workspaceScrolling = settings.workspaceScrolling !== undefined ? settings.workspaceScrolling : false - showWorkspaceApps = settings.showWorkspaceApps !== undefined ? settings.showWorkspaceApps : false - maxWorkspaceIcons = settings.maxWorkspaceIcons !== undefined ? settings.maxWorkspaceIcons : 3 - workspaceNameIcons = settings.workspaceNameIcons !== undefined ? settings.workspaceNameIcons : ({}) - workspacesPerMonitor = settings.workspacesPerMonitor !== undefined ? settings.workspacesPerMonitor : true - dwlShowAllTags = settings.dwlShowAllTags !== undefined ? settings.dwlShowAllTags : false - waveProgressEnabled = settings.waveProgressEnabled !== undefined ? settings.waveProgressEnabled : true - clockCompactMode = settings.clockCompactMode !== undefined ? settings.clockCompactMode : false - focusedWindowCompactMode = settings.focusedWindowCompactMode !== undefined ? settings.focusedWindowCompactMode : false - runningAppsCompactMode = settings.runningAppsCompactMode !== undefined ? settings.runningAppsCompactMode : true - keyboardLayoutNameCompactMode = settings.keyboardLayoutNameCompactMode !== undefined ? settings.keyboardLayoutNameCompactMode : true - runningAppsCurrentWorkspace = settings.runningAppsCurrentWorkspace !== undefined ? settings.runningAppsCurrentWorkspace : false - runningAppsGroupByApp = settings.runningAppsGroupByApp !== undefined ? settings.runningAppsGroupByApp : false - clockDateFormat = settings.clockDateFormat !== undefined ? settings.clockDateFormat : "" - lockDateFormat = settings.lockDateFormat !== undefined ? settings.lockDateFormat : "" - mediaSize = settings.mediaSize !== undefined ? settings.mediaSize : (settings.mediaCompactMode !== undefined ? (settings.mediaCompactMode ? 0 : 1) : 1) - if (settings.dankBarWidgetOrder || settings.topBarWidgetOrder) { - var widgetOrder = settings.dankBarWidgetOrder || settings.topBarWidgetOrder - dankBarLeftWidgets = widgetOrder.filter(w => { - return ["launcherButton", "workspaceSwitcher", "focusedWindow"].includes(w) - }) - dankBarCenterWidgets = widgetOrder.filter(w => { - return ["clock", "music", "weather"].includes(w) - }) - dankBarRightWidgets = widgetOrder.filter(w => { - return ["systemTray", "clipboard", "systemResources", "notificationButton", "battery", "controlCenterButton"].includes(w) - }) - } else { - var leftWidgets = settings.dankBarLeftWidgets !== undefined ? settings.dankBarLeftWidgets : (settings.topBarLeftWidgets !== undefined ? settings.topBarLeftWidgets : ["launcherButton", "workspaceSwitcher", "focusedWindow"]) - var centerWidgets = settings.dankBarCenterWidgets !== undefined ? settings.dankBarCenterWidgets : (settings.topBarCenterWidgets !== undefined ? settings.topBarCenterWidgets : ["music", "clock", "weather"]) - var rightWidgets = settings.dankBarRightWidgets - !== undefined ? settings.dankBarRightWidgets : (settings.topBarRightWidgets !== undefined ? settings.topBarRightWidgets : ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"]) - dankBarLeftWidgets = leftWidgets - dankBarCenterWidgets = centerWidgets - dankBarRightWidgets = rightWidgets - updateListModel(leftWidgetsModel, leftWidgets) - updateListModel(centerWidgetsModel, centerWidgets) - updateListModel(rightWidgetsModel, rightWidgets) - } - appLauncherViewMode = settings.appLauncherViewMode !== undefined ? settings.appLauncherViewMode : "list" - spotlightModalViewMode = settings.spotlightModalViewMode !== undefined ? settings.spotlightModalViewMode : "list" - sortAppsAlphabetically = settings.sortAppsAlphabetically !== undefined ? settings.sortAppsAlphabetically : false - networkPreference = settings.networkPreference !== undefined ? settings.networkPreference : "auto" - vpnLastConnected = settings.vpnLastConnected !== undefined ? settings.vpnLastConnected : "" - iconTheme = settings.iconTheme !== undefined ? settings.iconTheme : "System Default" - if (settings.useOSLogo !== undefined) { - launcherLogoMode = settings.useOSLogo ? "os" : "apps" - launcherLogoColorOverride = settings.osLogoColorOverride !== undefined ? settings.osLogoColorOverride : "" - launcherLogoBrightness = settings.osLogoBrightness !== undefined ? settings.osLogoBrightness : 0.5 - launcherLogoContrast = settings.osLogoContrast !== undefined ? settings.osLogoContrast : 1 - } else { - launcherLogoMode = settings.launcherLogoMode !== undefined ? settings.launcherLogoMode : "apps" - launcherLogoCustomPath = settings.launcherLogoCustomPath !== undefined ? settings.launcherLogoCustomPath : "" - launcherLogoColorOverride = settings.launcherLogoColorOverride !== undefined ? settings.launcherLogoColorOverride : "" - launcherLogoColorInvertOnMode = settings.launcherLogoColorInvertOnMode !== undefined ? settings.launcherLogoColorInvertOnMode : false - launcherLogoBrightness = settings.launcherLogoBrightness !== undefined ? settings.launcherLogoBrightness : 0.5 - launcherLogoContrast = settings.launcherLogoContrast !== undefined ? settings.launcherLogoContrast : 1 - launcherLogoSizeOffset = settings.launcherLogoSizeOffset !== undefined ? settings.launcherLogoSizeOffset : 0 - } - fontFamily = settings.fontFamily !== undefined ? settings.fontFamily : defaultFontFamily - monoFontFamily = settings.monoFontFamily !== undefined ? settings.monoFontFamily : defaultMonoFontFamily - fontWeight = settings.fontWeight !== undefined ? settings.fontWeight : Font.Normal - fontScale = settings.fontScale !== undefined ? settings.fontScale : 1.0 - dankBarFontScale = settings.dankBarFontScale !== undefined ? settings.dankBarFontScale : 1.0 - notepadUseMonospace = settings.notepadUseMonospace !== undefined ? settings.notepadUseMonospace : true - notepadFontFamily = settings.notepadFontFamily !== undefined ? settings.notepadFontFamily : "" - notepadFontSize = settings.notepadFontSize !== undefined ? settings.notepadFontSize : 14 - notepadShowLineNumbers = settings.notepadShowLineNumbers !== undefined ? settings.notepadShowLineNumbers : false - notepadTransparencyOverride = settings.notepadTransparencyOverride !== undefined ? settings.notepadTransparencyOverride : -1 - notepadLastCustomTransparency = settings.notepadLastCustomTransparency !== undefined ? settings.notepadLastCustomTransparency : 0.95 - soundsEnabled = settings.soundsEnabled !== undefined ? settings.soundsEnabled : true - useSystemSoundTheme = settings.useSystemSoundTheme !== undefined ? settings.useSystemSoundTheme : false - soundNewNotification = settings.soundNewNotification !== undefined ? settings.soundNewNotification : true - soundVolumeChanged = settings.soundVolumeChanged !== undefined ? settings.soundVolumeChanged : true - soundPluggedIn = settings.soundPluggedIn !== undefined ? settings.soundPluggedIn : true - gtkThemingEnabled = settings.gtkThemingEnabled !== undefined ? settings.gtkThemingEnabled : false - qtThemingEnabled = settings.qtThemingEnabled !== undefined ? settings.qtThemingEnabled : false - syncModeWithPortal = settings.syncModeWithPortal !== undefined ? settings.syncModeWithPortal : true - showDock = settings.showDock !== undefined ? settings.showDock : false - dockAutoHide = settings.dockAutoHide !== undefined ? settings.dockAutoHide : false - dockGroupByApp = settings.dockGroupByApp !== undefined ? settings.dockGroupByApp : false - dockPosition = settings.dockPosition !== undefined ? settings.dockPosition : SettingsData.Position.Bottom - dockSpacing = settings.dockSpacing !== undefined ? settings.dockSpacing : 4 - dockBottomGap = settings.dockBottomGap !== undefined ? settings.dockBottomGap : 0 - dockIconSize = settings.dockIconSize !== undefined ? settings.dockIconSize : 40 - dockIndicatorStyle = settings.dockIndicatorStyle !== undefined ? settings.dockIndicatorStyle : "circle" - cornerRadius = settings.cornerRadius !== undefined ? settings.cornerRadius : 12 - notificationOverlayEnabled = settings.notificationOverlayEnabled !== undefined ? settings.notificationOverlayEnabled : false - dankBarAutoHide = settings.dankBarAutoHide !== undefined ? settings.dankBarAutoHide : (settings.topBarAutoHide !== undefined ? settings.topBarAutoHide : false) - dankBarOpenOnOverview = settings.dankBarOpenOnOverview !== undefined ? settings.dankBarOpenOnOverview : (settings.topBarOpenOnOverview !== undefined ? settings.topBarOpenOnOverview : false) - dankBarVisible = settings.dankBarVisible !== undefined ? settings.dankBarVisible : (settings.topBarVisible !== undefined ? settings.topBarVisible : true) - dockOpenOnOverview = settings.dockOpenOnOverview !== undefined ? settings.dockOpenOnOverview : false - notificationTimeoutLow = settings.notificationTimeoutLow !== undefined ? settings.notificationTimeoutLow : 5000 - notificationTimeoutNormal = settings.notificationTimeoutNormal !== undefined ? settings.notificationTimeoutNormal : 5000 - notificationTimeoutCritical = settings.notificationTimeoutCritical !== undefined ? settings.notificationTimeoutCritical : 0 - notificationPopupPosition = settings.notificationPopupPosition !== undefined ? settings.notificationPopupPosition : SettingsData.Position.Top - osdAlwaysShowValue = settings.osdAlwaysShowValue !== undefined ? settings.osdAlwaysShowValue : false - powerActionConfirm = settings.powerActionConfirm !== undefined ? settings.powerActionConfirm : true - customPowerActionLock = settings.customPowerActionLock != undefined ? settings.customPowerActionLock : "" - customPowerActionLogout = settings.customPowerActionLogout != undefined ? settings.customPowerActionLogout : "" - customPowerActionSuspend = settings.customPowerActionSuspend != undefined ? settings.customPowerActionSuspend : "" - customPowerActionHibernate = settings.customPowerActionHibernate != undefined ? settings.customPowerActionHibernate : "" - customPowerActionReboot = settings.customPowerActionReboot != undefined ? settings.customPowerActionReboot : "" - customPowerActionPowerOff = settings.customPowerActionPowerOff != undefined ? settings.customPowerActionPowerOff : "" - updaterUseCustomCommand = settings.updaterUseCustomCommand !== undefined ? settings.updaterUseCustomCommand : false - updaterCustomCommand = settings.updaterCustomCommand !== undefined ? settings.updaterCustomCommand : "" - updaterTerminalAdditionalParams = settings.updaterTerminalAdditionalParams !== undefined ? settings.updaterTerminalAdditionalParams : "" - dankBarSpacing = settings.dankBarSpacing !== undefined ? settings.dankBarSpacing : (settings.topBarSpacing !== undefined ? settings.topBarSpacing : 4) - dankBarBottomGap = settings.dankBarBottomGap !== undefined ? settings.dankBarBottomGap : (settings.topBarBottomGap !== undefined ? settings.topBarBottomGap : 0) - dankBarInnerPadding = settings.dankBarInnerPadding !== undefined ? settings.dankBarInnerPadding : (settings.topBarInnerPadding !== undefined ? settings.topBarInnerPadding : 4) - dankBarSquareCorners = settings.dankBarSquareCorners !== undefined ? settings.dankBarSquareCorners : (settings.topBarSquareCorners !== undefined ? settings.topBarSquareCorners : false) - dankBarNoBackground = settings.dankBarNoBackground !== undefined ? settings.dankBarNoBackground : (settings.topBarNoBackground !== undefined ? settings.topBarNoBackground : false) - dankBarGothCornersEnabled = settings.dankBarGothCornersEnabled !== undefined ? settings.dankBarGothCornersEnabled : (settings.topBarGothCornersEnabled !== undefined ? settings.topBarGothCornersEnabled : false) - dankBarBorderEnabled = settings.dankBarBorderEnabled !== undefined ? settings.dankBarBorderEnabled : false - dankBarBorderColor = settings.dankBarBorderColor !== undefined ? settings.dankBarBorderColor : "surfaceText" - dankBarBorderOpacity = settings.dankBarBorderOpacity !== undefined ? settings.dankBarBorderOpacity : 1.0 - dankBarBorderThickness = settings.dankBarBorderThickness !== undefined ? settings.dankBarBorderThickness : 1 - popupGapsAuto = settings.popupGapsAuto !== undefined ? settings.popupGapsAuto : true - popupGapsManual = settings.popupGapsManual !== undefined ? settings.popupGapsManual : 4 - modalDarkenBackground = settings.modalDarkenBackground !== undefined ? settings.modalDarkenBackground : true - dankBarPosition = settings.dankBarPosition - !== undefined ? settings.dankBarPosition : (settings.dankBarAtBottom !== undefined ? (settings.dankBarAtBottom ? SettingsData.Position.Bottom : SettingsData.Position.Top) : (settings.topBarAtBottom !== undefined ? (settings.topBarAtBottom ? SettingsData.Position.Bottom : SettingsData.Position.Top) : SettingsData.Position.Top)) - lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true - enableFprint = settings.enableFprint !== undefined ? settings.enableFprint : false - maxFprintTries = settings.maxFprintTries !== undefined ? settings.maxFprintTries : 3 - hideBrightnessSlider = settings.hideBrightnessSlider !== undefined ? settings.hideBrightnessSlider : false - widgetBackgroundColor = settings.widgetBackgroundColor !== undefined ? settings.widgetBackgroundColor : "sch" - surfaceBase = settings.surfaceBase !== undefined ? settings.surfaceBase : "s" - screenPreferences = settings.screenPreferences !== undefined ? settings.screenPreferences : ({}) - showOnLastDisplay = settings.showOnLastDisplay !== undefined ? settings.showOnLastDisplay : ({}) - wallpaperFillMode = settings.wallpaperFillMode !== undefined ? settings.wallpaperFillMode : "Fill" - blurredWallpaperLayer = settings.blurredWallpaperLayer !== undefined ? settings.blurredWallpaperLayer : false - blurWallpaperOnOverview = settings.blurWallpaperOnOverview !== undefined ? settings.blurWallpaperOnOverview : false - animationSpeed = settings.animationSpeed !== undefined ? settings.animationSpeed : SettingsData.AnimationSpeed.Short - customAnimationDuration = settings.customAnimationDuration !== undefined ? settings.customAnimationDuration : 500 - acMonitorTimeout = settings.acMonitorTimeout !== undefined ? settings.acMonitorTimeout : 0 - acLockTimeout = settings.acLockTimeout !== undefined ? settings.acLockTimeout : 0 - acSuspendTimeout = settings.acSuspendTimeout !== undefined ? settings.acSuspendTimeout : 0 - acHibernateTimeout = settings.acHibernateTimeout !== undefined ? settings.acHibernateTimeout : 0 - batteryMonitorTimeout = settings.batteryMonitorTimeout !== undefined ? settings.batteryMonitorTimeout : 0 - batteryLockTimeout = settings.batteryLockTimeout !== undefined ? settings.batteryLockTimeout : 0 - batterySuspendTimeout = settings.batterySuspendTimeout !== undefined ? settings.batterySuspendTimeout : 0 - batteryHibernateTimeout = settings.batteryHibernateTimeout !== undefined ? settings.batteryHibernateTimeout : 0 - lockBeforeSuspend = settings.lockBeforeSuspend !== undefined ? settings.lockBeforeSuspend : false - loginctlLockIntegration = settings.loginctlLockIntegration !== undefined ? settings.loginctlLockIntegration : true - launchPrefix = settings.launchPrefix !== undefined ? settings.launchPrefix : "" - brightnessDevicePins = settings.brightnessDevicePins !== undefined ? settings.brightnessDevicePins : ({}) - - if (settings.configVersion === undefined) { - migrateFromUndefinedToV1(settings) - cleanupUnusedKeys() - saveSettings() - } - - applyStoredTheme() - detectAvailableIconThemes() - detectQtTools() - updateGtkIconTheme(iconTheme) - applyStoredIconTheme() - } else { - applyStoredTheme() - } - } catch (e) { - applyStoredTheme() - } finally { - _loading = false - } - - if (shouldMigrate) { - savePluginSettings() - saveSettings() - } - } - function saveSettings() { - if (_loading) - return - settingsFile.setText(JSON.stringify({ - "currentThemeName": currentThemeName, - "customThemeFile": customThemeFile, - "matugenScheme": matugenScheme, - "runUserMatugenTemplates": runUserMatugenTemplates, - "matugenTargetMonitor": matugenTargetMonitor, - "dankBarTransparency": dankBarTransparency, - "dankBarWidgetTransparency": dankBarWidgetTransparency, - "popupTransparency": popupTransparency, - "dockTransparency": dockTransparency, - "use24HourClock": use24HourClock, - "showSeconds": showSeconds, - "useFahrenheit": useFahrenheit, - "nightModeEnabled": nightModeEnabled, - "weatherLocation": weatherLocation, - "weatherCoordinates": weatherCoordinates, - "useAutoLocation": useAutoLocation, - "weatherEnabled": weatherEnabled, - "showLauncherButton": showLauncherButton, - "showWorkspaceSwitcher": showWorkspaceSwitcher, - "showFocusedWindow": showFocusedWindow, - "showWeather": showWeather, - "showMusic": showMusic, - "showClipboard": showClipboard, - "showCpuUsage": showCpuUsage, - "showMemUsage": showMemUsage, - "showCpuTemp": showCpuTemp, - "showGpuTemp": showGpuTemp, - "selectedGpuIndex": selectedGpuIndex, - "enabledGpuPciIds": enabledGpuPciIds, - "showSystemTray": showSystemTray, - "showClock": showClock, - "showNotificationButton": showNotificationButton, - "showBattery": showBattery, - "showControlCenterButton": showControlCenterButton, - "controlCenterShowNetworkIcon": controlCenterShowNetworkIcon, - "controlCenterShowBluetoothIcon": controlCenterShowBluetoothIcon, - "controlCenterShowAudioIcon": controlCenterShowAudioIcon, - "controlCenterWidgets": controlCenterWidgets, - "showWorkspaceIndex": showWorkspaceIndex, - "workspaceScrolling": workspaceScrolling, - "showWorkspacePadding": showWorkspacePadding, - "showWorkspaceApps": showWorkspaceApps, - "maxWorkspaceIcons": maxWorkspaceIcons, - "workspacesPerMonitor": workspacesPerMonitor, - "dwlShowAllTags": dwlShowAllTags, - "workspaceNameIcons": workspaceNameIcons, - "waveProgressEnabled": waveProgressEnabled, - "clockCompactMode": clockCompactMode, - "focusedWindowCompactMode": focusedWindowCompactMode, - "runningAppsCompactMode": runningAppsCompactMode, - "keyboardLayoutNameCompactMode": keyboardLayoutNameCompactMode, - "runningAppsCurrentWorkspace": runningAppsCurrentWorkspace, - "runningAppsGroupByApp": runningAppsGroupByApp, - "clockDateFormat": clockDateFormat, - "lockDateFormat": lockDateFormat, - "mediaSize": mediaSize, - "dankBarLeftWidgets": dankBarLeftWidgets, - "dankBarCenterWidgets": dankBarCenterWidgets, - "dankBarRightWidgets": dankBarRightWidgets, - "appLauncherViewMode": appLauncherViewMode, - "spotlightModalViewMode": spotlightModalViewMode, - "sortAppsAlphabetically": sortAppsAlphabetically, - "networkPreference": networkPreference, - "vpnLastConnected": vpnLastConnected, - "iconTheme": iconTheme, - "launcherLogoMode": launcherLogoMode, - "launcherLogoCustomPath": launcherLogoCustomPath, - "launcherLogoColorOverride": launcherLogoColorOverride, - "launcherLogoColorInvertOnMode": launcherLogoColorInvertOnMode, - "launcherLogoBrightness": launcherLogoBrightness, - "launcherLogoContrast": launcherLogoContrast, - "launcherLogoSizeOffset": launcherLogoSizeOffset, - "fontFamily": fontFamily, - "monoFontFamily": monoFontFamily, - "fontWeight": fontWeight, - "fontScale": fontScale, - "dankBarFontScale": dankBarFontScale, - "notepadUseMonospace": notepadUseMonospace, - "notepadFontFamily": notepadFontFamily, - "notepadFontSize": notepadFontSize, - "notepadShowLineNumbers": notepadShowLineNumbers, - "notepadTransparencyOverride": notepadTransparencyOverride, - "notepadLastCustomTransparency": notepadLastCustomTransparency, - "soundsEnabled": soundsEnabled, - "useSystemSoundTheme": useSystemSoundTheme, - "soundNewNotification": soundNewNotification, - "soundVolumeChanged": soundVolumeChanged, - "soundPluggedIn": soundPluggedIn, - "gtkThemingEnabled": gtkThemingEnabled, - "qtThemingEnabled": qtThemingEnabled, - "syncModeWithPortal": syncModeWithPortal, - "showDock": showDock, - "dockAutoHide": dockAutoHide, - "dockGroupByApp": dockGroupByApp, - "dockOpenOnOverview": dockOpenOnOverview, - "dockPosition": dockPosition, - "dockSpacing": dockSpacing, - "dockBottomGap": dockBottomGap, - "dockIconSize": dockIconSize, - "dockIndicatorStyle": dockIndicatorStyle, - "cornerRadius": cornerRadius, - "notificationOverlayEnabled": notificationOverlayEnabled, - "dankBarAutoHide": dankBarAutoHide, - "dankBarOpenOnOverview": dankBarOpenOnOverview, - "dankBarVisible": dankBarVisible, - "dankBarSpacing": dankBarSpacing, - "dankBarBottomGap": dankBarBottomGap, - "dankBarInnerPadding": dankBarInnerPadding, - "dankBarSquareCorners": dankBarSquareCorners, - "dankBarNoBackground": dankBarNoBackground, - "dankBarGothCornersEnabled": dankBarGothCornersEnabled, - "dankBarBorderEnabled": dankBarBorderEnabled, - "dankBarBorderColor": dankBarBorderColor, - "dankBarBorderOpacity": dankBarBorderOpacity, - "dankBarBorderThickness": dankBarBorderThickness, - "popupGapsAuto": popupGapsAuto, - "popupGapsManual": popupGapsManual, - "modalDarkenBackground": modalDarkenBackground, - "dankBarPosition": dankBarPosition, - "lockScreenShowPowerActions": lockScreenShowPowerActions, - "enableFprint": enableFprint, - "maxFprintTries": maxFprintTries, - "hideBrightnessSlider": hideBrightnessSlider, - "widgetBackgroundColor": widgetBackgroundColor, - "surfaceBase": surfaceBase, - "wallpaperFillMode": wallpaperFillMode, - "blurredWallpaperLayer": blurredWallpaperLayer, - "blurWallpaperOnOverview": blurWallpaperOnOverview, - "notificationTimeoutLow": notificationTimeoutLow, - "notificationTimeoutNormal": notificationTimeoutNormal, - "notificationTimeoutCritical": notificationTimeoutCritical, - "notificationPopupPosition": notificationPopupPosition, - "osdAlwaysShowValue": osdAlwaysShowValue, - "powerActionConfirm": powerActionConfirm, - "customPowerActionLock": customPowerActionLock, - "customPowerActionLogout": customPowerActionLogout, - "customPowerActionSuspend": customPowerActionSuspend, - "customPowerActionHibernate": customPowerActionHibernate, - "customPowerActionReboot": customPowerActionReboot, - "customPowerActionPowerOff": customPowerActionPowerOff, - "updaterUseCustomCommand": updaterUseCustomCommand, - "updaterCustomCommand": updaterCustomCommand, - "updaterTerminalAdditionalParams": updaterTerminalAdditionalParams, - "screenPreferences": screenPreferences, - "showOnLastDisplay": showOnLastDisplay, - "animationSpeed": animationSpeed, - "customAnimationDuration": customAnimationDuration, - "acMonitorTimeout": acMonitorTimeout, - "acLockTimeout": acLockTimeout, - "acSuspendTimeout": acSuspendTimeout, - "acHibernateTimeout": acHibernateTimeout, - "batteryMonitorTimeout": batteryMonitorTimeout, - "batteryLockTimeout": batteryLockTimeout, - "batterySuspendTimeout": batterySuspendTimeout, - "batteryHibernateTimeout": batteryHibernateTimeout, - "lockBeforeSuspend": lockBeforeSuspend, - "loginctlLockIntegration": loginctlLockIntegration, - "launchPrefix": launchPrefix, - "brightnessDevicePins": brightnessDevicePins, - "configVersion": settingsConfigVersion - }, null, 2)) + if (_loading) return + settingsFile.setText(JSON.stringify(Store.toJson(root), null, 2)) } function savePluginSettings() { - if (_pluginSettingsLoading) - return + if (_pluginSettingsLoading) return pluginSettingsFile.setText(JSON.stringify(pluginSettings, null, 2)) } - function migrateFromUndefinedToV1(settings) { - console.info("SettingsData: Migrating configuration from undefined to version 1") - } - - function cleanupUnusedKeys() { - const validKeys = ["currentThemeName", "customThemeFile", "matugenScheme", "runUserMatugenTemplates", "matugenTargetMonitor", "dankBarTransparency", "dankBarWidgetTransparency", "popupTransparency", "dockTransparency", "use24HourClock", "showSeconds", "useFahrenheit", "nightModeEnabled", "weatherLocation", "weatherCoordinates", "useAutoLocation", "weatherEnabled", "showLauncherButton", "showWorkspaceSwitcher", "showFocusedWindow", "showWeather", "showMusic", "showClipboard", "showCpuUsage", "showMemUsage", "showCpuTemp", "showGpuTemp", "selectedGpuIndex", "enabledGpuPciIds", "showSystemTray", "showClock", "showNotificationButton", "showBattery", "showControlCenterButton", "controlCenterShowNetworkIcon", "controlCenterShowBluetoothIcon", "controlCenterShowAudioIcon", "controlCenterWidgets", "showWorkspaceIndex", "workspaceScrolling", "showWorkspacePadding", "showWorkspaceApps", "maxWorkspaceIcons", "workspacesPerMonitor", "dwlShowAllTags", "workspaceNameIcons", "waveProgressEnabled", "clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode", "keyboardLayoutNameCompactMode", "runningAppsCurrentWorkspace", "runningAppsGroupByApp", "clockDateFormat", "lockDateFormat", "mediaSize", "dankBarLeftWidgets", "dankBarCenterWidgets", "dankBarRightWidgets", "appLauncherViewMode", "spotlightModalViewMode", "sortAppsAlphabetically", "networkPreference", "vpnLastConnected", "iconTheme", "launcherLogoMode", "launcherLogoCustomPath", "launcherLogoColorOverride", "launcherLogoColorInvertOnMode", "launcherLogoBrightness", "launcherLogoContrast", "launcherLogoSizeOffset", "fontFamily", "monoFontFamily", "fontWeight", "fontScale", "dankBarFontScale", "notepadUseMonospace", "notepadFontFamily", "notepadFontSize", "notepadShowLineNumbers", "notepadTransparencyOverride", "notepadLastCustomTransparency", "soundsEnabled", "useSystemSoundTheme", "soundNewNotification", "soundVolumeChanged", "soundPluggedIn", "gtkThemingEnabled", "qtThemingEnabled", "syncModeWithPortal", "showDock", "dockAutoHide", "dockGroupByApp", "dockOpenOnOverview", "dockPosition", "dockSpacing", "dockBottomGap", "dockIconSize", "dockIndicatorStyle", "cornerRadius", "notificationOverlayEnabled", "dankBarAutoHide", "dankBarOpenOnOverview", "dankBarVisible", "dankBarSpacing", "dankBarBottomGap", "dankBarInnerPadding", "dankBarSquareCorners", "dankBarNoBackground", "dankBarGothCornersEnabled", "dankBarBorderEnabled", "dankBarBorderColor", "dankBarBorderOpacity", "dankBarBorderThickness", "popupGapsAuto", "popupGapsManual", "modalDarkenBackground", "dankBarPosition", "lockScreenShowPowerActions", "enableFprint", "maxFprintTries", "hideBrightnessSlider", "widgetBackgroundColor", "surfaceBase", "wallpaperFillMode", "blurredWallpaperLayer", "blurWallpaperOnOverview", "notificationTimeoutLow", "notificationTimeoutNormal", "notificationTimeoutCritical", "notificationPopupPosition", "osdAlwaysShowValue", "powerActionConfirm", "customPowerActionLock", "customPowerActionLogout", "customPowerActionSuspend", "customPowerActionHibernate", "customPowerActionReboot", "customPowerActionPowerOff", "updaterUseCustomCommand", "updaterCustomCommand", "updaterTerminalAdditionalParams", "screenPreferences", "showOnLastDisplay", "animationSpeed", "customAnimationDuration", "acMonitorTimeout", "acLockTimeout", "acSuspendTimeout", "acHibernateTimeout", "batteryMonitorTimeout", "batteryLockTimeout", "batterySuspendTimeout", "batteryHibernateTimeout", "lockBeforeSuspend", "loginctlLockIntegration", "launchPrefix", "brightnessDevicePins", "configVersion"] - - try { - const content = settingsFile.text() - if (!content || !content.trim()) - return - - const settings = JSON.parse(content) - let needsSave = false - - for (const key in settings) { - if (!validKeys.includes(key)) { - console.log("SettingsData: Removing unused key:", key) - delete settings[key] - needsSave = true - } - } - - if (needsSave) { - settingsFile.setText(JSON.stringify(settings, null, 2)) - } - } catch (e) { - console.warn("SettingsData: Failed to cleanup unused keys:", e.message) - } + function detectAvailableIconThemes() { + Processes.detectIcons() } function getEffectiveTimeFormat() { @@ -827,70 +500,27 @@ Singleton { } function initializeListModels() { - var dummyItem = { - "widgetId": "dummy", - "enabled": true, - "size": 20, - "selectedGpuIndex": 0, - "pciId": "", - "mountPath": "/", - "minimumWidth": true - } - leftWidgetsModel.append(dummyItem) - centerWidgetsModel.append(dummyItem) - rightWidgetsModel.append(dummyItem) - - updateListModel(leftWidgetsModel, dankBarLeftWidgets) - updateListModel(centerWidgetsModel, dankBarCenterWidgets) - updateListModel(rightWidgetsModel, dankBarRightWidgets) + Lists.init(leftWidgetsModel, centerWidgetsModel, rightWidgetsModel, dankBarLeftWidgets, dankBarCenterWidgets, dankBarRightWidgets) } function updateListModel(listModel, order) { - listModel.clear() - for (var i = 0; i < order.length; i++) { - var widgetId = typeof order[i] === "string" ? order[i] : order[i].id - var enabled = typeof order[i] === "string" ? true : order[i].enabled - var size = typeof order[i] === "string" ? undefined : order[i].size - var selectedGpuIndex = typeof order[i] === "string" ? undefined : order[i].selectedGpuIndex - var pciId = typeof order[i] === "string" ? undefined : order[i].pciId - var mountPath = typeof order[i] === "string" ? undefined : order[i].mountPath - var minimumWidth = typeof order[i] === "string" ? undefined : order[i].minimumWidth - var item = { - "widgetId": widgetId, - "enabled": enabled - } - if (size !== undefined) - item.size = size - if (selectedGpuIndex !== undefined) - item.selectedGpuIndex = selectedGpuIndex - if (pciId !== undefined) - item.pciId = pciId - if (mountPath !== undefined) - item.mountPath = mountPath - if (minimumWidth !== undefined) - item.minimumWidth = minimumWidth - - listModel.append(item) - } + Lists.update(listModel, order) widgetDataChanged() } function hasNamedWorkspaces() { - if (typeof NiriService === "undefined" || !CompositorService.isNiri) - return false + if (typeof NiriService === "undefined" || !CompositorService.isNiri) return false for (var i = 0; i < NiriService.allWorkspaces.length; i++) { var ws = NiriService.allWorkspaces[i] - if (ws.name && ws.name.trim() !== "") - return true + if (ws.name && ws.name.trim() !== "") return true } return false } function getNamedWorkspaces() { var namedWorkspaces = [] - if (typeof NiriService === "undefined" || !CompositorService.isNiri) - return namedWorkspaces + if (typeof NiriService === "undefined" || !CompositorService.isNiri) return namedWorkspaces for (const ws of NiriService.allWorkspaces) { if (ws.name && ws.name.trim() !== "") { @@ -900,61 +530,6 @@ Singleton { return namedWorkspaces } - function applyStoredTheme() { - if (typeof Theme !== "undefined") - Theme.switchTheme(currentThemeName, false, false) - else - Qt.callLater(() => { - if (typeof Theme !== "undefined") - Theme.switchTheme(currentThemeName, false, false) - }) - } - - function detectAvailableIconThemes() { - systemDefaultDetectionProcess.running = true - } - - function detectQtTools() { - qtToolsDetectionProcess.running = true - } - - function updateGtkIconTheme(themeName) { - var gtkThemeName = (themeName === "System Default") ? systemDefaultIconTheme : themeName - if (gtkThemeName !== "System Default" && gtkThemeName !== "") { - if (DMSService.apiVersion >= 3) { - PortalService.setSystemIconTheme(gtkThemeName) - } - - var configScript = "mkdir -p " + _configDir + "/gtk-3.0 " + _configDir + "/gtk-4.0\n" + "\n" + "for config_dir in " + _configDir + "/gtk-3.0 " - + _configDir + "/gtk-4.0; do\n" + " settings_file=\"$config_dir/settings.ini\"\n" + " if [ -f \"$settings_file\" ]; then\n" - + " if grep -q '^gtk-icon-theme-name=' \"$settings_file\"; then\n" + " sed -i 's/^gtk-icon-theme-name=.*/gtk-icon-theme-name=" + gtkThemeName + "/' \"$settings_file\"\n" - + " else\n" + " if grep -q '\\[Settings\\]' \"$settings_file\"; then\n" + " sed -i '/\\[Settings\\]/a gtk-icon-theme-name=" + gtkThemeName - + "' \"$settings_file\"\n" + " else\n" + " echo -e '\\n[Settings]\\ngtk-icon-theme-name=" + gtkThemeName + "' >> \"$settings_file\"\n" + " fi\n" + " fi\n" + " else\n" - + " echo -e '[Settings]\\ngtk-icon-theme-name=" + gtkThemeName + "' > \"$settings_file\"\n" + " fi\n" + "done\n" + "\n" + "rm -rf ~/.cache/icon-cache ~/.cache/thumbnails 2>/dev/null || true\n" + "pkill -HUP -f 'gtk' 2>/dev/null || true\n" - Quickshell.execDetached(["sh", "-lc", configScript]) - } - } - - function updateQtIconTheme(themeName) { - var qtThemeName = (themeName === "System Default") ? "" : themeName - var home = _shq(Paths.strip(root._homeUrl)) - if (!qtThemeName) { - return - } - var script = "mkdir -p " + _configDir + "/qt5ct " + _configDir + "/qt6ct " + _configDir + "/environment.d 2>/dev/null || true\n" + "update_qt_icon_theme() {\n" + " local config_file=\"$1\"\n" - + " local theme_name=\"$2\"\n" + " if [ -f \"$config_file\" ]; then\n" + " if grep -q '^\\[Appearance\\]' \"$config_file\"; then\n" + " if grep -q '^icon_theme=' \"$config_file\"; then\n" - + " sed -i \"s/^icon_theme=.*/icon_theme=$theme_name/\" \"$config_file\"\n" + " else\n" + " sed -i \"/^\\[Appearance\\]/a icon_theme=$theme_name\" \"$config_file\"\n" + " fi\n" - + " else\n" + " printf '\\n[Appearance]\\nicon_theme=%s\\n' \"$theme_name\" >> \"$config_file\"\n" + " fi\n" + " else\n" - + " printf '[Appearance]\\nicon_theme=%s\\n' \"$theme_name\" > \"$config_file\"\n" + " fi\n" + "}\n" + "update_qt_icon_theme " + _configDir + "/qt5ct/qt5ct.conf " + _shq(qtThemeName) - + "\n" + "update_qt_icon_theme " + _configDir + "/qt6ct/qt6ct.conf " + _shq(qtThemeName) + "\n" + "rm -rf " + home + "/.cache/icon-cache " + home + "/.cache/thumbnails 2>/dev/null || true\n" - Quickshell.execDetached(["sh", "-lc", script]) - } - - function applyStoredIconTheme() { - updateGtkIconTheme(iconTheme) - updateQtIconTheme(iconTheme) - } - function getPopupYPosition(barHeight) { const gothOffset = dankBarGothCornersEnabled ? Theme.cornerRadius : 0 return barHeight + dankBarSpacing + dankBarBottomGap - gothOffset + Theme.popupDistance @@ -1010,353 +585,138 @@ Singleton { testNotificationProcess.running = true } - function _shq(s) { - return "'" + String(s).replace(/'/g, "'\\''") + "'" - } - - function setTheme(themeName) { - currentThemeName = themeName - saveSettings() - } - - function setCustomThemeFile(filePath) { - customThemeFile = filePath - saveSettings() - } function setMatugenScheme(scheme) { var normalized = scheme || "scheme-tonal-spot" - if (matugenScheme === normalized) - return - - matugenScheme = normalized - saveSettings() - + if (matugenScheme === normalized) return + set("matugenScheme", normalized) if (typeof Theme !== "undefined") { Theme.generateSystemThemesFromCurrentTheme() } } function setRunUserMatugenTemplates(enabled) { - if (runUserMatugenTemplates === enabled) - return - - runUserMatugenTemplates = enabled - saveSettings() - + if (runUserMatugenTemplates === enabled) return + set("runUserMatugenTemplates", enabled) if (typeof Theme !== "undefined") { Theme.generateSystemThemesFromCurrentTheme() } } function setMatugenTargetMonitor(monitorName) { - if (matugenTargetMonitor === monitorName) - return - - matugenTargetMonitor = monitorName - saveSettings() - + if (matugenTargetMonitor === monitorName) return + set("matugenTargetMonitor", monitorName) if (typeof Theme !== "undefined") { Theme.generateSystemThemesFromCurrentTheme() } } - function setDankBarTransparency(transparency) { - dankBarTransparency = transparency - saveSettings() - } - - function setDankBarWidgetTransparency(transparency) { - dankBarWidgetTransparency = transparency - saveSettings() - } - - function setPopupTransparency(transparency) { - popupTransparency = transparency - saveSettings() - } - - function setDockTransparency(transparency) { - dockTransparency = transparency - saveSettings() - } - - function setWidgetBackgroundColor(color) { - widgetBackgroundColor = color - saveSettings() - } - function setSurfaceBase(base) { - surfaceBase = base - saveSettings() + set("surfaceBase", base) if (typeof Theme !== "undefined") { Theme.generateSystemThemesFromCurrentTheme() } } function setCornerRadius(radius) { - cornerRadius = radius - saveSettings() + set("cornerRadius", radius) NiriService.generateNiriLayoutConfig() } - function setClockFormat(use24Hour) { - use24HourClock = use24Hour + function setWeatherLocation(displayName, coordinates) { + weatherLocation = displayName + weatherCoordinates = coordinates saveSettings() } - function setTimeFormat(useSec) { - showSeconds = useSec + function setIconTheme(themeName) { + iconTheme = themeName + updateGtkIconTheme() + updateQtIconTheme() + saveSettings() + if (typeof Theme !== "undefined" && Theme.currentTheme === Theme.dynamic) Theme.generateSystemThemesFromCurrentTheme() + } + + function setGtkThemingEnabled(enabled) { + set("gtkThemingEnabled", enabled) + if (enabled && typeof Theme !== "undefined") { + Theme.generateSystemThemesFromCurrentTheme() + } + } + + function setQtThemingEnabled(enabled) { + set("qtThemingEnabled", enabled) + if (enabled && typeof Theme !== "undefined") { + Theme.generateSystemThemesFromCurrentTheme() + } + } + + function setShowDock(enabled) { + showDock = enabled + if (enabled && dockPosition === dankBarPosition) { + if (dankBarPosition === SettingsData.Position.Top) { + setDockPosition(SettingsData.Position.Bottom) + return + } + if (dankBarPosition === SettingsData.Position.Bottom) { + setDockPosition(SettingsData.Position.Top) + return + } + if (dankBarPosition === SettingsData.Position.Left) { + setDockPosition(SettingsData.Position.Right) + return + } + if (dankBarPosition === SettingsData.Position.Right) { + setDockPosition(SettingsData.Position.Left) + return + } + } saveSettings() } - function setTemperatureUnit(fahrenheit) { - useFahrenheit = fahrenheit + function setDockPosition(position) { + dockPosition = position + if (position === SettingsData.Position.Bottom && dankBarPosition === SettingsData.Position.Bottom && showDock) { + setDankBarPosition(SettingsData.Position.Top) + } + if (position === SettingsData.Position.Top && dankBarPosition === SettingsData.Position.Top && showDock) { + setDankBarPosition(SettingsData.Position.Bottom) + } + if (position === SettingsData.Position.Left && dankBarPosition === SettingsData.Position.Left && showDock) { + setDankBarPosition(SettingsData.Position.Right) + } + if (position === SettingsData.Position.Right && dankBarPosition === SettingsData.Position.Right && showDock) { + setDankBarPosition(SettingsData.Position.Left) + } saveSettings() + Qt.callLater(() => forceDockLayoutRefresh()) } - function setNightModeEnabled(enabled) { - nightModeEnabled = enabled - saveSettings() + function setDankBarSpacing(spacing) { + set("dankBarSpacing", spacing) + if (typeof NiriService !== "undefined" && CompositorService.isNiri) { + NiriService.generateNiriLayoutConfig() + } } - function setAnimationSpeed(speed) { - animationSpeed = speed - saveSettings() - } - - function setCustomAnimationDuration(duration) { - customAnimationDuration = duration - saveSettings() - } - - function setWallpaperFillMode(mode) { - wallpaperFillMode = mode - saveSettings() - } - - function setBlurredWallpaperLayer(enabled) { - blurredWallpaperLayer = enabled - saveSettings() - } - - function setBlurWallpaperOnOverview(enabled) { - blurWallpaperOnOverview = enabled - saveSettings() - } - - function setShowLauncherButton(enabled) { - showLauncherButton = enabled - saveSettings() - } - - function setShowWorkspaceSwitcher(enabled) { - showWorkspaceSwitcher = enabled - saveSettings() - } - - function setShowFocusedWindow(enabled) { - showFocusedWindow = enabled - saveSettings() - } - - function setShowWeather(enabled) { - showWeather = enabled - saveSettings() - } - - function setShowMusic(enabled) { - showMusic = enabled - saveSettings() - } - - function setShowClipboard(enabled) { - showClipboard = enabled - saveSettings() - } - - function setShowCpuUsage(enabled) { - showCpuUsage = enabled - saveSettings() - } - - function setShowMemUsage(enabled) { - showMemUsage = enabled - saveSettings() - } - - function setShowCpuTemp(enabled) { - showCpuTemp = enabled - saveSettings() - } - - function setShowGpuTemp(enabled) { - showGpuTemp = enabled - saveSettings() - } - - function setSelectedGpuIndex(index) { - selectedGpuIndex = index - saveSettings() - } - - function setEnabledGpuPciIds(pciIds) { - enabledGpuPciIds = pciIds - saveSettings() - } - - function setShowSystemTray(enabled) { - showSystemTray = enabled - saveSettings() - } - - function setShowClock(enabled) { - showClock = enabled - saveSettings() - } - - function setShowNotificationButton(enabled) { - showNotificationButton = enabled - saveSettings() - } - - function setShowBattery(enabled) { - showBattery = enabled - saveSettings() - } - - function setShowControlCenterButton(enabled) { - showControlCenterButton = enabled - saveSettings() - } - - function setControlCenterShowNetworkIcon(enabled) { - controlCenterShowNetworkIcon = enabled - saveSettings() - } - - function setControlCenterShowBluetoothIcon(enabled) { - controlCenterShowBluetoothIcon = enabled - saveSettings() - } - - function setControlCenterShowAudioIcon(enabled) { - controlCenterShowAudioIcon = enabled - saveSettings() - } - - function setControlCenterWidgets(widgets) { - controlCenterWidgets = widgets - saveSettings() - } - - function setShowWorkspaceIndex(enabled) { - showWorkspaceIndex = enabled - saveSettings() - } - - function setWorkspaceScrolling(enabled) { - workspaceScrolling = enabled - saveSettings() - } - - function setShowWorkspacePadding(enabled) { - showWorkspacePadding = enabled - saveSettings() - } - - function setShowWorkspaceApps(enabled) { - showWorkspaceApps = enabled - saveSettings() - } - - function setMaxWorkspaceIcons(maxIcons) { - maxWorkspaceIcons = maxIcons - saveSettings() - } - - function setWorkspacesPerMonitor(enabled) { - workspacesPerMonitor = enabled - saveSettings() - } - - function setDwlShowAllTags(enabled) { - dwlShowAllTags = enabled - saveSettings() - } - - function setWorkspaceNameIcon(workspaceName, iconData) { - var iconMap = JSON.parse(JSON.stringify(workspaceNameIcons)) - iconMap[workspaceName] = iconData - workspaceNameIcons = iconMap - saveSettings() - workspaceIconsUpdated() - } - - function removeWorkspaceNameIcon(workspaceName) { - var iconMap = JSON.parse(JSON.stringify(workspaceNameIcons)) - delete iconMap[workspaceName] - workspaceNameIcons = iconMap - saveSettings() - workspaceIconsUpdated() - } - - function getWorkspaceNameIcon(workspaceName) { - return workspaceNameIcons[workspaceName] || null - } - - function setWaveProgressEnabled(enabled) { - waveProgressEnabled = enabled - saveSettings() - } - - function setClockCompactMode(enabled) { - clockCompactMode = enabled - saveSettings() - } - - function setFocusedWindowCompactMode(enabled) { - focusedWindowCompactMode = enabled - saveSettings() - } - - function setRunningAppsCompactMode(enabled) { - runningAppsCompactMode = enabled - saveSettings() - } - - function setKeyboardLayoutNameCompactMode(enabled) { - keyboardLayoutNameCompactMode = enabled - saveSettings() - } - - function setRunningAppsCurrentWorkspace(enabled) { - runningAppsCurrentWorkspace = enabled - saveSettings() - } - - function setRunningAppsGroupByApp(enabled) { - runningAppsGroupByApp = enabled - saveSettings() - } - - function setClockDateFormat(format) { - clockDateFormat = format || "" - saveSettings() - } - - function setLockDateFormat(format) { - lockDateFormat = format || "" - saveSettings() - } - - function setMediaSize(size) { - mediaSize = size - saveSettings() - } - - function setDankBarWidgetOrder(order) { - dankBarWidgetOrder = order + function setDankBarPosition(position) { + dankBarPosition = position + if (position === SettingsData.Position.Bottom && dockPosition === SettingsData.Position.Bottom && showDock) { + setDockPosition(SettingsData.Position.Top) + return + } + if (position === SettingsData.Position.Top && dockPosition === SettingsData.Position.Top && showDock) { + setDockPosition(SettingsData.Position.Bottom) + return + } + if (position === SettingsData.Position.Left && dockPosition === SettingsData.Position.Left && showDock) { + setDockPosition(SettingsData.Position.Right) + return + } + if (position === SettingsData.Position.Right && dockPosition === SettingsData.Position.Right && showDock) { + setDockPosition(SettingsData.Position.Left) + return + } saveSettings() } @@ -1406,316 +766,24 @@ Singleton { saveSettings() } - function setAppLauncherViewMode(mode) { - appLauncherViewMode = mode + function setWorkspaceNameIcon(workspaceName, iconData) { + var iconMap = JSON.parse(JSON.stringify(workspaceNameIcons)) + iconMap[workspaceName] = iconData + workspaceNameIcons = iconMap saveSettings() + workspaceIconsUpdated() } - function setSpotlightModalViewMode(mode) { - spotlightModalViewMode = mode + function removeWorkspaceNameIcon(workspaceName) { + var iconMap = JSON.parse(JSON.stringify(workspaceNameIcons)) + delete iconMap[workspaceName] + workspaceNameIcons = iconMap saveSettings() + workspaceIconsUpdated() } - function setSortAppsAlphabetically(enabled) { - sortAppsAlphabetically = enabled - saveSettings() - } - - function setWeatherLocation(displayName, coordinates) { - weatherLocation = displayName - weatherCoordinates = coordinates - saveSettings() - } - - function setAutoLocation(enabled) { - useAutoLocation = enabled - saveSettings() - } - - function setWeatherEnabled(enabled) { - weatherEnabled = enabled - saveSettings() - } - - function setNetworkPreference(preference) { - networkPreference = preference - saveSettings() - } - - function setVpnLastConnected(uuid) { - vpnLastConnected = uuid - saveSettings() - } - - function setIconTheme(themeName) { - iconTheme = themeName - updateGtkIconTheme(themeName) - updateQtIconTheme(themeName) - saveSettings() - if (typeof Theme !== "undefined" && Theme.currentTheme === Theme.dynamic) - Theme.generateSystemThemesFromCurrentTheme() - } - - function setLauncherLogoMode(mode) { - launcherLogoMode = mode - saveSettings() - } - - function setLauncherLogoCustomPath(path) { - launcherLogoCustomPath = path - saveSettings() - } - - function setLauncherLogoColorOverride(color) { - launcherLogoColorOverride = color - saveSettings() - } - - function setLauncherLogoColorInvertOnMode(invert) { - launcherLogoColorInvertOnMode = invert - saveSettings() - } - - function setLauncherLogoBrightness(brightness) { - launcherLogoBrightness = brightness - saveSettings() - } - - function setLauncherLogoContrast(contrast) { - launcherLogoContrast = contrast - saveSettings() - } - - function setLauncherLogoSizeOffset(offset) { - launcherLogoSizeOffset = offset - saveSettings() - } - - function setFontFamily(family) { - fontFamily = family - saveSettings() - } - - function setFontWeight(weight) { - fontWeight = weight - saveSettings() - } - - function setMonoFontFamily(family) { - monoFontFamily = family - saveSettings() - } - - function setFontScale(scale) { - fontScale = scale - saveSettings() - } - - function setDankBarFontScale(scale) { - dankBarFontScale = scale - saveSettings() - } - - function setSoundsEnabled(enabled) { - soundsEnabled = enabled - saveSettings() - } - - function setUseSystemSoundTheme(enabled) { - useSystemSoundTheme = enabled - saveSettings() - } - - function setSoundNewNotification(enabled) { - soundNewNotification = enabled - saveSettings() - } - - function setSoundVolumeChanged(enabled) { - soundVolumeChanged = enabled - saveSettings() - } - - function setSoundPluggedIn(enabled) { - soundPluggedIn = enabled - saveSettings() - } - - function setAcMonitorTimeout(timeout) { - acMonitorTimeout = timeout - saveSettings() - } - - function setAcLockTimeout(timeout) { - acLockTimeout = timeout - saveSettings() - } - - function setAcSuspendTimeout(timeout) { - acSuspendTimeout = timeout - saveSettings() - } - - function setAcHibernateTimeout(timeout) { - acHibernateTimeout = timeout - saveSettings() - } - - function setBatteryMonitorTimeout(timeout) { - batteryMonitorTimeout = timeout - saveSettings() - } - - function setBatteryLockTimeout(timeout) { - batteryLockTimeout = timeout - saveSettings() - } - - function setBatterySuspendTimeout(timeout) { - batterySuspendTimeout = timeout - saveSettings() - } - - function setBatteryHibernateTimeout(timeout) { - batteryHibernateTimeout = timeout - saveSettings() - } - - function setLockBeforeSuspend(enabled) { - lockBeforeSuspend = enabled - saveSettings() - } - - function setLoginctlLockIntegration(enabled) { - loginctlLockIntegration = enabled - saveSettings() - } - - function setLaunchPrefix(prefix) { - launchPrefix = prefix - saveSettings() - } - - function setGtkThemingEnabled(enabled) { - gtkThemingEnabled = enabled - saveSettings() - if (enabled && typeof Theme !== "undefined") { - Theme.generateSystemThemesFromCurrentTheme() - } - } - - function setQtThemingEnabled(enabled) { - qtThemingEnabled = enabled - saveSettings() - if (enabled && typeof Theme !== "undefined") { - Theme.generateSystemThemesFromCurrentTheme() - } - } - - function setSyncModeWithPortal(enabled) { - syncModeWithPortal = enabled - saveSettings() - } - - function setShowDock(enabled) { - showDock = enabled - if (enabled && dockPosition === dankBarPosition) { - if (dankBarPosition === SettingsData.Position.Top) { - setDockPosition(SettingsData.Position.Bottom) - return - } - if (dankBarPosition === SettingsData.Position.Bottom) { - setDockPosition(SettingsData.Position.Top) - return - } - if (dankBarPosition === SettingsData.Position.Left) { - setDockPosition(SettingsData.Position.Right) - return - } - if (dankBarPosition === SettingsData.Position.Right) { - setDockPosition(SettingsData.Position.Left) - return - } - } - saveSettings() - } - - function setDockAutoHide(enabled) { - dockAutoHide = enabled - saveSettings() - } - - function setDockGroupByApp(enabled) { - dockGroupByApp = enabled - saveSettings() - } - - function setdockOpenOnOverview(enabled) { - dockOpenOnOverview = enabled - saveSettings() - } - - function setDockPosition(position) { - dockPosition = position - if (position === SettingsData.Position.Bottom && dankBarPosition === SettingsData.Position.Bottom && showDock) { - setDankBarPosition(SettingsData.Position.Top) - } - if (position === SettingsData.Position.Top && dankBarPosition === SettingsData.Position.Top && showDock) { - setDankBarPosition(SettingsData.Position.Bottom) - } - if (position === SettingsData.Position.Left && dankBarPosition === SettingsData.Position.Left && showDock) { - setDankBarPosition(SettingsData.Position.Right) - } - if (position === SettingsData.Position.Right && dankBarPosition === SettingsData.Position.Right && showDock) { - setDankBarPosition(SettingsData.Position.Left) - } - saveSettings() - Qt.callLater(() => forceDockLayoutRefresh()) - } - - function setDockSpacing(spacing) { - dockSpacing = spacing - saveSettings() - } - - function setDockBottomGap(gap) { - dockBottomGap = gap - saveSettings() - } - - function setDockIconSize(size) { - dockIconSize = size - saveSettings() - } - - function setDockOpenOnOverview(enabled) { - dockOpenOnOverview = enabled - saveSettings() - } - - function setDockIndicatorStyle(style) { - dockIndicatorStyle = style - saveSettings() - } - - function setNotificationOverlayEnabled(enabled) { - notificationOverlayEnabled = enabled - saveSettings() - } - - function setDankBarAutoHide(enabled) { - dankBarAutoHide = enabled - saveSettings() - } - - function setDankBarOpenOnOverview(enabled) { - dankBarOpenOnOverview = enabled - saveSettings() - } - - function setDankBarVisible(visible) { - dankBarVisible = visible - saveSettings() + function getWorkspaceNameIcon(workspaceName) { + return workspaceNameIcons[workspaceName] || null } function toggleDankBarVisible() { @@ -1723,190 +791,6 @@ Singleton { saveSettings() } - function setDankBarSpacing(spacing) { - dankBarSpacing = spacing - saveSettings() - if (typeof NiriService !== "undefined" && CompositorService.isNiri) { - NiriService.generateNiriLayoutConfig() - } - } - - function setDankBarBottomGap(gap) { - dankBarBottomGap = gap - saveSettings() - } - - function setDankBarInnerPadding(padding) { - dankBarInnerPadding = padding - saveSettings() - } - - function setDankBarPosition(position) { - dankBarPosition = position - if (position === SettingsData.Position.Bottom && dockPosition === SettingsData.Position.Bottom && showDock) { - setDockPosition(SettingsData.Position.Top) - return - } - if (position === SettingsData.Position.Top && dockPosition === SettingsData.Position.Top && showDock) { - setDockPosition(SettingsData.Position.Bottom) - return - } - if (position === SettingsData.Position.Left && dockPosition === SettingsData.Position.Left && showDock) { - setDockPosition(SettingsData.Position.Right) - return - } - if (position === SettingsData.Position.Right && dockPosition === SettingsData.Position.Right && showDock) { - setDockPosition(SettingsData.Position.Left) - return - } - saveSettings() - } - - function setDankBarSquareCorners(enabled) { - dankBarSquareCorners = enabled - saveSettings() - } - - function setDankBarNoBackground(enabled) { - dankBarNoBackground = enabled - saveSettings() - } - - function setDankBarGothCornersEnabled(enabled) { - dankBarGothCornersEnabled = enabled - saveSettings() - } - - function setDankBarBorderEnabled(enabled) { - dankBarBorderEnabled = enabled - saveSettings() - } - - function setPopupGapsAuto(enabled) { - popupGapsAuto = enabled - saveSettings() - } - - function setPopupGapsManual(value) { - popupGapsManual = value - saveSettings() - } - - function setLockScreenShowPowerActions(enabled) { - lockScreenShowPowerActions = enabled - saveSettings() - } - - function setEnableFprint(enabled) { - enableFprint = enabled - saveSettings() - } - - function setMaxFprintTries(tries) { - maxFprintTries = tries - saveSettings() - } - - function setHideBrightnessSlider(enabled) { - hideBrightnessSlider = enabled - saveSettings() - } - - function setModalDarkenBackground(enabled) { - modalDarkenBackground = enabled - saveSettings() - } - - function setNotificationTimeoutLow(timeout) { - notificationTimeoutLow = timeout - saveSettings() - } - - function setNotificationTimeoutNormal(timeout) { - notificationTimeoutNormal = timeout - saveSettings() - } - - function setNotificationTimeoutCritical(timeout) { - notificationTimeoutCritical = timeout - saveSettings() - } - - function setNotificationPopupPosition(position) { - notificationPopupPosition = position - saveSettings() - } - - function setOsdAlwaysShowValue(enabled) { - osdAlwaysShowValue = enabled - saveSettings() - } - - function setPowerActionConfirm(confirm) { - powerActionConfirm = confirm - saveSettings() - } - - function setCustomPowerActionLock(command) { - customPowerActionLock = command - saveSettings() - } - - function setCustomPowerActionLogout(command) { - customPowerActionLogout = command - saveSettings() - } - - function setCustomPowerActionSuspend(command) { - customPowerActionSuspend = command - saveSettings() - } - - function setCustomPowerActionHibernate(command) { - customPowerActionHibernate = command - saveSettings() - } - - function setCustomPowerActionReboot(command) { - customPowerActionReboot = command - saveSettings() - } - - function setCustomPowerActionPowerOff(command) { - customPowerActionPowerOff = command - saveSettings() - } - - function setUpdaterUseCustomCommandEnabled(enabled) { - updaterUseCustomCommand = enabled - saveSettings() - } - - function setUpdaterCustomCommand(command) { - updaterCustomCommand = command - saveSettings() - } - - function setUpdaterTerminalAdditionalParams(customArgs) { - updaterTerminalAdditionalParams = customArgs - saveSettings() - } - - function setScreenPreferences(prefs) { - screenPreferences = prefs - saveSettings() - } - - function setShowOnLastDisplay(prefs) { - showOnLastDisplay = prefs - saveSettings() - } - - function setBrightnessDevicePins(pins) { - brightnessDevicePins = pins - saveSettings() - } - function getPluginSetting(pluginId, key, defaultValue) { if (!pluginSettings[pluginId]) { return defaultValue @@ -1933,6 +817,7 @@ Singleton { return pluginSettings[pluginId] || {} } + ListModel { id: leftWidgetsModel } @@ -1968,6 +853,8 @@ Singleton { onTriggered: sendTestNotification(2) } + property alias settingsFile: settingsFile + FileView { id: settingsFile @@ -1978,14 +865,21 @@ Singleton { watchChanges: !isGreeterMode onLoaded: { if (!isGreeterMode) { - parseSettings(settingsFile.text()) + try { + const txt = settingsFile.text() + const obj = (txt && txt.trim()) ? JSON.parse(txt) : null + Store.parse(root, obj) + Store.migrate(root, obj) + } catch (e) { + console.warn("SettingsData: Failed to reload settings:", e.message) + } hasTriedDefaultSettings = false } } onLoadFailed: error => { if (!isGreeterMode && !hasTriedDefaultSettings) { hasTriedDefaultSettings = true - defaultSettingsCheckProcess.running = true + Processes.checkDefaultSettings() } else if (!isGreeterMode) { applyStoredTheme() } @@ -2014,101 +908,6 @@ Singleton { property bool pluginSettingsFileExists: false - Process { - id: pluginSettingsCheckProcess - command: ["test", "-f", pluginSettingsPath] - - onExited: (exitCode) => { - pluginSettingsFileExists = (exitCode === 0) - } - } - - Process { - id: systemDefaultDetectionProcess - - command: ["sh", "-c", "gsettings get org.gnome.desktop.interface icon-theme 2>/dev/null | sed \"s/'//g\" || echo ''"] - running: false - onExited: exitCode => { - if (exitCode === 0 && stdout && stdout.length > 0) - systemDefaultIconTheme = stdout.trim() - else - systemDefaultIconTheme = "" - iconThemeDetectionProcess.running = true - } - } - - Process { - id: iconThemeDetectionProcess - - command: ["sh", "-c", "find /usr/share/icons ~/.local/share/icons ~/.icons -maxdepth 1 -type d 2>/dev/null | sed 's|.*/||' | grep -v '^icons$' | sort -u"] - running: false - - stdout: StdioCollector { - onStreamFinished: { - var detectedThemes = ["System Default"] - if (text && text.trim()) { - var themes = text.trim().split('\n') - for (var i = 0; i < themes.length; i++) { - var theme = themes[i].trim() - if (theme && theme !== "" && theme !== "default" && theme !== "hicolor" && theme !== "locolor") - detectedThemes.push(theme) - } - } - availableIconThemes = detectedThemes - } - } - } - - Process { - id: qtToolsDetectionProcess - - command: ["sh", "-c", "echo -n 'qt5ct:'; command -v qt5ct >/dev/null && echo 'true' || echo 'false'; echo -n 'qt6ct:'; command -v qt6ct >/dev/null && echo 'true' || echo 'false'; echo -n 'gtk:'; (command -v gsettings >/dev/null || command -v dconf >/dev/null) && echo 'true' || echo 'false'"] - running: false - - stdout: StdioCollector { - onStreamFinished: { - if (text && text.trim()) { - var lines = text.trim().split('\n') - for (var i = 0; i < lines.length; i++) { - var line = lines[i] - if (line.startsWith('qt5ct:')) - qt5ctAvailable = line.split(':')[1] === 'true' - else if (line.startsWith('qt6ct:')) - qt6ctAvailable = line.split(':')[1] === 'true' - else if (line.startsWith('gtk:')) - gtkAvailable = line.split(':')[1] === 'true' - } - } - } - } - } - - Process { - id: defaultSettingsCheckProcess - - command: ["sh", "-c", "CONFIG_DIR=\"" + _configDir - + "/DankMaterialShell\"; if [ -f \"$CONFIG_DIR/default-settings.json\" ] && [ ! -f \"$CONFIG_DIR/settings.json\" ]; then cp --no-preserve=mode \"$CONFIG_DIR/default-settings.json\" \"$CONFIG_DIR/settings.json\" && echo 'copied'; else echo 'not_found'; fi"] - running: false - onExited: exitCode => { - if (exitCode === 0) { - console.info("Copied default-settings.json to settings.json") - settingsFile.reload() - } else { - applyStoredTheme() - } - } - } - - Process { - id: fprintdDetectionProcess - - command: ["sh", "-c", "command -v fprintd-list >/dev/null 2>&1"] - running: false - onExited: exitCode => { - fprintdAvailable = (exitCode === 0) - } - } - IpcHandler { function reveal(): string { root.setDankBarVisible(true) diff --git a/Common/Theme.qml b/Common/Theme.qml index 0fbc4f12..e62c3a84 100644 --- a/Common/Theme.qml +++ b/Common/Theme.qml @@ -482,7 +482,7 @@ Singleton { } const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode) if (savePrefs && typeof SettingsData !== "undefined" && !isGreeterMode) - SettingsData.setTheme(currentTheme) + SettingsData.set("currentThemeName", currentTheme) if (!isGreeterMode) { generateSystemThemesFromCurrentTheme() diff --git a/Common/settings/Lists.qml b/Common/settings/Lists.qml new file mode 100644 index 00000000..5391597d --- /dev/null +++ b/Common/settings/Lists.qml @@ -0,0 +1,53 @@ +pragma Singleton + +pragma ComponentBehavior: Bound + +import Quickshell +import QtQuick + +Singleton { + id: root + + function init(leftModel, centerModel, rightModel, left, center, right) { + const dummy = { + widgetId: "dummy", + enabled: true, + size: 20, + selectedGpuIndex: 0, + pciId: "", + mountPath: "/", + minimumWidth: true + } + leftModel.append(dummy) + centerModel.append(dummy) + rightModel.append(dummy) + + update(leftModel, left) + update(centerModel, center) + update(rightModel, right) + } + + function update(model, order) { + model.clear() + for (var i = 0; i < order.length; i++) { + var widgetId = typeof order[i] === "string" ? order[i] : order[i].id + var enabled = typeof order[i] === "string" ? true : order[i].enabled + var size = typeof order[i] === "string" ? undefined : order[i].size + var selectedGpuIndex = typeof order[i] === "string" ? undefined : order[i].selectedGpuIndex + var pciId = typeof order[i] === "string" ? undefined : order[i].pciId + var mountPath = typeof order[i] === "string" ? undefined : order[i].mountPath + var minimumWidth = typeof order[i] === "string" ? undefined : order[i].minimumWidth + var item = { + widgetId: widgetId, + enabled: enabled + } + if (size !== undefined) item.size = size + if (selectedGpuIndex !== undefined) item.selectedGpuIndex = selectedGpuIndex + if (pciId !== undefined) item.pciId = pciId + if (mountPath !== undefined) item.mountPath = mountPath + if (minimumWidth !== undefined) item.minimumWidth = minimumWidth + + model.append(item) + } + } +} diff --git a/Common/settings/Processes.qml b/Common/settings/Processes.qml new file mode 100644 index 00000000..3dfb45f3 --- /dev/null +++ b/Common/settings/Processes.qml @@ -0,0 +1,131 @@ +pragma Singleton + +pragma ComponentBehavior: Bound + +import QtQuick +import Quickshell +import Quickshell.Io + +Singleton { + id: root + + property var settingsRoot: null + + function detectIcons() { + systemDefaultDetectionProcess.running = true + } + + function detectQtTools() { + qtToolsDetectionProcess.running = true + } + + function detectFprintd() { + fprintdDetectionProcess.running = true + } + + function checkPluginSettings() { + pluginSettingsCheckProcess.running = true + } + + function checkDefaultSettings() { + defaultSettingsCheckProcess.running = true + } + + property var systemDefaultDetectionProcess: Process { + command: ["sh", "-c", "gsettings get org.gnome.desktop.interface icon-theme 2>/dev/null | sed \"s/'//g\" || echo ''"] + running: false + onExited: function(exitCode) { + if (!settingsRoot) return; + if (exitCode === 0 && stdout && stdout.length > 0) { + settingsRoot.systemDefaultIconTheme = stdout.trim(); + } else { + settingsRoot.systemDefaultIconTheme = ""; + } + iconThemeDetectionProcess.running = true; + } + } + + property var iconThemeDetectionProcess: Process { + + command: ["sh", "-c", "find /usr/share/icons ~/.local/share/icons ~/.icons -maxdepth 1 -type d 2>/dev/null | sed 's|.*/||' | grep -v '^icons$' | sort -u"] + running: false + + stdout: StdioCollector { + onStreamFinished: { + if (!settingsRoot) return + var detectedThemes = ["System Default"] + if (text && text.trim()) { + var themes = text.trim().split('\n') + for (var i = 0; i < themes.length; i++) { + var theme = themes[i].trim() + if (theme && theme !== "" && theme !== "default" && theme !== "hicolor" && theme !== "locolor") { + detectedThemes.push(theme) + } + } + } + settingsRoot.availableIconThemes = detectedThemes + } + } + } + + property var qtToolsDetectionProcess: Process { + command: ["sh", "-c", "echo -n 'qt5ct:'; command -v qt5ct >/dev/null && echo 'true' || echo 'false'; echo -n 'qt6ct:'; command -v qt6ct >/dev/null && echo 'true' || echo 'false'; echo -n 'gtk:'; (command -v gsettings >/dev/null || command -v dconf >/dev/null) && echo 'true' || echo 'false'"] + running: false + + stdout: StdioCollector { + onStreamFinished: { + if (!settingsRoot) return; + if (text && text.trim()) { + var lines = text.trim().split('\n'); + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; + if (line.startsWith('qt5ct:')) { + settingsRoot.qt5ctAvailable = line.split(':')[1] === 'true'; + } else if (line.startsWith('qt6ct:')) { + settingsRoot.qt6ctAvailable = line.split(':')[1] === 'true'; + } else if (line.startsWith('gtk:')) { + settingsRoot.gtkAvailable = line.split(':')[1] === 'true'; + } + } + } + } + } + } + + property var defaultSettingsCheckProcess: Process { + command: ["sh", "-c", "CONFIG_DIR=\"" + (settingsRoot?._configDir || "") + "/DankMaterialShell\"; if [ -f \"$CONFIG_DIR/default-settings.json\" ] && [ ! -f \"$CONFIG_DIR/settings.json\" ]; then cp --no-preserve=mode \"$CONFIG_DIR/default-settings.json\" \"$CONFIG_DIR/settings.json\" && echo 'copied'; else echo 'not_found'; fi"] + running: false + onExited: function(exitCode) { + if (!settingsRoot) return; + if (exitCode === 0) { + console.info("Copied default-settings.json to settings.json"); + if (settingsRoot.settingsFile) { + settingsRoot.settingsFile.reload(); + } + } else { + if (typeof ThemeApplier !== "undefined") { + ThemeApplier.applyStoredTheme(settingsRoot); + } + } + } + } + + property var fprintdDetectionProcess: Process { + command: ["sh", "-c", "command -v fprintd-list >/dev/null 2>&1"] + running: false + onExited: function(exitCode) { + if (!settingsRoot) return; + settingsRoot.fprintdAvailable = (exitCode === 0); + } + } + + property var pluginSettingsCheckProcess: Process { + command: ["test", "-f", settingsRoot?.pluginSettingsPath || ""] + running: false + + onExited: function(exitCode) { + if (!settingsRoot) return; + settingsRoot.pluginSettingsFileExists = (exitCode === 0); + } + } +} diff --git a/Common/settings/SettingsSpec.js b/Common/settings/SettingsSpec.js new file mode 100644 index 00000000..cb58dd89 --- /dev/null +++ b/Common/settings/SettingsSpec.js @@ -0,0 +1,230 @@ +.pragma library + +function percentToUnit(v) { + if (v === undefined || v === null) return undefined; + return v > 1 ? v / 100 : v; +} + +var SPEC = { + currentThemeName: { def: "blue", onChange: "applyStoredTheme" }, + customThemeFile: { def: "" }, + matugenScheme: { def: "scheme-tonal-spot", onChange: "regenSystemThemes" }, + runUserMatugenTemplates: { def: true, onChange: "regenSystemThemes" }, + matugenTargetMonitor: { def: "", onChange: "regenSystemThemes" }, + + dankBarTransparency: { def: 1.0, coerce: percentToUnit, migrate: ["topBarTransparency"] }, + dankBarWidgetTransparency: { def: 1.0, coerce: percentToUnit, migrate: ["topBarWidgetTransparency"] }, + popupTransparency: { def: 1.0, coerce: percentToUnit }, + dockTransparency: { def: 1.0, coerce: percentToUnit }, + + widgetBackgroundColor: { def: "sch" }, + surfaceBase: { def: "s", onChange: "regenSystemThemes" }, + cornerRadius: { def: 12, onChange: "updateNiriLayout" }, + + use24HourClock: { def: true }, + showSeconds: { def: false }, + useFahrenheit: { def: false }, + nightModeEnabled: { def: false }, + animationSpeed: { def: 1 }, + customAnimationDuration: { def: 500 }, + wallpaperFillMode: { def: "Fill" }, + blurredWallpaperLayer: { def: false }, + blurWallpaperOnOverview: { def: false }, + + showLauncherButton: { def: true }, + showWorkspaceSwitcher: { def: true }, + showFocusedWindow: { def: true }, + showWeather: { def: true }, + showMusic: { def: true }, + showClipboard: { def: true }, + showCpuUsage: { def: true }, + showMemUsage: { def: true }, + showCpuTemp: { def: true }, + showGpuTemp: { def: true }, + selectedGpuIndex: { def: 0 }, + enabledGpuPciIds: { def: [] }, + showSystemTray: { def: true }, + showClock: { def: true }, + showNotificationButton: { def: true }, + showBattery: { def: true }, + showControlCenterButton: { def: true }, + + controlCenterShowNetworkIcon: { def: true }, + controlCenterShowBluetoothIcon: { def: true }, + controlCenterShowAudioIcon: { def: true }, + controlCenterWidgets: { def: [ + { id: "volumeSlider", enabled: true, width: 50 }, + { id: "brightnessSlider", enabled: true, width: 50 }, + { id: "wifi", enabled: true, width: 50 }, + { id: "bluetooth", enabled: true, width: 50 }, + { id: "audioOutput", enabled: true, width: 50 }, + { id: "audioInput", enabled: true, width: 50 }, + { id: "nightMode", enabled: true, width: 50 }, + { id: "darkMode", enabled: true, width: 50 } + ]}, + + showWorkspaceIndex: { def: false }, + showWorkspacePadding: { def: false }, + workspaceScrolling: { def: false }, + showWorkspaceApps: { def: false }, + maxWorkspaceIcons: { def: 3 }, + workspacesPerMonitor: { def: true }, + dwlShowAllTags: { def: false }, + workspaceNameIcons: { def: {} }, + waveProgressEnabled: { def: true }, + clockCompactMode: { def: false }, + focusedWindowCompactMode: { def: false }, + runningAppsCompactMode: { def: true }, + keyboardLayoutNameCompactMode: { def: false }, + runningAppsCurrentWorkspace: { def: false }, + runningAppsGroupByApp: { def: false }, + clockDateFormat: { def: "" }, + lockDateFormat: { def: "" }, + mediaSize: { def: 1 }, + + dankBarLeftWidgets: { def: ["launcherButton", "workspaceSwitcher", "focusedWindow"], migrate: ["topBarLeftWidgets"] }, + dankBarCenterWidgets: { def: ["music", "clock", "weather"], migrate: ["topBarCenterWidgets"] }, + dankBarRightWidgets: { def: ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"], migrate: ["topBarRightWidgets"] }, + dankBarWidgetOrder: { def: [] }, + + appLauncherViewMode: { def: "list" }, + spotlightModalViewMode: { def: "list" }, + sortAppsAlphabetically: { def: false }, + + weatherLocation: { def: "New York, NY" }, + weatherCoordinates: { def: "40.7128,-74.0060" }, + useAutoLocation: { def: false }, + weatherEnabled: { def: true }, + + networkPreference: { def: "auto" }, + vpnLastConnected: { def: "" }, + + iconTheme: { def: "System Default", onChange: "applyStoredIconTheme" }, + availableIconThemes: { def: ["System Default"], persist: false }, + systemDefaultIconTheme: { def: "", persist: false }, + qt5ctAvailable: { def: false, persist: false }, + qt6ctAvailable: { def: false, persist: false }, + gtkAvailable: { def: false, persist: false }, + + launcherLogoMode: { def: "apps" }, + launcherLogoCustomPath: { def: "" }, + launcherLogoColorOverride: { def: "" }, + launcherLogoColorInvertOnMode: { def: false }, + launcherLogoBrightness: { def: 0.5 }, + launcherLogoContrast: { def: 1 }, + launcherLogoSizeOffset: { def: 0 }, + + fontFamily: { def: "Inter Variable" }, + monoFontFamily: { def: "Fira Code" }, + fontWeight: { def: 400 }, + fontScale: { def: 1.0 }, + dankBarFontScale: { def: 1.0 }, + + notepadUseMonospace: { def: true }, + notepadFontFamily: { def: "" }, + notepadFontSize: { def: 14 }, + notepadShowLineNumbers: { def: false }, + notepadTransparencyOverride: { def: -1 }, + notepadLastCustomTransparency: { def: 0.7 }, + + soundsEnabled: { def: true }, + useSystemSoundTheme: { def: false }, + soundNewNotification: { def: true }, + soundVolumeChanged: { def: true }, + soundPluggedIn: { def: true }, + + acMonitorTimeout: { def: 0 }, + acLockTimeout: { def: 0 }, + acSuspendTimeout: { def: 0 }, + acHibernateTimeout: { def: 0 }, + batteryMonitorTimeout: { def: 0 }, + batteryLockTimeout: { def: 0 }, + batterySuspendTimeout: { def: 0 }, + batteryHibernateTimeout: { def: 0 }, + lockBeforeSuspend: { def: false }, + loginctlLockIntegration: { def: true }, + launchPrefix: { def: "" }, + brightnessDevicePins: { def: {} }, + + gtkThemingEnabled: { def: false, onChange: "regenSystemThemes" }, + qtThemingEnabled: { def: false, onChange: "regenSystemThemes" }, + syncModeWithPortal: { def: true }, + + showDock: { def: false }, + dockAutoHide: { def: false }, + dockGroupByApp: { def: false }, + dockOpenOnOverview: { def: false }, + dockPosition: { def: 1 }, + dockSpacing: { def: 4 }, + dockBottomGap: { def: 0 }, + dockIconSize: { def: 40 }, + dockIndicatorStyle: { def: "circle" }, + + notificationOverlayEnabled: { def: false }, + dankBarAutoHide: { def: false, migrate: ["topBarAutoHide"] }, + dankBarOpenOnOverview: { def: false, migrate: ["topBarOpenOnOverview"] }, + dankBarVisible: { def: true, migrate: ["topBarVisible"] }, + overviewRows: { def: 2, persist: false }, + overviewColumns: { def: 5, persist: false }, + overviewScale: { def: 0.16, persist: false }, + dankBarSpacing: { def: 4, migrate: ["topBarSpacing"], onChange: "updateNiriLayout" }, + dankBarBottomGap: { def: 0, migrate: ["topBarBottomGap"] }, + dankBarInnerPadding: { def: 4, migrate: ["topBarInnerPadding"] }, + dankBarPosition: { def: 0, migrate: ["dankBarAtBottom", "topBarAtBottom"] }, + dankBarIsVertical: { def: false, persist: false }, + + dankBarSquareCorners: { def: false, migrate: ["topBarSquareCorners"] }, + dankBarNoBackground: { def: false, migrate: ["topBarNoBackground"] }, + dankBarGothCornersEnabled: { def: false, migrate: ["topBarGothCornersEnabled"] }, + dankBarBorderEnabled: { def: false }, + dankBarBorderColor: { def: "surfaceText" }, + dankBarBorderOpacity: { def: 1.0 }, + dankBarBorderThickness: { def: 1 }, + + popupGapsAuto: { def: true }, + popupGapsManual: { def: 4 }, + + modalDarkenBackground: { def: true }, + + lockScreenShowPowerActions: { def: true }, + enableFprint: { def: false }, + maxFprintTries: { def: 3 }, + fprintdAvailable: { def: false, persist: false }, + hideBrightnessSlider: { def: false }, + + notificationTimeoutLow: { def: 5000 }, + notificationTimeoutNormal: { def: 5000 }, + notificationTimeoutCritical: { def: 0 }, + notificationPopupPosition: { def: 0 }, + + osdAlwaysShowValue: { def: false }, + + powerActionConfirm: { def: true }, + customPowerActionLock: { def: "" }, + customPowerActionLogout: { def: "" }, + customPowerActionSuspend: { def: "" }, + customPowerActionHibernate: { def: "" }, + customPowerActionReboot: { def: "" }, + customPowerActionPowerOff: { def: "" }, + + updaterUseCustomCommand: { def: false }, + updaterCustomCommand: { def: "" }, + updaterTerminalAdditionalParams: { def: "" }, + + screenPreferences: { def: {} }, + showOnLastDisplay: { def: {} } +}; + +function getValidKeys() { + return Object.keys(SPEC).filter(function(k) { return SPEC[k].persist !== false; }).concat(["configVersion"]); +} + +function set(root, key, value, saveFn, hooks) { + if (!(key in SPEC)) return; + root[key] = value; + var hookName = SPEC[key].onChange; + if (hookName && hooks && hooks[hookName]) { + hooks[hookName](root); + } + saveFn(); +} diff --git a/Common/settings/SettingsStore.js b/Common/settings/SettingsStore.js new file mode 100644 index 00000000..9902107b --- /dev/null +++ b/Common/settings/SettingsStore.js @@ -0,0 +1,118 @@ +.pragma library + +.import "./SettingsSpec.js" as SpecModule + +function parse(root, jsonObj) { + var SPEC = SpecModule.SPEC; + for (var k in SPEC) { + var spec = SPEC[k]; + root[k] = spec.def; + } + + if (!jsonObj) return; + + for (var k in jsonObj) { + if (!SPEC[k]) continue; + var raw = jsonObj[k]; + var spec = SPEC[k]; + var coerce = spec.coerce; + root[k] = coerce ? (coerce(raw) !== undefined ? coerce(raw) : root[k]) : raw; + } +} + +function toJson(root) { + var SPEC = SpecModule.SPEC; + var out = {}; + for (var k in SPEC) { + if (SPEC[k].persist === false) continue; + out[k] = root[k]; + } + out.configVersion = root.settingsConfigVersion; + return out; +} + +function migrate(root, jsonObj) { + var SPEC = SpecModule.SPEC; + if (!jsonObj) return; + + if (jsonObj.themeIndex !== undefined || jsonObj.themeIsDynamic !== undefined) { + var themeNames = ["blue", "deepBlue", "purple", "green", "orange", "red", "cyan", "pink", "amber", "coral"]; + if (jsonObj.themeIsDynamic) { + root.currentThemeName = "dynamic"; + } else if (jsonObj.themeIndex >= 0 && jsonObj.themeIndex < themeNames.length) { + root.currentThemeName = themeNames[jsonObj.themeIndex]; + } + console.info("Auto-migrated theme from index", jsonObj.themeIndex, "to", root.currentThemeName); + } + + if ((jsonObj.dankBarWidgetOrder && jsonObj.dankBarWidgetOrder.length > 0) || + (jsonObj.topBarWidgetOrder && jsonObj.topBarWidgetOrder.length > 0)) { + if (jsonObj.dankBarLeftWidgets === undefined && jsonObj.dankBarCenterWidgets === undefined && jsonObj.dankBarRightWidgets === undefined) { + var widgetOrder = jsonObj.dankBarWidgetOrder || jsonObj.topBarWidgetOrder; + root.dankBarLeftWidgets = widgetOrder.filter(function(w) { return ["launcherButton", "workspaceSwitcher", "focusedWindow"].indexOf(w) >= 0; }); + root.dankBarCenterWidgets = widgetOrder.filter(function(w) { return ["clock", "music", "weather"].indexOf(w) >= 0; }); + root.dankBarRightWidgets = widgetOrder.filter(function(w) { return ["systemTray", "clipboard", "systemResources", "notificationButton", "battery", "controlCenterButton"].indexOf(w) >= 0; }); + } + } + + if (jsonObj.useOSLogo !== undefined) { + root.launcherLogoMode = jsonObj.useOSLogo ? "os" : "apps"; + root.launcherLogoColorOverride = jsonObj.osLogoColorOverride !== undefined ? jsonObj.osLogoColorOverride : ""; + root.launcherLogoBrightness = jsonObj.osLogoBrightness !== undefined ? jsonObj.osLogoBrightness : 0.5; + root.launcherLogoContrast = jsonObj.osLogoContrast !== undefined ? jsonObj.osLogoContrast : 1; + } + + if (jsonObj.mediaCompactMode !== undefined && jsonObj.mediaSize === undefined) { + root.mediaSize = jsonObj.mediaCompactMode ? 0 : 1; + } + + for (var k in SPEC) { + var spec = SPEC[k]; + if (!spec.migrate) continue; + for (var i = 0; i < spec.migrate.length; i++) { + var oldKey = spec.migrate[i]; + if (jsonObj[oldKey] !== undefined && jsonObj[k] === undefined) { + var raw = jsonObj[oldKey]; + var coerce = spec.coerce; + root[k] = coerce ? (coerce(raw) !== undefined ? coerce(raw) : root[k]) : raw; + break; + } + } + } + + if (jsonObj.dankBarAtBottom !== undefined || jsonObj.topBarAtBottom !== undefined) { + var atBottom = jsonObj.dankBarAtBottom !== undefined ? jsonObj.dankBarAtBottom : jsonObj.topBarAtBottom; + root.dankBarPosition = atBottom ? 1 : 0; + } + + if (jsonObj.pluginSettings !== undefined) { + root.pluginSettings = jsonObj.pluginSettings; + return true; + } + + return false; +} + +function cleanup(fileText) { + var getValidKeys = SpecModule.getValidKeys; + if (!fileText || !fileText.trim()) return; + + try { + var settings = JSON.parse(fileText); + var validKeys = getValidKeys(); + var needsSave = false; + + for (var key in settings) { + if (validKeys.indexOf(key) < 0) { + console.log("SettingsData: Removing unused key:", key); + delete settings[key]; + needsSave = true; + } + } + + return needsSave ? JSON.stringify(settings, null, 2) : null; + } catch (e) { + console.warn("SettingsData: Failed to cleanup unused keys:", e.message); + return null; + } +} diff --git a/Modals/Settings/PowerSettings.qml b/Modals/Settings/PowerSettings.qml index 075d93ff..16d0da85 100644 --- a/Modals/Settings/PowerSettings.qml +++ b/Modals/Settings/PowerSettings.qml @@ -64,7 +64,7 @@ Item { text: I18n.tr("Show Power Actions") description: I18n.tr("Show power, restart, and logout buttons on the lock screen") checked: SettingsData.lockScreenShowPowerActions - onToggled: checked => SettingsData.setLockScreenShowPowerActions(checked) + onToggled: checked => SettingsData.set("lockScreenShowPowerActions", checked) } StyledText { @@ -84,7 +84,7 @@ Item { enabled: SessionService.loginctlAvailable onToggled: checked => { if (SessionService.loginctlAvailable) { - SettingsData.setLoginctlLockIntegration(checked) + SettingsData.set("loginctlLockIntegration", checked) } } } @@ -95,7 +95,7 @@ Item { description: I18n.tr("Automatically lock the screen when the system prepares to suspend") checked: SettingsData.lockBeforeSuspend visible: SessionService.loginctlAvailable && SettingsData.loginctlLockIntegration - onToggled: checked => SettingsData.setLockBeforeSuspend(checked) + onToggled: checked => SettingsData.set("lockBeforeSuspend", checked) } DankToggle { @@ -104,7 +104,7 @@ Item { description: I18n.tr("Use fingerprint reader for lock screen authentication (requires enrolled fingerprints)") checked: SettingsData.enableFprint visible: SettingsData.fprintdAvailable - onToggled: checked => SettingsData.setEnableFprint(checked) + onToggled: checked => SettingsData.set("enableFprint", checked) } } } @@ -186,9 +186,9 @@ Item { if (index >= 0) { const timeout = timeoutValues[index] if (powerCategory.currentIndex === 0) { - SettingsData.setAcLockTimeout(timeout) + SettingsData.set("acLockTimeout", timeout) } else { - SettingsData.setBatteryLockTimeout(timeout) + SettingsData.set("batteryLockTimeout", timeout) } } } @@ -222,9 +222,9 @@ Item { if (index >= 0) { const timeout = timeoutValues[index] if (powerCategory.currentIndex === 0) { - SettingsData.setAcMonitorTimeout(timeout) + SettingsData.set("acMonitorTimeout", timeout) } else { - SettingsData.setBatteryMonitorTimeout(timeout) + SettingsData.set("batteryMonitorTimeout", timeout) } } } @@ -258,9 +258,9 @@ Item { if (index >= 0) { const timeout = timeoutValues[index] if (powerCategory.currentIndex === 0) { - SettingsData.setAcSuspendTimeout(timeout) + SettingsData.set("acSuspendTimeout", timeout) } else { - SettingsData.setBatterySuspendTimeout(timeout) + SettingsData.set("batterySuspendTimeout", timeout) } } } @@ -295,9 +295,9 @@ Item { if (index >= 0) { const timeout = timeoutValues[index] if (powerCategory.currentIndex === 0) { - SettingsData.setAcHibernateTimeout(timeout) + SettingsData.set("acHibernateTimeout", timeout) } else { - SettingsData.setBatteryHibernateTimeout(timeout) + SettingsData.set("batteryHibernateTimeout", timeout) } } } @@ -352,7 +352,7 @@ Item { text: I18n.tr("Show Confirmation on Power Actions") description: I18n.tr("Request confirmation on power off, restart, suspend, hibernate and logout actions") checked: SettingsData.powerActionConfirm - onToggled: checked => SettingsData.setPowerActionConfirm(checked) + onToggled: checked => SettingsData.set("powerActionConfirm", checked) } } } @@ -418,7 +418,7 @@ Item { } onTextEdited: { - SettingsData.setCustomPowerActionLock(text.trim()); + SettingsData.set("customPowerActionLock", text.trim()); } } } @@ -450,7 +450,7 @@ Item { } onTextEdited: { - SettingsData.setCustomPowerActionLogout(text.trim()); + SettingsData.set("customPowerActionLogout", text.trim()); } } } @@ -482,7 +482,7 @@ Item { } onTextEdited: { - SettingsData.setCustomPowerActionSuspend(text.trim()); + SettingsData.set("customPowerActionSuspend", text.trim()); } } } @@ -514,7 +514,7 @@ Item { } onTextEdited: { - SettingsData.setCustomPowerActionHibernate(text.trim()); + SettingsData.set("customPowerActionHibernate", text.trim()); } } } @@ -546,7 +546,7 @@ Item { } onTextEdited: { - SettingsData.setCustomPowerActionReboot(text.trim()); + SettingsData.set("customPowerActionReboot", text.trim()); } } } @@ -578,7 +578,7 @@ Item { } onTextEdited: { - SettingsData.setCustomPowerActionPowerOff(text.trim()); + SettingsData.set("customPowerActionPowerOff", text.trim()); } } } diff --git a/Modals/Spotlight/SpotlightContent.qml b/Modals/Spotlight/SpotlightContent.qml index 177b47c9..4c3821c5 100644 --- a/Modals/Spotlight/SpotlightContent.qml +++ b/Modals/Spotlight/SpotlightContent.qml @@ -160,7 +160,7 @@ Item { parentModal.hide() } onViewModeSelected: mode => { - SettingsData.setSpotlightModalViewMode(mode) + SettingsData.set("spotlightModalViewMode", mode) } } diff --git a/Modules/AppDrawer/AppDrawerPopout.qml b/Modules/AppDrawer/AppDrawerPopout.qml index 85d9d5d5..392e133a 100644 --- a/Modules/AppDrawer/AppDrawerPopout.qml +++ b/Modules/AppDrawer/AppDrawerPopout.qml @@ -59,7 +59,7 @@ DankPopout { gridColumns: 4 onAppLaunched: appDrawerPopout.close() onViewModeSelected: function (mode) { - SettingsData.setAppLauncherViewMode(mode) + SettingsData.set("appLauncherViewMode", mode) } } diff --git a/Modules/ControlCenter/Components/DetailHost.qml b/Modules/ControlCenter/Components/DetailHost.qml index 1f53b310..92bc945e 100644 --- a/Modules/ControlCenter/Components/DetailHost.qml +++ b/Modules/ControlCenter/Components/DetailHost.qml @@ -50,7 +50,7 @@ Item { } return w }) - SettingsData.setControlCenterWidgets(newWidgets) + SettingsData.set("controlCenterWidgets", newWidgets) if (root.collapseCallback) { root.collapseCallback() } @@ -74,7 +74,7 @@ Item { } return w }) - SettingsData.setControlCenterWidgets(newWidgets) + SettingsData.set("controlCenterWidgets", newWidgets) if (root.collapseCallback) { root.collapseCallback() } diff --git a/Modules/ControlCenter/Components/DragDropDetailHost.qml b/Modules/ControlCenter/Components/DragDropDetailHost.qml index 5e54242c..2f00af9c 100644 --- a/Modules/ControlCenter/Components/DragDropDetailHost.qml +++ b/Modules/ControlCenter/Components/DragDropDetailHost.qml @@ -83,7 +83,7 @@ Item { } return w }) - SettingsData.setControlCenterWidgets(newWidgets) + SettingsData.set("controlCenterWidgets", newWidgets) } } } diff --git a/Modules/ControlCenter/Components/DragDropWidgetWrapper.qml b/Modules/ControlCenter/Components/DragDropWidgetWrapper.qml index 2f3f0506..6a005241 100644 --- a/Modules/ControlCenter/Components/DragDropWidgetWrapper.qml +++ b/Modules/ControlCenter/Components/DragDropWidgetWrapper.qml @@ -110,7 +110,7 @@ Item { copy[i] = copy[j]; copy[j] = tmp; - SettingsData.setControlCenterWidgets(copy); + SettingsData.set("controlCenterWidgets", copy); } function snapToGrid() { @@ -244,7 +244,7 @@ Item { var widgets = SettingsData.controlCenterWidgets.slice() if (widgetIndex >= 0 && widgetIndex < widgets.length) { widgets[widgetIndex].width = newSize - SettingsData.setControlCenterWidgets(widgets) + SettingsData.set("controlCenterWidgets", widgets) } } } diff --git a/Modules/ControlCenter/Details/BrightnessDetail.qml b/Modules/ControlCenter/Details/BrightnessDetail.qml index d8e1c337..134b92c6 100644 --- a/Modules/ControlCenter/Details/BrightnessDetail.qml +++ b/Modules/ControlCenter/Details/BrightnessDetail.qml @@ -85,7 +85,7 @@ Rectangle { pins[screenName] = currentDeviceName } - SettingsData.setBrightnessDevicePins(pins) + SettingsData.set("brightnessDevicePins", pins) } implicitHeight: brightnessContent.height + Theme.spacingM @@ -314,7 +314,7 @@ Rectangle { const pins = JSON.parse(JSON.stringify(SettingsData.brightnessDevicePins || {})) if (pins[screenName]) { delete pins[screenName] - SettingsData.setBrightnessDevicePins(pins) + SettingsData.set("brightnessDevicePins", pins) } } currentDeviceName = modelData.name diff --git a/Modules/DankDash/WeatherTab.qml b/Modules/DankDash/WeatherTab.qml index 29a3fea7..a13489be 100644 --- a/Modules/DankDash/WeatherTab.qml +++ b/Modules/DankDash/WeatherTab.qml @@ -139,7 +139,7 @@ Item { cursorShape: Qt.PointingHandCursor onClicked: { if (WeatherService.weather.available) { - SettingsData.setTemperatureUnit(!SettingsData.useFahrenheit) + SettingsData.set("temperatureUnit", !SettingsData.useFahrenheit) } } enabled: WeatherService.weather.available diff --git a/Modules/Notifications/Center/NotificationSettings.qml b/Modules/Notifications/Center/NotificationSettings.qml index 4f09800e..704acc39 100644 --- a/Modules/Notifications/Center/NotificationSettings.qml +++ b/Modules/Notifications/Center/NotificationSettings.qml @@ -164,7 +164,7 @@ Rectangle { onValueChanged: value => { for (let i = 0; i < timeoutOptions.length; i++) { if (timeoutOptions[i].text === value) { - SettingsData.setNotificationTimeoutLow(timeoutOptions[i].value) + SettingsData.set("notificationTimeoutLow", timeoutOptions[i].value) break } } @@ -179,7 +179,7 @@ Rectangle { onValueChanged: value => { for (let i = 0; i < timeoutOptions.length; i++) { if (timeoutOptions[i].text === value) { - SettingsData.setNotificationTimeoutNormal(timeoutOptions[i].value) + SettingsData.set("notificationTimeoutNormal", timeoutOptions[i].value) break } } @@ -194,7 +194,7 @@ Rectangle { onValueChanged: value => { for (let i = 0; i < timeoutOptions.length; i++) { if (timeoutOptions[i].text === value) { - SettingsData.setNotificationTimeoutCritical(timeoutOptions[i].value) + SettingsData.set("notificationTimeoutCritical", timeoutOptions[i].value) break } } @@ -245,7 +245,7 @@ Rectangle { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter checked: SettingsData.notificationOverlayEnabled - onToggled: toggled => SettingsData.setNotificationOverlayEnabled(toggled) + onToggled: toggled => SettingsData.set("notificationOverlayEnabled", toggled) } } } diff --git a/Modules/Settings/DankBarTab.qml b/Modules/Settings/DankBarTab.qml index da52d6e2..16e54f06 100644 --- a/Modules/Settings/DankBarTab.qml +++ b/Modules/Settings/DankBarTab.qml @@ -502,11 +502,11 @@ Item { function handleControlCenterSettingChanged(sectionId, widgetIndex, settingName, value) { // Control Center settings are global, not per-widget instance if (settingName === "showNetworkIcon") { - SettingsData.setControlCenterShowNetworkIcon(value) + SettingsData.set("controlCenterShowNetworkIcon", value) } else if (settingName === "showBluetoothIcon") { - SettingsData.setControlCenterShowBluetoothIcon(value) + SettingsData.set("controlCenterShowBluetoothIcon", value) } else if (settingName === "showAudioIcon") { - SettingsData.setControlCenterShowAudioIcon(value) + SettingsData.set("controlCenterShowAudioIcon", value) } } @@ -786,7 +786,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.dankBarAutoHide onToggled: toggled => { - return SettingsData.setDankBarAutoHide( + return SettingsData.set("dankBarAutoHide", toggled) } } @@ -838,7 +838,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.dankBarVisible onToggled: toggled => { - return SettingsData.setDankBarVisible( + return SettingsData.set("dankBarVisible", toggled) } } @@ -892,7 +892,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.dankBarOpenOnOverview onToggled: toggled => { - return SettingsData.setDankBarOpenOnOverview( + return SettingsData.set("dankBarOpenOnOverview", toggled) } } @@ -1047,7 +1047,7 @@ Item { iconColor: Theme.surfaceText anchors.verticalCenter: parent.verticalCenter onClicked: { - SettingsData.setDankBarBottomGap(0) + SettingsData.set("dankBarBottomGap", 0) } } @@ -1069,7 +1069,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setDankBarBottomGap( + SettingsData.set("dankBarBottomGap", newValue) } @@ -1119,7 +1119,7 @@ Item { iconColor: Theme.surfaceText anchors.verticalCenter: parent.verticalCenter onClicked: { - SettingsData.setDankBarInnerPadding(4) + SettingsData.set("dankBarInnerPadding", 4) } } @@ -1141,7 +1141,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setDankBarInnerPadding( + SettingsData.set("dankBarInnerPadding", newValue) } @@ -1164,7 +1164,7 @@ Item { description: I18n.tr("Automatically calculate popup distance from bar edge.") checked: SettingsData.popupGapsAuto onToggled: checked => { - SettingsData.setPopupGapsAuto(checked) + SettingsData.set("popupGapsAuto", checked) } } @@ -1218,7 +1218,7 @@ Item { iconColor: Theme.surfaceText anchors.verticalCenter: parent.verticalCenter onClicked: { - SettingsData.setPopupGapsManual(4) + SettingsData.set("popupGapsManual", 4) } } @@ -1240,7 +1240,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setPopupGapsManual(newValue) + SettingsData.set("popupGapsManual", newValue) } Binding { @@ -1260,7 +1260,7 @@ Item { description: "Removes rounded corners from bar container." checked: SettingsData.dankBarSquareCorners onToggled: checked => { - SettingsData.setDankBarSquareCorners( + SettingsData.set("dankBarSquareCorners", checked) } } @@ -1271,7 +1271,7 @@ Item { description: "Remove widget backgrounds for a minimal look with tighter spacing." checked: SettingsData.dankBarNoBackground onToggled: checked => { - SettingsData.setDankBarNoBackground( + SettingsData.set("dankBarNoBackground", checked) } } @@ -1282,7 +1282,7 @@ Item { description: "Add curved swooping tips at the bottom of the bar." checked: SettingsData.dankBarGothCornersEnabled onToggled: checked => { - SettingsData.setDankBarGothCornersEnabled( + SettingsData.set("dankBarGothCornersEnabled", checked) } } @@ -1297,7 +1297,7 @@ Item { description: "Add a 1px border to the bar. Smart edge detection only shows border on exposed sides." checked: SettingsData.dankBarBorderEnabled onToggled: checked => { - SettingsData.setDankBarBorderEnabled(checked) + SettingsData.set("dankBarBorderEnabled", checked) } } @@ -1565,7 +1565,7 @@ Item { iconColor: Theme.surfaceText onClicked: { var newScale = Math.max(0.5, SettingsData.dankBarFontScale - 0.05) - SettingsData.setDankBarFontScale(newScale) + SettingsData.set("dankBarFontScale", newScale) } } @@ -1595,7 +1595,7 @@ Item { iconColor: Theme.surfaceText onClicked: { var newScale = Math.min(2.0, SettingsData.dankBarFontScale + 0.05) - SettingsData.setDankBarFontScale(newScale) + SettingsData.set("dankBarFontScale", newScale) } } } @@ -1770,19 +1770,19 @@ Item { } onCompactModeChanged: (widgetId, value) => { if (widgetId === "clock") { - SettingsData.setClockCompactMode( + SettingsData.set("clockCompactMode", value) } else if (widgetId === "music") { - SettingsData.setMediaSize( + SettingsData.set("mediaSize", value) } else if (widgetId === "focusedWindow") { - SettingsData.setFocusedWindowCompactMode( + SettingsData.set("focusedWindowCompactMode", value) } else if (widgetId === "runningApps") { - SettingsData.setRunningAppsCompactMode( + SettingsData.set("runningAppsCompactMode", value) } else if (widgetId === "keyboard_layout_name") { - SettingsData.setKeyboardLayoutNameCompactMode( + SettingsData.set("keyboardLayoutNameCompactMode", value) } } @@ -1849,19 +1849,19 @@ Item { } onCompactModeChanged: (widgetId, value) => { if (widgetId === "clock") { - SettingsData.setClockCompactMode( + SettingsData.set("clockCompactMode", value) } else if (widgetId === "music") { - SettingsData.setMediaSize( + SettingsData.set("mediaSize", value) } else if (widgetId === "focusedWindow") { - SettingsData.setFocusedWindowCompactMode( + SettingsData.set("focusedWindowCompactMode", value) } else if (widgetId === "runningApps") { - SettingsData.setRunningAppsCompactMode( + SettingsData.set("runningAppsCompactMode", value) } else if (widgetId === "keyboard_layout_name") { - SettingsData.setKeyboardLayoutNameCompactMode( + SettingsData.set("keyboardLayoutNameCompactMode", value) } } @@ -1928,19 +1928,19 @@ Item { } onCompactModeChanged: (widgetId, value) => { if (widgetId === "clock") { - SettingsData.setClockCompactMode( + SettingsData.set("clockCompactMode", value) } else if (widgetId === "music") { - SettingsData.setMediaSize( + SettingsData.set("mediaSize", value) } else if (widgetId === "focusedWindow") { - SettingsData.setFocusedWindowCompactMode( + SettingsData.set("focusedWindowCompactMode", value) } else if (widgetId === "runningApps") { - SettingsData.setRunningAppsCompactMode( + SettingsData.set("runningAppsCompactMode", value) } else if (widgetId === "keyboard_layout_name") { - SettingsData.setKeyboardLayoutNameCompactMode( + SettingsData.set("keyboardLayoutNameCompactMode", value) } } diff --git a/Modules/Settings/DisplaysTab.qml b/Modules/Settings/DisplaysTab.qml index ece2af6c..fc27073a 100644 --- a/Modules/Settings/DisplaysTab.qml +++ b/Modules/Settings/DisplaysTab.qml @@ -59,7 +59,7 @@ Item { var prefs = SettingsData.screenPreferences || {}; var newPrefs = Object.assign({}, prefs); newPrefs[componentId] = screenNames; - SettingsData.setScreenPreferences(newPrefs); + SettingsData.set("screenPreferences", newPrefs); } function getShowOnLastDisplay(componentId) { @@ -70,7 +70,7 @@ Item { var prefs = SettingsData.showOnLastDisplay || {}; var newPrefs = Object.assign({}, prefs); newPrefs[componentId] = enabled; - SettingsData.setShowOnLastDisplay(newPrefs); + SettingsData.set("showOnLastDisplay", newPrefs); } DankFlickable { diff --git a/Modules/Settings/DockTab.qml b/Modules/Settings/DockTab.qml index 8270c864..8ec2886c 100644 --- a/Modules/Settings/DockTab.qml +++ b/Modules/Settings/DockTab.qml @@ -146,7 +146,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.dockAutoHide onToggled: checked => { - SettingsData.setDockAutoHide(checked) + SettingsData.set("dockAutoHide", checked) } } } @@ -250,7 +250,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.dockOpenOnOverview onToggled: checked => { - SettingsData.setDockOpenOnOverview(checked) + SettingsData.set("dockOpenOnOverview", checked) } } } @@ -315,7 +315,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.dockGroupByApp onToggled: checked => { - SettingsData.setDockGroupByApp(checked) + SettingsData.set("dockGroupByApp", checked) } } } @@ -380,7 +380,7 @@ Item { currentIndex: SettingsData.dockIndicatorStyle === "circle" ? 0 : 1 onSelectionChanged: (index, selected) => { if (selected) { - SettingsData.setDockIndicatorStyle(index === 0 ? "circle" : "line") + SettingsData.set("dockIndicatorStyle", index === 0 ? "circle" : "line") } } } @@ -445,7 +445,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setDockIconSize(newValue) + SettingsData.set("dockIconSize", newValue) } } } @@ -519,7 +519,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setDockSpacing( + SettingsData.set("dockSpacing", newValue) } } @@ -547,7 +547,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setDockBottomGap( + SettingsData.set("dockBottomGap", newValue) } } @@ -612,7 +612,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setDockTransparency( + SettingsData.set("dockTransparency", newValue / 100) } } diff --git a/Modules/Settings/LauncherTab.qml b/Modules/Settings/LauncherTab.qml index c24200da..d200e57e 100644 --- a/Modules/Settings/LauncherTab.qml +++ b/Modules/Settings/LauncherTab.qml @@ -18,7 +18,7 @@ Item { browserType: "generic" filterExtensions: ["*.svg", "*.png", "*.jpg", "*.jpeg", "*.webp"] onFileSelected: path => { - SettingsData.setLauncherLogoCustomPath(path.replace("file://", "")) + SettingsData.set("launcherLogoCustomPath", path.replace("file://", "")) } } @@ -112,15 +112,15 @@ Item { onSelectionChanged: (index, selected) => { if (!selected) return if (index === 0) { - SettingsData.setLauncherLogoMode("apps") + SettingsData.set("launcherLogoMode", "apps") } else if (index === 1) { - SettingsData.setLauncherLogoMode("os") + SettingsData.set("launcherLogoMode", "os") } else if (index === 2) { - SettingsData.setLauncherLogoMode("dank") + SettingsData.set("launcherLogoMode", "dank") } else if (index === 3) { - SettingsData.setLauncherLogoMode("compositor") + SettingsData.set("launcherLogoMode", "compositor") } else if (index === 4) { - SettingsData.setLauncherLogoMode("custom") + SettingsData.set("launcherLogoMode", "custom") } } } @@ -210,16 +210,16 @@ Item { onSelectionChanged: (index, selected) => { if (!selected) return if (index === 0) { - SettingsData.setLauncherLogoColorOverride("") + SettingsData.set("launcherLogoColorOverride", "") } else if (index === 1) { - SettingsData.setLauncherLogoColorOverride("primary") + SettingsData.set("launcherLogoColorOverride", "primary") } else if (index === 2) { - SettingsData.setLauncherLogoColorOverride("surface") + SettingsData.set("launcherLogoColorOverride", "surface") } else if (index === 3) { const currentOverride = SettingsData.launcherLogoColorOverride const isPreset = currentOverride === "" || currentOverride === "primary" || currentOverride === "surface" if (isPreset) { - SettingsData.setLauncherLogoColorOverride("#ffffff") + SettingsData.set("launcherLogoColorOverride", "#ffffff") } } } @@ -252,7 +252,7 @@ Item { PopoutService.colorPickerModal.selectedColor = SettingsData.launcherLogoColorOverride PopoutService.colorPickerModal.pickerTitle = I18n.tr("Choose Launcher Logo Color") PopoutService.colorPickerModal.onColorSelectedCallback = function(selectedColor) { - SettingsData.setLauncherLogoColorOverride(selectedColor) + SettingsData.set("launcherLogoColorOverride", selectedColor) } PopoutService.colorPickerModal.show() } @@ -291,7 +291,7 @@ Item { thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) anchors.horizontalCenter: parent.horizontalCenter onSliderValueChanged: newValue => { - SettingsData.setLauncherLogoSizeOffset(newValue) + SettingsData.set("launcherLogoSizeOffset", newValue) } } } @@ -342,7 +342,7 @@ Item { thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) anchors.horizontalCenter: parent.horizontalCenter onSliderValueChanged: newValue => { - SettingsData.setLauncherLogoBrightness(newValue / 100) + SettingsData.set("launcherLogoBrightness", newValue / 100) } } } @@ -371,7 +371,7 @@ Item { thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) anchors.horizontalCenter: parent.horizontalCenter onSliderValueChanged: newValue => { - SettingsData.setLauncherLogoContrast(newValue / 100) + SettingsData.set("launcherLogoContrast", newValue / 100) } } } @@ -394,7 +394,7 @@ Item { checked: SettingsData.launcherLogoColorInvertOnMode anchors.horizontalCenter: parent.horizontalCenter onToggled: checked => { - SettingsData.setLauncherLogoColorInvertOnMode(checked) + SettingsData.set("launcherLogoColorInvertOnMode", checked) } } } @@ -453,7 +453,7 @@ Item { text: SettingsData.launchPrefix placeholderText: I18n.tr("Enter launch prefix (e.g., 'uwsm-app')") onTextEdited: { - SettingsData.setLaunchPrefix(text) + SettingsData.set("launchPrefix", text) } } } @@ -509,7 +509,7 @@ Item { checked: SettingsData.sortAppsAlphabetically anchors.verticalCenter: parent.verticalCenter onToggled: checked => { - SettingsData.setSortAppsAlphabetically(checked) + SettingsData.set("sortAppsAlphabetically", checked) } } } diff --git a/Modules/Settings/PersonalizationTab.qml b/Modules/Settings/PersonalizationTab.qml index 0a8ab976..c8145847 100644 --- a/Modules/Settings/PersonalizationTab.qml +++ b/Modules/Settings/PersonalizationTab.qml @@ -413,7 +413,7 @@ Item { onSelectionChanged: (index, selected) => { if (selected) { const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"] - SettingsData.setWallpaperFillMode(modes[index]) + SettingsData.set("wallpaperFillMode", modes[index]) } } @@ -930,7 +930,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.blurWallpaperOnOverview onToggled: checked => { - SettingsData.setBlurWallpaperOnOverview(checked) + SettingsData.set("blurWallpaperOnOverview", checked) } } } @@ -1461,7 +1461,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.blurredWallpaperLayer onToggled: checked => { - SettingsData.setBlurredWallpaperLayer(checked) + SettingsData.set("blurredWallpaperLayer", checked) } } } @@ -1573,7 +1573,7 @@ Item { currentIndex: SettingsData.animationSpeed onSelectionChanged: (index, selected) => { if (selected) { - SettingsData.setAnimationSpeed(index) + SettingsData.set("animationSpeed", index) } } @@ -1654,8 +1654,8 @@ Item { wheelEnabled: false onSliderValueChanged: newValue => { - SettingsData.setAnimationSpeed(SettingsData.AnimationSpeed.Custom) - SettingsData.setCustomAnimationDuration(newValue) + SettingsData.set("animationSpeed", SettingsData.AnimationSpeed.Custom) + SettingsData.set("customAnimationDuration", newValue) } Connections { @@ -1926,7 +1926,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.soundsEnabled onToggled: checked => { - SettingsData.setSoundsEnabled(checked) + SettingsData.set("soundsEnabled", checked) } } } @@ -1974,7 +1974,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.useSystemSoundTheme onToggled: checked => { - SettingsData.setUseSystemSoundTheme(checked) + SettingsData.set("useSystemSoundTheme", checked) } } } @@ -2039,7 +2039,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.soundNewNotification onToggled: checked => { - SettingsData.setSoundNewNotification(checked) + SettingsData.set("soundNewNotification", checked) } } } @@ -2073,7 +2073,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.soundVolumeChanged onToggled: checked => { - SettingsData.setSoundVolumeChanged(checked) + SettingsData.set("soundVolumeChanged", checked) } } } @@ -2108,7 +2108,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.soundPluggedIn onToggled: checked => { - SettingsData.setSoundPluggedIn(checked) + SettingsData.set("soundPluggedIn", checked) } } } diff --git a/Modules/Settings/ThemeColorsTab.qml b/Modules/Settings/ThemeColorsTab.qml index 965338a5..b9793b6b 100644 --- a/Modules/Settings/ThemeColorsTab.qml +++ b/Modules/Settings/ThemeColorsTab.qml @@ -770,7 +770,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setDankBarTransparency( + SettingsData.set("dankBarTransparency", newValue / 100) } } @@ -835,7 +835,7 @@ Item { onSelectionChanged: (index, selected) => { if (!selected) return const colorOptions = ["sth", "s", "sc", "sch"] - SettingsData.setWidgetBackgroundColor(colorOptions[index]) + SettingsData.set("widgetBackgroundColor", colorOptions[index]) } } } @@ -852,7 +852,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setDankBarWidgetTransparency( + SettingsData.set("dankBarWidgetTransparency", newValue / 100) } } @@ -889,7 +889,7 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setPopupTransparency( + SettingsData.set("popupTransparency", newValue / 100) } } @@ -968,7 +968,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.modalDarkenBackground onToggled: checked => { - SettingsData.setModalDarkenBackground(checked) + SettingsData.set("modalDarkenBackground", checked) } } } @@ -1026,9 +1026,9 @@ Item { options: cachedFontFamilies onValueChanged: value => { if (value.startsWith("Default")) - SettingsData.setFontFamily(SettingsData.defaultFontFamily) + SettingsData.set("fontFamily", SettingsData.defaultFontFamily) else - SettingsData.setFontFamily(value) + SettingsData.set("fontFamily", value) } } @@ -1094,7 +1094,7 @@ Item { weight = Font.Normal break } - SettingsData.setFontWeight(weight) + SettingsData.set("fontWeight", weight) } } @@ -1113,9 +1113,9 @@ Item { options: cachedMonoFamilies onValueChanged: value => { if (value === "Default") - SettingsData.setMonoFontFamily(SettingsData.defaultMonoFontFamily) + SettingsData.set("monoFontFamily", SettingsData.defaultMonoFontFamily) else - SettingsData.setMonoFontFamily(value) + SettingsData.set("monoFontFamily", value) } } @@ -1165,7 +1165,7 @@ Item { iconColor: Theme.surfaceText onClicked: { var newScale = Math.max(1.0, SettingsData.fontScale - 0.05) - SettingsData.setFontScale(newScale) + SettingsData.set("fontScale", newScale) } } @@ -1199,7 +1199,7 @@ Item { onClicked: { var newScale = Math.min(2.0, SettingsData.fontScale + 0.05) - SettingsData.setFontScale(newScale) + SettingsData.set("fontScale", newScale) } } } @@ -1258,7 +1258,7 @@ Item { height: 32 checked: SettingsData.syncModeWithPortal anchors.verticalCenter: parent.verticalCenter - onToggled: checked => SettingsData.setSyncModeWithPortal(checked) + onToggled: checked => SettingsData.set("syncModeWithPortal", checked) } } } @@ -1499,7 +1499,7 @@ Item { onFileSelected: function(filePath) { // Save the custom theme file path and switch to custom theme if (filePath.endsWith(".json")) { - SettingsData.setCustomThemeFile(filePath) + SettingsData.set("customThemeFile", filePath) Theme.switchTheme("custom") close() } diff --git a/Modules/Settings/TimeWeatherTab.qml b/Modules/Settings/TimeWeatherTab.qml index bb19ba26..3a8c2fd0 100644 --- a/Modules/Settings/TimeWeatherTab.qml +++ b/Modules/Settings/TimeWeatherTab.qml @@ -77,7 +77,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.use24HourClock onToggled: checked => { - return SettingsData.setClockFormat( + return SettingsData.set("clockFormat", checked) } } @@ -140,7 +140,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.showSeconds onToggled: checked => { - return SettingsData.setTimeFormat( + return SettingsData.set("timeFormat", checked) } } @@ -240,7 +240,7 @@ Item { customFormatInput.visible = true } else { customFormatInput.visible = false - SettingsData.setClockDateFormat( + SettingsData.set("clockDateFormat", formatMap[value]) } } @@ -302,7 +302,7 @@ Item { customLockFormatInput.visible = true } else { customLockFormatInput.visible = false - SettingsData.setLockDateFormat( + SettingsData.set("lockDateFormat", formatMap[value]) } } @@ -317,7 +317,7 @@ Item { text: SettingsData.clockDateFormat onTextChanged: { if (visible && text) - SettingsData.setClockDateFormat(text) + SettingsData.set("clockDateFormat", text) } } @@ -330,7 +330,7 @@ Item { text: SettingsData.lockDateFormat onTextChanged: { if (visible && text) - SettingsData.setLockDateFormat(text) + SettingsData.set("lockDateFormat", text) } } @@ -491,7 +491,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.weatherEnabled onToggled: checked => { - return SettingsData.setWeatherEnabled( + return SettingsData.set("weatherEnabled", checked) } } @@ -556,7 +556,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.useFahrenheit onToggled: checked => { - return SettingsData.setTemperatureUnit( + return SettingsData.set("temperatureUnit", checked) } } @@ -628,7 +628,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.useAutoLocation onToggled: checked => { - return SettingsData.setAutoLocation( + return SettingsData.set("autoLocation", checked) } } @@ -966,7 +966,7 @@ Item { cursorShape: Qt.PointingHandCursor onClicked: { if (WeatherService.weather.available) { - SettingsData.setTemperatureUnit(!SettingsData.useFahrenheit) + SettingsData.set("temperatureUnit", !SettingsData.useFahrenheit) } } enabled: WeatherService.weather.available diff --git a/Modules/Settings/WidgetTweaksTab.qml b/Modules/Settings/WidgetTweaksTab.qml index 6cffb90d..0627fa55 100644 --- a/Modules/Settings/WidgetTweaksTab.qml +++ b/Modules/Settings/WidgetTweaksTab.qml @@ -61,7 +61,7 @@ Item { description: I18n.tr("Show workspace index numbers in the top bar workspace switcher") checked: SettingsData.showWorkspaceIndex onToggled: checked => { - return SettingsData.setShowWorkspaceIndex( + return SettingsData.set("showWorkspaceIndex", checked) } } @@ -71,7 +71,7 @@ Item { description: I18n.tr("Always show a minimum of 3 workspaces, even if fewer are available") checked: SettingsData.showWorkspacePadding onToggled: checked => { - return SettingsData.setShowWorkspacePadding( + return SettingsData.set("showWorkspacePadding", checked) } } @@ -82,7 +82,7 @@ Item { description: I18n.tr("Display application icons in workspace indicators") checked: SettingsData.showWorkspaceApps onToggled: checked => { - return SettingsData.setShowWorkspaceApps( + return SettingsData.set("showWorkspaceApps", checked) } } @@ -116,7 +116,7 @@ Item { topPadding: Theme.spacingXS bottomPadding: Theme.spacingXS onEditingFinished: { - SettingsData.setMaxWorkspaceIcons(parseInt(text, 10)) + SettingsData.set("maxWorkspaceIcons", parseInt(text, 10)) } } } @@ -135,7 +135,7 @@ Item { description: I18n.tr("Show only workspaces belonging to each specific monitor.") checked: SettingsData.workspacesPerMonitor onToggled: checked => { - return SettingsData.setWorkspacesPerMonitor(checked); + return SettingsData.set("workspacesPerMonitor", checked); } } @@ -146,7 +146,7 @@ Item { checked: SettingsData.dwlShowAllTags visible: CompositorService.isDwl onToggled: checked => { - return SettingsData.setDwlShowAllTags(checked); + return SettingsData.set("dwlShowAllTags", checked); } } } @@ -194,7 +194,7 @@ Item { description: I18n.tr("Use animated wave progress bars for media playback") checked: SettingsData.waveProgressEnabled onToggled: checked => { - return SettingsData.setWaveProgressEnabled(checked); + return SettingsData.set("waveProgressEnabled", checked); } } } @@ -244,10 +244,10 @@ Item { if (!checked) { updaterCustomCommand.text = ""; updaterTerminalCustomClass.text = ""; - SettingsData.setUpdaterCustomCommand(""); - SettingsData.setUpdaterTerminalAdditionalParams(""); + SettingsData.set("updaterCustomCommand", ""); + SettingsData.set("updaterTerminalAdditionalParams", ""); } - return SettingsData.setUpdaterUseCustomCommandEnabled(checked); + return SettingsData.set("updaterUseCustomCommandEnabled", checked); } } @@ -284,7 +284,7 @@ Item { } onTextEdited: { - SettingsData.setUpdaterCustomCommand(text.trim()); + SettingsData.set("updaterCustomCommand", text.trim()); } MouseArea { @@ -331,7 +331,7 @@ Item { } onTextEdited: { - SettingsData.setUpdaterTerminalAdditionalParams(text.trim()); + SettingsData.set("updaterTerminalAdditionalParams", text.trim()); } MouseArea { @@ -389,7 +389,7 @@ Item { description: I18n.tr("Show only apps running in current workspace") checked: SettingsData.runningAppsCurrentWorkspace onToggled: checked => { - return SettingsData.setRunningAppsCurrentWorkspace( + return SettingsData.set("runningAppsCurrentWorkspace", checked) } } @@ -621,19 +621,19 @@ Item { onValueChanged: value => { switch (value) { case "Top Right": - SettingsData.setNotificationPopupPosition(SettingsData.Position.Top) + SettingsData.set("notificationPopupPosition", SettingsData.Position.Top) break case "Top Left": - SettingsData.setNotificationPopupPosition(SettingsData.Position.Left) + SettingsData.set("notificationPopupPosition", SettingsData.Position.Left) break case "Top Center": - SettingsData.setNotificationPopupPosition(-1) + SettingsData.set("notificationPopupPosition", -1) break case "Bottom Right": - SettingsData.setNotificationPopupPosition(SettingsData.Position.Right) + SettingsData.set("notificationPopupPosition", SettingsData.Position.Right) break case "Bottom Left": - SettingsData.setNotificationPopupPosition(SettingsData.Position.Bottom) + SettingsData.set("notificationPopupPosition", SettingsData.Position.Bottom) break } SettingsData.sendTestNotifications() @@ -693,7 +693,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.osdAlwaysShowValue onToggleCompleted: checked => { - SettingsData.setOsdAlwaysShowValue(checked) + SettingsData.set("osdAlwaysShowValue", checked) } } } diff --git a/Modules/Settings/WidgetsTabSection.qml b/Modules/Settings/WidgetsTabSection.qml index e74a5ff8..3523830f 100644 --- a/Modules/Settings/WidgetsTabSection.qml +++ b/Modules/Settings/WidgetsTabSection.qml @@ -483,7 +483,7 @@ Column { iconSize: 16 iconColor: SettingsData.runningAppsGroupByApp ? Theme.primary : Theme.outline onClicked: { - SettingsData.setRunningAppsGroupByApp(!SettingsData.runningAppsGroupByApp) + SettingsData.set("runningAppsGroupByApp", !SettingsData.runningAppsGroupByApp) } onEntered: { groupByAppTooltipLoader.active = true diff --git a/Services/DMSNetworkService.qml b/Services/DMSNetworkService.qml index c2af7b6a..b29dfc8b 100644 --- a/Services/DMSNetworkService.qml +++ b/Services/DMSNetworkService.qml @@ -280,7 +280,7 @@ Singleton { if (vpnConnected && activeUuid) { lastConnectedVpnUuid = activeUuid - SettingsData.setVpnLastConnected(activeUuid) + SettingsData.set("vpnLastConnected", activeUuid) } if (vpnIsBusy) { @@ -558,7 +558,7 @@ Singleton { userPreference = preference changingPreference = true targetPreference = preference - SettingsData.setNetworkPreference(preference) + SettingsData.set("networkPreference", preference) DMSService.sendRequest("network.preference.set", { preference: preference }, response => { changingPreference = false diff --git a/Services/LegacyNetworkService.qml b/Services/LegacyNetworkService.qml index 7a7aecd5..59439693 100644 --- a/Services/LegacyNetworkService.qml +++ b/Services/LegacyNetworkService.qml @@ -764,7 +764,7 @@ Singleton { root.userPreference = preference root.changingPreference = true root.targetPreference = preference - SettingsData.setNetworkPreference(preference) + SettingsData.set("networkPreference", preference) if (preference === "wifi") { setConnectionPriority("wifi")