From 2a002304b9236bb50b65b0803ad630b7441c4461 Mon Sep 17 00:00:00 2001 From: bbedward Date: Sun, 23 Nov 2025 13:26:04 -0500 Subject: [PATCH] migrate default font family props to Theme --- quickshell/Common/SettingsData.qml | 906 ++++++++++-------- quickshell/Common/Theme.qml | 823 ++++++++-------- quickshell/Modules/Greetd/GreetdSettings.qml | 81 +- .../Modules/Notepad/NotepadSettings.qml | 2 +- .../Modules/Settings/PersonalizationTab.qml | 630 ++++++------ .../Modules/Settings/ThemeColorsTab.qml | 411 ++++---- quickshell/Widgets/StyledText.qml | 11 +- quickshell/Widgets/StyledTextMetrics.qml | 12 +- 8 files changed, 1456 insertions(+), 1420 deletions(-) diff --git a/quickshell/Common/SettingsData.qml b/quickshell/Common/SettingsData.qml index e929f062..e127a345 100644 --- a/quickshell/Common/SettingsData.qml +++ b/quickshell/Common/SettingsData.qml @@ -1,5 +1,4 @@ pragma Singleton - pragma ComponentBehavior: Bound import QtCore @@ -49,8 +48,6 @@ Singleton { Colorful } - readonly property string defaultFontFamily: "Inter Variable" - readonly property string defaultMonoFontFamily: "Fira Code" readonly property string _homeUrl: StandardPaths.writableLocation(StandardPaths.HomeLocation) readonly property string _configUrl: StandardPaths.writableLocation(StandardPaths.ConfigLocation) readonly property string _configDir: Paths.strip(_configUrl) @@ -113,39 +110,48 @@ Singleton { property bool privacyShowCameraIcon: false property bool privacyShowScreenShareIcon: false - property var controlCenterWidgets: [{ + property var 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 - }] + } + ] property bool showWorkspaceIndex: false property bool showWorkspacePadding: false @@ -166,7 +172,6 @@ Singleton { property string lockDateFormat: "" property int mediaSize: 1 - property string appLauncherViewMode: "list" property string spotlightModalViewMode: "list" property bool sortAppsAlphabetically: false @@ -215,9 +220,9 @@ Singleton { onNotepadShowLineNumbersChanged: saveSettings() onNotepadTransparencyOverrideChanged: { if (notepadTransparencyOverride > 0) { - notepadLastCustomTransparency = notepadTransparencyOverride + notepadLastCustomTransparency = notepadTransparencyOverride; } - saveSettings() + saveSettings(); } onNotepadLastCustomTransparencyChanged: saveSettings() @@ -308,38 +313,40 @@ Singleton { property var screenPreferences: ({}) property var showOnLastDisplay: ({}) - property var barConfigs: [{ - id: "default", - name: "Main Bar", - enabled: true, - position: 0, - screenPreferences: ["all"], - showOnLastDisplay: true, - leftWidgets: ["launcherButton", "workspaceSwitcher", "focusedWindow"], - centerWidgets: ["music", "clock", "weather"], - rightWidgets: ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"], - spacing: 4, - innerPadding: 4, - bottomGap: 0, - transparency: 1.0, - widgetTransparency: 1.0, - squareCorners: false, - noBackground: false, - gothCornersEnabled: false, - gothCornerRadiusOverride: false, - gothCornerRadiusValue: 12, - borderEnabled: false, - borderColor: "surfaceText", - borderOpacity: 1.0, - borderThickness: 1, - fontScale: 1.0, - autoHide: false, - autoHideDelay: 250, - openOnOverview: false, - visible: true, - popupGapsAuto: true, - popupGapsManual: 4 - }] + property var barConfigs: [ + { + id: "default", + name: "Main Bar", + enabled: true, + position: 0, + screenPreferences: ["all"], + showOnLastDisplay: true, + leftWidgets: ["launcherButton", "workspaceSwitcher", "focusedWindow"], + centerWidgets: ["music", "clock", "weather"], + rightWidgets: ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"], + spacing: 4, + innerPadding: 4, + bottomGap: 0, + transparency: 1.0, + widgetTransparency: 1.0, + squareCorners: false, + noBackground: false, + gothCornersEnabled: false, + gothCornerRadiusOverride: false, + gothCornerRadiusValue: 12, + borderEnabled: false, + borderColor: "surfaceText", + borderOpacity: 1.0, + borderThickness: 1, + fontScale: 1.0, + autoHide: false, + autoHideDelay: 250, + openOnOverview: false, + visible: true, + popupGapsAuto: true, + popupGapsManual: 4 + } + ] signal forceDankBarLayoutRefresh signal forceDockLayoutRefresh @@ -348,49 +355,49 @@ Singleton { Component.onCompleted: { if (!isGreeterMode) { - Processes.settingsRoot = root - loadSettings() - initializeListModels() - Processes.detectFprintd() - Processes.checkPluginSettings() + Processes.settingsRoot = root; + loadSettings(); + initializeListModels(); + Processes.detectFprintd(); + Processes.checkPluginSettings(); } } function applyStoredTheme() { if (typeof Theme !== "undefined") { - Theme.switchTheme(currentThemeName, false, false) + Theme.switchTheme(currentThemeName, false, false); } else { - Qt.callLater(function() { + Qt.callLater(function () { if (typeof Theme !== "undefined") { - Theme.switchTheme(currentThemeName, false, false) + Theme.switchTheme(currentThemeName, false, false); } - }) + }); } } function regenSystemThemes() { if (typeof Theme !== "undefined") { - Theme.generateSystemThemesFromCurrentTheme() + Theme.generateSystemThemesFromCurrentTheme(); } } function updateNiriLayout() { if (typeof NiriService !== "undefined" && typeof CompositorService !== "undefined" && CompositorService.isNiri) { - NiriService.generateNiriLayoutConfig() + NiriService.generateNiriLayoutConfig(); } } function applyStoredIconTheme() { - updateGtkIconTheme() - updateQtIconTheme() + updateGtkIconTheme(); + updateQtIconTheme(); } function updateGtkIconTheme() { - const gtkThemeName = (iconTheme === "System Default") ? systemDefaultIconTheme : iconTheme - if (gtkThemeName === "System Default" || gtkThemeName === "") return - + 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) + PortalService.setSystemIconTheme(gtkThemeName); } const configScript = `mkdir -p ${_configDir}/gtk-3.0 ${_configDir}/gtk-4.0 @@ -413,17 +420,17 @@ for config_dir in ${_configDir}/gtk-3.0 ${_configDir}/gtk-4.0; do done rm -rf ~/.cache/icon-cache ~/.cache/thumbnails 2>/dev/null || true -pkill -HUP -f 'gtk' 2>/dev/null || true` +pkill -HUP -f 'gtk' 2>/dev/null || true`; - Quickshell.execDetached(["sh", "-lc", configScript]) + 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 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() { @@ -445,310 +452,335 @@ update_qt_icon_theme() { } 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` +rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || true`; - Quickshell.execDetached(["sh", "-lc", script]) + Quickshell.execDetached(["sh", "-lc", script]); } readonly property var _hooks: ({ - applyStoredTheme: applyStoredTheme, - regenSystemThemes: regenSystemThemes, - updateNiriLayout: updateNiriLayout, - applyStoredIconTheme: applyStoredIconTheme, - updateBarConfigs: updateBarConfigs - }) + applyStoredTheme: applyStoredTheme, + regenSystemThemes: regenSystemThemes, + updateNiriLayout: updateNiriLayout, + applyStoredIconTheme: applyStoredIconTheme, + updateBarConfigs: updateBarConfigs + }) function set(key, value) { - Spec.set(root, key, value, saveSettings, _hooks) + Spec.set(root, key, value, saveSettings, _hooks); } function loadSettings() { - _loading = true + _loading = true; try { - const txt = settingsFile.text() - let obj = (txt && txt.trim()) ? JSON.parse(txt) : null + const txt = settingsFile.text(); + let obj = (txt && txt.trim()) ? JSON.parse(txt) : null; - const oldVersion = obj?.configVersion ?? 0 + const oldVersion = obj?.configVersion ?? 0; if (oldVersion < settingsConfigVersion) { - const migrated = Store.migrateToVersion(obj, settingsConfigVersion) + const migrated = Store.migrateToVersion(obj, settingsConfigVersion); if (migrated) { - settingsFile.setText(JSON.stringify(migrated, null, 2)) - obj = migrated + settingsFile.setText(JSON.stringify(migrated, null, 2)); + obj = migrated; } } - Store.parse(root, obj) - applyStoredTheme() - applyStoredIconTheme() - Processes.detectIcons() - Processes.detectQtTools() + Store.parse(root, obj); + applyStoredTheme(); + applyStoredIconTheme(); + Processes.detectIcons(); + Processes.detectQtTools(); } catch (e) { - console.warn("SettingsData: Failed to load settings:", e.message) - applyStoredTheme() - applyStoredIconTheme() + console.warn("SettingsData: Failed to load settings:", e.message); + applyStoredTheme(); + applyStoredIconTheme(); } finally { - _loading = false + _loading = false; } - loadPluginSettings() + loadPluginSettings(); } function loadPluginSettings() { - _pluginSettingsLoading = true - parsePluginSettings(pluginSettingsFile.text()) - _pluginSettingsLoading = false + _pluginSettingsLoading = true; + parsePluginSettings(pluginSettingsFile.text()); + _pluginSettingsLoading = false; } function parsePluginSettings(content) { - _pluginSettingsLoading = true + _pluginSettingsLoading = true; try { if (content && content.trim()) { - pluginSettings = JSON.parse(content) + pluginSettings = JSON.parse(content); } else { - pluginSettings = {} + pluginSettings = {}; } } catch (e) { - console.warn("SettingsData: Failed to parse plugin settings:", e.message) - pluginSettings = {} + console.warn("SettingsData: Failed to parse plugin settings:", e.message); + pluginSettings = {}; } finally { - _pluginSettingsLoading = false + _pluginSettingsLoading = false; } } function saveSettings() { - if (_loading) return - settingsFile.setText(JSON.stringify(Store.toJson(root), null, 2)) + if (_loading) + return; + settingsFile.setText(JSON.stringify(Store.toJson(root), null, 2)); } function savePluginSettings() { - if (_pluginSettingsLoading) return - pluginSettingsFile.setText(JSON.stringify(pluginSettings, null, 2)) + if (_pluginSettingsLoading) + return; + pluginSettingsFile.setText(JSON.stringify(pluginSettings, null, 2)); } function detectAvailableIconThemes() { - Processes.detectIcons() + Processes.detectIcons(); } function getEffectiveTimeFormat() { if (use24HourClock) { - return showSeconds ? "hh:mm:ss" : "hh:mm" + return showSeconds ? "hh:mm:ss" : "hh:mm"; } else { - return showSeconds ? "h:mm:ss AP" : "h:mm AP" + return showSeconds ? "h:mm:ss AP" : "h:mm AP"; } } function getEffectiveClockDateFormat() { - return clockDateFormat && clockDateFormat.length > 0 ? clockDateFormat : "ddd d" + return clockDateFormat && clockDateFormat.length > 0 ? clockDateFormat : "ddd d"; } function getEffectiveLockDateFormat() { - return lockDateFormat && lockDateFormat.length > 0 ? lockDateFormat : Locale.LongFormat + return lockDateFormat && lockDateFormat.length > 0 ? lockDateFormat : Locale.LongFormat; } function initializeListModels() { - const defaultBar = barConfigs[0] || getBarConfig("default") + const defaultBar = barConfigs[0] || getBarConfig("default"); if (defaultBar) { - Lists.init(leftWidgetsModel, centerWidgetsModel, rightWidgetsModel, defaultBar.leftWidgets, defaultBar.centerWidgets, defaultBar.rightWidgets) + Lists.init(leftWidgetsModel, centerWidgetsModel, rightWidgetsModel, defaultBar.leftWidgets, defaultBar.centerWidgets, defaultBar.rightWidgets); } } function updateListModel(listModel, order) { - Lists.update(listModel, order) - widgetDataChanged() + 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 + var ws = NiriService.allWorkspaces[i]; + if (ws.name && ws.name.trim() !== "") + return true; } - return false + return false; } function getNamedWorkspaces() { - var namedWorkspaces = [] - if (typeof NiriService === "undefined" || !CompositorService.isNiri) return namedWorkspaces + var namedWorkspaces = []; + if (typeof NiriService === "undefined" || !CompositorService.isNiri) + return namedWorkspaces; for (const ws of NiriService.allWorkspaces) { if (ws.name && ws.name.trim() !== "") { - namedWorkspaces.push(ws.name) + namedWorkspaces.push(ws.name); } } - return namedWorkspaces + return namedWorkspaces; } function getPopupYPosition(barHeight) { - const defaultBar = barConfigs[0] || getBarConfig("default") - const gothOffset = defaultBar?.gothCornersEnabled ? Theme.cornerRadius : 0 - const spacing = defaultBar?.spacing ?? 4 - const bottomGap = defaultBar?.bottomGap ?? 0 - return barHeight + spacing + bottomGap - gothOffset + Theme.popupDistance + const defaultBar = barConfigs[0] || getBarConfig("default"); + const gothOffset = defaultBar?.gothCornersEnabled ? Theme.cornerRadius : 0; + const spacing = defaultBar?.spacing ?? 4; + const bottomGap = defaultBar?.bottomGap ?? 0; + return barHeight + spacing + bottomGap - gothOffset + Theme.popupDistance; } function getPopupTriggerPosition(globalPos, screen, barThickness, widgetWidth, barSpacing, barPosition, barConfig) { - const screenX = screen ? screen.x : 0 - const screenY = screen ? screen.y : 0 - const relativeX = globalPos.x - screenX - const relativeY = globalPos.y - screenY - const defaultBar = barConfigs[0] || getBarConfig("default") - const spacing = barSpacing !== undefined ? barSpacing : (defaultBar?.spacing ?? 4) - const position = barPosition !== undefined ? barPosition : (defaultBar?.position ?? SettingsData.Position.Top) - const bottomGap = barConfig ? (barConfig.bottomGap !== undefined ? barConfig.bottomGap : (defaultBar?.bottomGap ?? 0)) : (defaultBar?.bottomGap ?? 0) + const screenX = screen ? screen.x : 0; + const screenY = screen ? screen.y : 0; + const relativeX = globalPos.x - screenX; + const relativeY = globalPos.y - screenY; + const defaultBar = barConfigs[0] || getBarConfig("default"); + const spacing = barSpacing !== undefined ? barSpacing : (defaultBar?.spacing ?? 4); + const position = barPosition !== undefined ? barPosition : (defaultBar?.position ?? SettingsData.Position.Top); + const bottomGap = barConfig ? (barConfig.bottomGap !== undefined ? barConfig.bottomGap : (defaultBar?.bottomGap ?? 0)) : (defaultBar?.bottomGap ?? 0); + + const useAutoGaps = (barConfig && barConfig.popupGapsAuto !== undefined) ? barConfig.popupGapsAuto : (defaultBar?.popupGapsAuto ?? true); + const manualGapValue = (barConfig && barConfig.popupGapsManual !== undefined) ? barConfig.popupGapsManual : (defaultBar?.popupGapsManual ?? 4); + const popupGap = useAutoGaps ? Math.max(4, spacing) : manualGapValue; - const useAutoGaps = (barConfig && barConfig.popupGapsAuto !== undefined) ? barConfig.popupGapsAuto : (defaultBar?.popupGapsAuto ?? true) - const manualGapValue = (barConfig && barConfig.popupGapsManual !== undefined) ? barConfig.popupGapsManual : (defaultBar?.popupGapsManual ?? 4) - const popupGap = useAutoGaps ? Math.max(4, spacing) : manualGapValue - switch (position) { case SettingsData.Position.Left: return { "x": barThickness + spacing + popupGap, "y": relativeY, "width": widgetWidth - } + }; case SettingsData.Position.Right: return { "x": (screen?.width || 0) - (barThickness + spacing + popupGap), "y": relativeY, "width": widgetWidth - } + }; case SettingsData.Position.Bottom: return { "x": relativeX, "y": (screen?.height || 0) - (barThickness + spacing + bottomGap + popupGap), "width": widgetWidth - } + }; default: return { "x": relativeX, "y": barThickness + spacing + bottomGap + popupGap, "width": widgetWidth - } + }; } } function getAdjacentBarInfo(screen, barPosition, barConfig) { if (!screen || !barConfig) { - return { "topBar": 0, "bottomBar": 0, "leftBar": 0, "rightBar": 0 } + return { + "topBar": 0, + "bottomBar": 0, + "leftBar": 0, + "rightBar": 0 + }; } if (barConfig.autoHide) { - return { "topBar": 0, "bottomBar": 0, "leftBar": 0, "rightBar": 0 } + return { + "topBar": 0, + "bottomBar": 0, + "leftBar": 0, + "rightBar": 0 + }; } - const enabledBars = getEnabledBarConfigs() - const defaultBar = barConfigs[0] || getBarConfig("default") - const position = barPosition !== undefined ? barPosition : (defaultBar?.position ?? SettingsData.Position.Top) - let topBar = 0 - let bottomBar = 0 - let leftBar = 0 - let rightBar = 0 + const enabledBars = getEnabledBarConfigs(); + const defaultBar = barConfigs[0] || getBarConfig("default"); + const position = barPosition !== undefined ? barPosition : (defaultBar?.position ?? SettingsData.Position.Top); + let topBar = 0; + let bottomBar = 0; + let leftBar = 0; + let rightBar = 0; for (let i = 0; i < enabledBars.length; i++) { - const other = enabledBars[i] - if (other.id === barConfig.id) continue - if (other.autoHide) continue + const other = enabledBars[i]; + if (other.id === barConfig.id) + continue; + if (other.autoHide) + continue; + const otherScreens = other.screenPreferences || ["all"]; + const barScreens = barConfig.screenPreferences || ["all"]; + const onSameScreen = otherScreens.includes("all") || barScreens.includes("all") || otherScreens.some(s => isScreenInPreferences(screen, [s])); - const otherScreens = other.screenPreferences || ["all"] - const barScreens = barConfig.screenPreferences || ["all"] - const onSameScreen = otherScreens.includes("all") || barScreens.includes("all") || - otherScreens.some(s => isScreenInPreferences(screen, [s])) + if (!onSameScreen) + continue; + const otherSpacing = other.spacing !== undefined ? other.spacing : (defaultBar?.spacing ?? 4); + const otherPadding = other.innerPadding !== undefined ? other.innerPadding : (defaultBar?.innerPadding ?? 4); + const otherThickness = Math.max(26 + otherPadding * 0.6, Theme.barHeight - 4 - (8 - otherPadding)) + otherSpacing; - if (!onSameScreen) continue - - const otherSpacing = other.spacing !== undefined ? other.spacing : (defaultBar?.spacing ?? 4) - const otherPadding = other.innerPadding !== undefined ? other.innerPadding : (defaultBar?.innerPadding ?? 4) - const otherThickness = Math.max(26 + otherPadding * 0.6, Theme.barHeight - 4 - (8 - otherPadding)) + otherSpacing - - const useAutoGaps = other.popupGapsAuto !== undefined ? other.popupGapsAuto : (defaultBar?.popupGapsAuto ?? true) - const manualGap = other.popupGapsManual !== undefined ? other.popupGapsManual : (defaultBar?.popupGapsManual ?? 4) - const popupGap = useAutoGaps ? Math.max(4, otherSpacing) : manualGap + const useAutoGaps = other.popupGapsAuto !== undefined ? other.popupGapsAuto : (defaultBar?.popupGapsAuto ?? true); + const manualGap = other.popupGapsManual !== undefined ? other.popupGapsManual : (defaultBar?.popupGapsManual ?? 4); + const popupGap = useAutoGaps ? Math.max(4, otherSpacing) : manualGap; switch (other.position) { case SettingsData.Position.Top: - topBar = Math.max(topBar, otherThickness + popupGap) - break + topBar = Math.max(topBar, otherThickness + popupGap); + break; case SettingsData.Position.Bottom: - bottomBar = Math.max(bottomBar, otherThickness + popupGap) - break + bottomBar = Math.max(bottomBar, otherThickness + popupGap); + break; case SettingsData.Position.Left: - leftBar = Math.max(leftBar, otherThickness + popupGap) - break + leftBar = Math.max(leftBar, otherThickness + popupGap); + break; case SettingsData.Position.Right: - rightBar = Math.max(rightBar, otherThickness + popupGap) - break + rightBar = Math.max(rightBar, otherThickness + popupGap); + break; } } - return { "topBar": topBar, "bottomBar": bottomBar, "leftBar": leftBar, "rightBar": rightBar } + return { + "topBar": topBar, + "bottomBar": bottomBar, + "leftBar": leftBar, + "rightBar": rightBar + }; } function getBarBounds(screen, barThickness, barPosition, barConfig) { if (!screen) { - return { "x": 0, "y": 0, "width": 0, "height": 0, "wingSize": 0 } + return { + "x": 0, + "y": 0, + "width": 0, + "height": 0, + "wingSize": 0 + }; } - const defaultBar = barConfigs[0] || getBarConfig("default") - const wingRadius = (defaultBar?.gothCornerRadiusOverride ?? false) ? (defaultBar?.gothCornerRadiusValue ?? 12) : Theme.cornerRadius - const wingSize = (defaultBar?.gothCornersEnabled ?? false) ? Math.max(0, wingRadius) : 0 - const screenWidth = screen.width - const screenHeight = screen.height - const position = barPosition !== undefined ? barPosition : (defaultBar?.position ?? SettingsData.Position.Top) - const bottomGap = barConfig ? (barConfig.bottomGap !== undefined ? barConfig.bottomGap : (defaultBar?.bottomGap ?? 0)) : (defaultBar?.bottomGap ?? 0) + const defaultBar = barConfigs[0] || getBarConfig("default"); + const wingRadius = (defaultBar?.gothCornerRadiusOverride ?? false) ? (defaultBar?.gothCornerRadiusValue ?? 12) : Theme.cornerRadius; + const wingSize = (defaultBar?.gothCornersEnabled ?? false) ? Math.max(0, wingRadius) : 0; + const screenWidth = screen.width; + const screenHeight = screen.height; + const position = barPosition !== undefined ? barPosition : (defaultBar?.position ?? SettingsData.Position.Top); + const bottomGap = barConfig ? (barConfig.bottomGap !== undefined ? barConfig.bottomGap : (defaultBar?.bottomGap ?? 0)) : (defaultBar?.bottomGap ?? 0); - let topOffset = 0 - let bottomOffset = 0 - let leftOffset = 0 - let rightOffset = 0 + let topOffset = 0; + let bottomOffset = 0; + let leftOffset = 0; + let rightOffset = 0; if (barConfig) { - const enabledBars = getEnabledBarConfigs() + const enabledBars = getEnabledBarConfigs(); for (let i = 0; i < enabledBars.length; i++) { - const other = enabledBars[i] - if (other.id === barConfig.id) continue + const other = enabledBars[i]; + if (other.id === barConfig.id) + continue; + const otherScreens = other.screenPreferences || ["all"]; + const barScreens = barConfig.screenPreferences || ["all"]; + const onSameScreen = otherScreens.includes("all") || barScreens.includes("all") || otherScreens.some(s => isScreenInPreferences(screen, [s])); - const otherScreens = other.screenPreferences || ["all"] - const barScreens = barConfig.screenPreferences || ["all"] - const onSameScreen = otherScreens.includes("all") || barScreens.includes("all") || - otherScreens.some(s => isScreenInPreferences(screen, [s])) - - if (!onSameScreen) continue - - const otherSpacing = other.spacing !== undefined ? other.spacing : (defaultBar?.spacing ?? 4) - const otherPadding = other.innerPadding !== undefined ? other.innerPadding : (defaultBar?.innerPadding ?? 4) - const otherThickness = Math.max(26 + otherPadding * 0.6, Theme.barHeight - 4 - (8 - otherPadding)) + otherSpacing + wingSize - const otherBottomGap = other.bottomGap !== undefined ? other.bottomGap : (defaultBar?.bottomGap ?? 0) + if (!onSameScreen) + continue; + const otherSpacing = other.spacing !== undefined ? other.spacing : (defaultBar?.spacing ?? 4); + const otherPadding = other.innerPadding !== undefined ? other.innerPadding : (defaultBar?.innerPadding ?? 4); + const otherThickness = Math.max(26 + otherPadding * 0.6, Theme.barHeight - 4 - (8 - otherPadding)) + otherSpacing + wingSize; + const otherBottomGap = other.bottomGap !== undefined ? other.bottomGap : (defaultBar?.bottomGap ?? 0); switch (other.position) { case SettingsData.Position.Top: if (position === SettingsData.Position.Top && other.id < barConfig.id) { - topOffset += otherThickness // Simple stacking for same pos + topOffset += otherThickness; // Simple stacking for same pos } else if (position === SettingsData.Position.Left || position === SettingsData.Position.Right) { - topOffset = Math.max(topOffset, otherThickness) + topOffset = Math.max(topOffset, otherThickness); } - break + break; case SettingsData.Position.Bottom: if (position === SettingsData.Position.Bottom && other.id < barConfig.id) { - bottomOffset += (otherThickness + otherBottomGap) + bottomOffset += (otherThickness + otherBottomGap); } else if (position === SettingsData.Position.Left || position === SettingsData.Position.Right) { - bottomOffset = Math.max(bottomOffset, otherThickness + otherBottomGap) + bottomOffset = Math.max(bottomOffset, otherThickness + otherBottomGap); } - break + break; case SettingsData.Position.Left: if (position === SettingsData.Position.Top || position === SettingsData.Position.Bottom) { - leftOffset = Math.max(leftOffset, otherThickness) + leftOffset = Math.max(leftOffset, otherThickness); } else if (position === SettingsData.Position.Left && other.id < barConfig.id) { - leftOffset += otherThickness + leftOffset += otherThickness; } - break + break; case SettingsData.Position.Right: if (position === SettingsData.Position.Top || position === SettingsData.Position.Bottom) { - rightOffset = Math.max(rightOffset, otherThickness) + rightOffset = Math.max(rightOffset, otherThickness); } else if (position === SettingsData.Position.Right && other.id < barConfig.id) { - rightOffset += otherThickness + rightOffset += otherThickness; } - break + break; } } } @@ -761,7 +793,7 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr "width": screenWidth - leftOffset - rightOffset, "height": barThickness + wingSize, "wingSize": wingSize - } + }; case SettingsData.Position.Bottom: return { "x": leftOffset, @@ -769,7 +801,7 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr "width": screenWidth - leftOffset - rightOffset, "height": barThickness + wingSize, "wingSize": wingSize - } + }; case SettingsData.Position.Left: return { "x": 0, @@ -777,7 +809,7 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr "width": barThickness + wingSize, "height": screenHeight - topOffset - bottomOffset, "wingSize": wingSize - } + }; case SettingsData.Position.Right: return { "x": screenWidth - barThickness - wingSize, @@ -785,406 +817,428 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr "width": barThickness + wingSize, "height": screenHeight - topOffset - bottomOffset, "wingSize": wingSize - } + }; } - - return { "x": 0, "y": 0, "width": 0, "height": 0, "wingSize": 0 } + + return { + "x": 0, + "y": 0, + "width": 0, + "height": 0, + "wingSize": 0 + }; } function updateBarConfigs() { - barConfigsChanged() - saveSettings() + barConfigsChanged(); + saveSettings(); } function getBarConfig(barId) { - return barConfigs.find(cfg => cfg.id === barId) || null + return barConfigs.find(cfg => cfg.id === barId) || null; } function addBarConfig(config) { - const configs = JSON.parse(JSON.stringify(barConfigs)) - configs.push(config) - barConfigs = configs - updateBarConfigs() + const configs = JSON.parse(JSON.stringify(barConfigs)); + configs.push(config); + barConfigs = configs; + updateBarConfigs(); } function updateBarConfig(barId, updates) { - const configs = JSON.parse(JSON.stringify(barConfigs)) - const index = configs.findIndex(cfg => cfg.id === barId) - if (index === -1) return + const configs = JSON.parse(JSON.stringify(barConfigs)); + const index = configs.findIndex(cfg => cfg.id === barId); + if (index === -1) + return; + const positionChanged = updates.position !== undefined && configs[index].position !== updates.position; - const positionChanged = updates.position !== undefined && configs[index].position !== updates.position - - Object.assign(configs[index], updates) - barConfigs = configs - updateBarConfigs() + Object.assign(configs[index], updates); + barConfigs = configs; + updateBarConfigs(); if (positionChanged) { - NotificationService.clearAllPopups() + NotificationService.clearAllPopups(); } } function checkBarCollisions(barId) { - const bar = getBarConfig(barId) - if (!bar || !bar.enabled) return [] + const bar = getBarConfig(barId); + if (!bar || !bar.enabled) + return []; - const conflicts = [] - const enabledBars = getEnabledBarConfigs() + const conflicts = []; + const enabledBars = getEnabledBarConfigs(); for (let i = 0; i < enabledBars.length; i++) { - const other = enabledBars[i] - if (other.id === barId) continue + const other = enabledBars[i]; + if (other.id === barId) + continue; + const samePosition = bar.position === other.position; + if (!samePosition) + continue; + const barScreens = bar.screenPreferences || ["all"]; + const otherScreens = other.screenPreferences || ["all"]; - const samePosition = bar.position === other.position - if (!samePosition) continue - - const barScreens = bar.screenPreferences || ["all"] - const otherScreens = other.screenPreferences || ["all"] - - const hasAll = barScreens.includes("all") || otherScreens.includes("all") + const hasAll = barScreens.includes("all") || otherScreens.includes("all"); if (hasAll) { conflicts.push({ barId: other.id, barName: other.name, reason: "Same position on all screens" - }) - continue + }); + continue; } - const overlapping = barScreens.some(screen => otherScreens.includes(screen)) + const overlapping = barScreens.some(screen => otherScreens.includes(screen)); if (overlapping) { conflicts.push({ barId: other.id, barName: other.name, reason: "Same position on overlapping screens" - }) + }); } } - return conflicts + return conflicts; } function deleteBarConfig(barId) { - if (barId === "default") return - - const configs = barConfigs.filter(cfg => cfg.id !== barId) - barConfigs = configs - updateBarConfigs() + if (barId === "default") + return; + const configs = barConfigs.filter(cfg => cfg.id !== barId); + barConfigs = configs; + updateBarConfigs(); } function getEnabledBarConfigs() { - return barConfigs.filter(cfg => cfg.enabled) + return barConfigs.filter(cfg => cfg.enabled); } function getScreenDisplayName(screen) { - if (!screen) return "" + if (!screen) + return ""; if (displayNameMode === "model" && screen.model) { - return screen.model + return screen.model; } - return screen.name + return screen.name; } function isScreenInPreferences(screen, prefs) { - if (!screen) return false + if (!screen) + return false; return prefs.some(pref => { if (typeof pref === "string") { - return pref === "all" || pref === screen.name || pref === screen.model + return pref === "all" || pref === screen.name || pref === screen.model; } if (displayNameMode === "model") { - return pref.model && screen.model && pref.model === screen.model + return pref.model && screen.model && pref.model === screen.model; } - return pref.name === screen.name - }) + return pref.name === screen.name; + }); } function getFilteredScreens(componentId) { - var prefs = screenPreferences && screenPreferences[componentId] || ["all"] + var prefs = screenPreferences && screenPreferences[componentId] || ["all"]; if (prefs.includes("all") || (typeof prefs[0] === "string" && prefs[0] === "all")) { - return Quickshell.screens + return Quickshell.screens; } - var filtered = Quickshell.screens.filter(screen => isScreenInPreferences(screen, prefs)) + var filtered = Quickshell.screens.filter(screen => isScreenInPreferences(screen, prefs)); if (filtered.length === 0 && showOnLastDisplay && showOnLastDisplay[componentId] && Quickshell.screens.length === 1) { - return Quickshell.screens + return Quickshell.screens; } - return filtered + return filtered; } function sendTestNotifications() { - NotificationService.clearAllPopups() - sendTestNotification(0) - testNotifTimer1.start() - testNotifTimer2.start() + NotificationService.clearAllPopups(); + sendTestNotification(0); + testNotifTimer1.start(); + testNotifTimer2.start(); } function sendTestNotification(index) { - const notifications = [["Notification Position Test", "DMS test notification 1 of 3 ~ Hi there!", "preferences-system"], ["Second Test", "DMS Notification 2 of 3 ~ Check it out!", "applications-graphics"], ["Third Test", "DMS notification 3 of 3 ~ Enjoy!", "face-smile"]] + const notifications = [["Notification Position Test", "DMS test notification 1 of 3 ~ Hi there!", "preferences-system"], ["Second Test", "DMS Notification 2 of 3 ~ Check it out!", "applications-graphics"], ["Third Test", "DMS notification 3 of 3 ~ Enjoy!", "face-smile"]]; if (index < 0 || index >= notifications.length) { - return + return; } - const notif = notifications[index] - testNotificationProcess.command = ["notify-send", "-h", "int:transient:1", "-a", "DMS", "-i", notif[2], notif[0], notif[1]] - testNotificationProcess.running = true + const notif = notifications[index]; + testNotificationProcess.command = ["notify-send", "-h", "int:transient:1", "-a", "DMS", "-i", notif[2], notif[0], notif[1]]; + testNotificationProcess.running = true; } - function setMatugenScheme(scheme) { - var normalized = scheme || "scheme-tonal-spot" - if (matugenScheme === normalized) return - set("matugenScheme", normalized) + var normalized = scheme || "scheme-tonal-spot"; + if (matugenScheme === normalized) + return; + set("matugenScheme", normalized); if (typeof Theme !== "undefined") { - Theme.generateSystemThemesFromCurrentTheme() + Theme.generateSystemThemesFromCurrentTheme(); } } function setRunUserMatugenTemplates(enabled) { - if (runUserMatugenTemplates === enabled) return - set("runUserMatugenTemplates", enabled) + if (runUserMatugenTemplates === enabled) + return; + set("runUserMatugenTemplates", enabled); if (typeof Theme !== "undefined") { - Theme.generateSystemThemesFromCurrentTheme() + Theme.generateSystemThemesFromCurrentTheme(); } } function setMatugenTargetMonitor(monitorName) { - if (matugenTargetMonitor === monitorName) return - set("matugenTargetMonitor", monitorName) + if (matugenTargetMonitor === monitorName) + return; + set("matugenTargetMonitor", monitorName); if (typeof Theme !== "undefined") { - Theme.generateSystemThemesFromCurrentTheme() + Theme.generateSystemThemesFromCurrentTheme(); } } - function setCornerRadius(radius) { - set("cornerRadius", radius) - NiriService.generateNiriLayoutConfig() + set("cornerRadius", radius); + NiriService.generateNiriLayoutConfig(); } function setWeatherLocation(displayName, coordinates) { - weatherLocation = displayName - weatherCoordinates = coordinates - saveSettings() + weatherLocation = displayName; + weatherCoordinates = coordinates; + saveSettings(); } function setIconTheme(themeName) { - iconTheme = themeName - updateGtkIconTheme() - updateQtIconTheme() - saveSettings() - if (typeof Theme !== "undefined" && Theme.currentTheme === Theme.dynamic) Theme.generateSystemThemesFromCurrentTheme() + iconTheme = themeName; + updateGtkIconTheme(); + updateQtIconTheme(); + saveSettings(); + if (typeof Theme !== "undefined" && Theme.currentTheme === Theme.dynamic) + Theme.generateSystemThemesFromCurrentTheme(); } function setGtkThemingEnabled(enabled) { - set("gtkThemingEnabled", enabled) + set("gtkThemingEnabled", enabled); if (enabled && typeof Theme !== "undefined") { - Theme.generateSystemThemesFromCurrentTheme() + Theme.generateSystemThemesFromCurrentTheme(); } } function setQtThemingEnabled(enabled) { - set("qtThemingEnabled", enabled) + set("qtThemingEnabled", enabled); if (enabled && typeof Theme !== "undefined") { - Theme.generateSystemThemesFromCurrentTheme() + Theme.generateSystemThemesFromCurrentTheme(); } } function setShowDock(enabled) { - showDock = enabled - const defaultBar = barConfigs[0] || getBarConfig("default") - const barPos = defaultBar?.position ?? SettingsData.Position.Top + showDock = enabled; + const defaultBar = barConfigs[0] || getBarConfig("default"); + const barPos = defaultBar?.position ?? SettingsData.Position.Top; if (enabled && dockPosition === barPos) { if (barPos === SettingsData.Position.Top) { - setDockPosition(SettingsData.Position.Bottom) - return + setDockPosition(SettingsData.Position.Bottom); + return; } if (barPos === SettingsData.Position.Bottom) { - setDockPosition(SettingsData.Position.Top) - return + setDockPosition(SettingsData.Position.Top); + return; } if (barPos === SettingsData.Position.Left) { - setDockPosition(SettingsData.Position.Right) - return + setDockPosition(SettingsData.Position.Right); + return; } if (barPos === SettingsData.Position.Right) { - setDockPosition(SettingsData.Position.Left) - return + setDockPosition(SettingsData.Position.Left); + return; } } - saveSettings() + saveSettings(); } function setDockPosition(position) { - dockPosition = position - const defaultBar = barConfigs[0] || getBarConfig("default") - const barPos = defaultBar?.position ?? SettingsData.Position.Top + dockPosition = position; + const defaultBar = barConfigs[0] || getBarConfig("default"); + const barPos = defaultBar?.position ?? SettingsData.Position.Top; if (position === SettingsData.Position.Bottom && barPos === SettingsData.Position.Bottom && showDock) { - setDankBarPosition(SettingsData.Position.Top) + setDankBarPosition(SettingsData.Position.Top); } if (position === SettingsData.Position.Top && barPos === SettingsData.Position.Top && showDock) { - setDankBarPosition(SettingsData.Position.Bottom) + setDankBarPosition(SettingsData.Position.Bottom); } if (position === SettingsData.Position.Left && barPos === SettingsData.Position.Left && showDock) { - setDankBarPosition(SettingsData.Position.Right) + setDankBarPosition(SettingsData.Position.Right); } if (position === SettingsData.Position.Right && barPos === SettingsData.Position.Right && showDock) { - setDankBarPosition(SettingsData.Position.Left) + setDankBarPosition(SettingsData.Position.Left); } - saveSettings() - Qt.callLater(() => forceDockLayoutRefresh()) + saveSettings(); + Qt.callLater(() => forceDockLayoutRefresh()); } function setDankBarSpacing(spacing) { - const defaultBar = barConfigs[0] || getBarConfig("default") + const defaultBar = barConfigs[0] || getBarConfig("default"); if (defaultBar) { - updateBarConfig(defaultBar.id, { spacing: spacing }) + updateBarConfig(defaultBar.id, { + spacing: spacing + }); } if (typeof NiriService !== "undefined" && CompositorService.isNiri) { - NiriService.generateNiriLayoutConfig() + NiriService.generateNiriLayoutConfig(); } } function setDankBarPosition(position) { - const defaultBar = barConfigs[0] || getBarConfig("default") - if (!defaultBar) return - + const defaultBar = barConfigs[0] || getBarConfig("default"); + if (!defaultBar) + return; if (position === SettingsData.Position.Bottom && dockPosition === SettingsData.Position.Bottom && showDock) { - setDockPosition(SettingsData.Position.Top) - return + setDockPosition(SettingsData.Position.Top); + return; } if (position === SettingsData.Position.Top && dockPosition === SettingsData.Position.Top && showDock) { - setDockPosition(SettingsData.Position.Bottom) - return + setDockPosition(SettingsData.Position.Bottom); + return; } if (position === SettingsData.Position.Left && dockPosition === SettingsData.Position.Left && showDock) { - setDockPosition(SettingsData.Position.Right) - return + setDockPosition(SettingsData.Position.Right); + return; } if (position === SettingsData.Position.Right && dockPosition === SettingsData.Position.Right && showDock) { - setDockPosition(SettingsData.Position.Left) - return + setDockPosition(SettingsData.Position.Left); + return; } - updateBarConfig(defaultBar.id, { position: position }) + updateBarConfig(defaultBar.id, { + position: position + }); } function setDankBarLeftWidgets(order) { - const defaultBar = barConfigs[0] || getBarConfig("default") + const defaultBar = barConfigs[0] || getBarConfig("default"); if (defaultBar) { - updateBarConfig(defaultBar.id, { leftWidgets: order }) - updateListModel(leftWidgetsModel, order) + updateBarConfig(defaultBar.id, { + leftWidgets: order + }); + updateListModel(leftWidgetsModel, order); } } function setDankBarCenterWidgets(order) { - const defaultBar = barConfigs[0] || getBarConfig("default") + const defaultBar = barConfigs[0] || getBarConfig("default"); if (defaultBar) { - updateBarConfig(defaultBar.id, { centerWidgets: order }) - updateListModel(centerWidgetsModel, order) + updateBarConfig(defaultBar.id, { + centerWidgets: order + }); + updateListModel(centerWidgetsModel, order); } } function setDankBarRightWidgets(order) { - const defaultBar = barConfigs[0] || getBarConfig("default") + const defaultBar = barConfigs[0] || getBarConfig("default"); if (defaultBar) { - updateBarConfig(defaultBar.id, { rightWidgets: order }) - updateListModel(rightWidgetsModel, order) + updateBarConfig(defaultBar.id, { + rightWidgets: order + }); + updateListModel(rightWidgetsModel, order); } } function resetDankBarWidgetsToDefault() { - var defaultLeft = ["launcherButton", "workspaceSwitcher", "focusedWindow"] - var defaultCenter = ["music", "clock", "weather"] - var defaultRight = ["systemTray", "clipboard", "notificationButton", "battery", "controlCenterButton"] - const defaultBar = barConfigs[0] || getBarConfig("default") + var defaultLeft = ["launcherButton", "workspaceSwitcher", "focusedWindow"]; + var defaultCenter = ["music", "clock", "weather"]; + var defaultRight = ["systemTray", "clipboard", "notificationButton", "battery", "controlCenterButton"]; + const defaultBar = barConfigs[0] || getBarConfig("default"); if (defaultBar) { updateBarConfig(defaultBar.id, { leftWidgets: defaultLeft, centerWidgets: defaultCenter, rightWidgets: defaultRight - }) + }); } - updateListModel(leftWidgetsModel, defaultLeft) - updateListModel(centerWidgetsModel, defaultCenter) - updateListModel(rightWidgetsModel, defaultRight) - showLauncherButton = true - showWorkspaceSwitcher = true - showFocusedWindow = true - showWeather = true - showMusic = true - showClipboard = true - showCpuUsage = true - showMemUsage = true - showCpuTemp = true - showGpuTemp = true - showSystemTray = true - showClock = true - showNotificationButton = true - showBattery = true - showControlCenterButton = true - showCapsLockIndicator = true + updateListModel(leftWidgetsModel, defaultLeft); + updateListModel(centerWidgetsModel, defaultCenter); + updateListModel(rightWidgetsModel, defaultRight); + showLauncherButton = true; + showWorkspaceSwitcher = true; + showFocusedWindow = true; + showWeather = true; + showMusic = true; + showClipboard = true; + showCpuUsage = true; + showMemUsage = true; + showCpuTemp = true; + showGpuTemp = true; + showSystemTray = true; + showClock = true; + showNotificationButton = true; + showBattery = true; + showControlCenterButton = true; + showCapsLockIndicator = true; } function setWorkspaceNameIcon(workspaceName, iconData) { - var iconMap = JSON.parse(JSON.stringify(workspaceNameIcons)) - iconMap[workspaceName] = iconData - workspaceNameIcons = iconMap - saveSettings() - workspaceIconsUpdated() + 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() + var iconMap = JSON.parse(JSON.stringify(workspaceNameIcons)); + delete iconMap[workspaceName]; + workspaceNameIcons = iconMap; + saveSettings(); + workspaceIconsUpdated(); } function getWorkspaceNameIcon(workspaceName) { - return workspaceNameIcons[workspaceName] || null + return workspaceNameIcons[workspaceName] || null; } function toggleDankBarVisible() { - const defaultBar = barConfigs[0] || getBarConfig("default") + const defaultBar = barConfigs[0] || getBarConfig("default"); if (defaultBar) { - updateBarConfig(defaultBar.id, { visible: !defaultBar.visible }) + updateBarConfig(defaultBar.id, { + visible: !defaultBar.visible + }); } } function toggleShowDock() { - setShowDock(!showDock) + setShowDock(!showDock); } function getPluginSetting(pluginId, key, defaultValue) { if (!pluginSettings[pluginId]) { - return defaultValue + return defaultValue; } - return pluginSettings[pluginId][key] !== undefined ? pluginSettings[pluginId][key] : defaultValue + return pluginSettings[pluginId][key] !== undefined ? pluginSettings[pluginId][key] : defaultValue; } function setPluginSetting(pluginId, key, value) { - const updated = JSON.parse(JSON.stringify(pluginSettings)) + const updated = JSON.parse(JSON.stringify(pluginSettings)); if (!updated[pluginId]) { - updated[pluginId] = {} + updated[pluginId] = {}; } - updated[pluginId][key] = value - pluginSettings = updated - savePluginSettings() + updated[pluginId][key] = value; + pluginSettings = updated; + savePluginSettings(); } function removePluginSettings(pluginId) { if (pluginSettings[pluginId]) { - delete pluginSettings[pluginId] - savePluginSettings() + delete pluginSettings[pluginId]; + savePluginSettings(); } } function getPluginSettingsForPlugin(pluginId) { - const settings = pluginSettings[pluginId] - return settings ? JSON.parse(JSON.stringify(settings)) : {} + const settings = pluginSettings[pluginId]; + return settings ? JSON.parse(JSON.stringify(settings)) : {}; } - ListModel { id: leftWidgetsModel } @@ -1233,21 +1287,21 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr onLoaded: { if (!isGreeterMode) { try { - const txt = settingsFile.text() - const obj = (txt && txt.trim()) ? JSON.parse(txt) : null - Store.parse(root, obj) + const txt = settingsFile.text(); + const obj = (txt && txt.trim()) ? JSON.parse(txt) : null; + Store.parse(root, obj); } catch (e) { - console.warn("SettingsData: Failed to reload settings:", e.message) + console.warn("SettingsData: Failed to reload settings:", e.message); } - hasTriedDefaultSettings = false + hasTriedDefaultSettings = false; } } onLoadFailed: error => { if (!isGreeterMode && !hasTriedDefaultSettings) { - hasTriedDefaultSettings = true - Processes.checkDefaultSettings() + hasTriedDefaultSettings = true; + Processes.checkDefaultSettings(); } else if (!isGreeterMode) { - applyStoredTheme() + applyStoredTheme(); } } } @@ -1262,12 +1316,12 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr watchChanges: !isGreeterMode onLoaded: { if (!isGreeterMode) { - parsePluginSettings(pluginSettingsFile.text()) + parsePluginSettings(pluginSettingsFile.text()); } } onLoadFailed: error => { if (!isGreeterMode) { - pluginSettings = {} + pluginSettings = {}; } } } @@ -1276,22 +1330,22 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr IpcHandler { function reveal(): string { - root.setShowDock(true) - return "DOCK_SHOW_SUCCESS" + root.setShowDock(true); + return "DOCK_SHOW_SUCCESS"; } function hide(): string { - root.setShowDock(false) - return "DOCK_HIDE_SUCCESS" + root.setShowDock(false); + return "DOCK_HIDE_SUCCESS"; } function toggle(): string { - root.toggleShowDock() - return root.showDock ? "DOCK_SHOW_SUCCESS" : "DOCK_HIDE_SUCCESS" + root.toggleShowDock(); + return root.showDock ? "DOCK_SHOW_SUCCESS" : "DOCK_HIDE_SUCCESS"; } function status(): string { - return root.showDock ? "visible" : "hidden" + return root.showDock ? "visible" : "hidden"; } target: "dock" diff --git a/quickshell/Common/Theme.qml b/quickshell/Common/Theme.qml index c5eb2f49..35cc7192 100644 --- a/quickshell/Common/Theme.qml +++ b/quickshell/Common/Theme.qml @@ -1,5 +1,4 @@ pragma Singleton - pragma ComponentBehavior: Bound import QtCore @@ -15,20 +14,21 @@ import "StockThemes.js" as StockThemes Singleton { id: root - readonly property string stateDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.GenericCacheLocation).toString()) + "/DankMaterialShell" - readonly property bool envDisableMatugen: Quickshell.env("DMS_DISABLE_MATUGEN") === "1" || Quickshell.env("DMS_DISABLE_MATUGEN") === "true" + readonly property string defaultFontFamily: "Inter Variable" + readonly property string defaultMonoFontFamily: "Fira Code" readonly property real popupDistance: { if (typeof SettingsData === "undefined") - return 4 - const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default") - if (!defaultBar) return 4 - const useAuto = defaultBar.popupGapsAuto ?? true - const manualValue = defaultBar.popupGapsManual ?? 4 - const spacing = defaultBar.spacing ?? 4 - return useAuto ? Math.max(4, spacing) : manualValue + return 4; + const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default"); + if (!defaultBar) + return 4; + const useAuto = defaultBar.popupGapsAuto ?? true; + const manualValue = defaultBar.popupGapsManual ?? 4; + const spacing = defaultBar.spacing ?? 4; + return useAuto ? Math.max(4, spacing) : manualValue; } property string currentTheme: "blue" @@ -44,45 +44,45 @@ Singleton { readonly property string shellDir: Paths.strip(Qt.resolvedUrl(".").toString()).replace("/Common/", "") readonly property string wallpaperPath: { if (typeof SessionData === "undefined") - return "" + return ""; if (SessionData.perMonitorWallpaper) { - var screens = Quickshell.screens + var screens = Quickshell.screens; if (screens.length > 0) { - var firstMonitorWallpaper = SessionData.getMonitorWallpaper(screens[0].name) - return firstMonitorWallpaper || SessionData.wallpaperPath + var firstMonitorWallpaper = SessionData.getMonitorWallpaper(screens[0].name); + return firstMonitorWallpaper || SessionData.wallpaperPath; } } - return SessionData.wallpaperPath + return SessionData.wallpaperPath; } readonly property string rawWallpaperPath: { if (typeof SessionData === "undefined") - return "" + return ""; if (SessionData.perMonitorWallpaper) { - var screens = Quickshell.screens + var screens = Quickshell.screens; if (screens.length > 0) { - var targetMonitor = (typeof SettingsData !== "undefined" && SettingsData.matugenTargetMonitor && SettingsData.matugenTargetMonitor !== "") ? SettingsData.matugenTargetMonitor : screens[0].name + var targetMonitor = (typeof SettingsData !== "undefined" && SettingsData.matugenTargetMonitor && SettingsData.matugenTargetMonitor !== "") ? SettingsData.matugenTargetMonitor : screens[0].name; - var targetMonitorExists = false + var targetMonitorExists = false; for (var i = 0; i < screens.length; i++) { if (screens[i].name === targetMonitor) { - targetMonitorExists = true - break + targetMonitorExists = true; + break; } } if (!targetMonitorExists) { - targetMonitor = screens[0].name + targetMonitor = screens[0].name; } - var targetMonitorWallpaper = SessionData.getMonitorWallpaper(targetMonitor) - return targetMonitorWallpaper || SessionData.wallpaperPath + var targetMonitorWallpaper = SessionData.getMonitorWallpaper(targetMonitor); + return targetMonitorWallpaper || SessionData.wallpaperPath; } } - return SessionData.wallpaperPath + return SessionData.wallpaperPath; } property bool matugenAvailable: false @@ -93,88 +93,88 @@ Singleton { property var customThemeData: null Component.onCompleted: { - Quickshell.execDetached(["mkdir", "-p", stateDir]) + Quickshell.execDetached(["mkdir", "-p", stateDir]); Proc.runCommand("matugenCheck", ["which", "matugen"], (output, code) => { - matugenAvailable = (code === 0) && !envDisableMatugen - const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode) + matugenAvailable = (code === 0) && !envDisableMatugen; + const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode); - if (!matugenAvailable || isGreeterMode) { - return - } + if (!matugenAvailable || isGreeterMode) { + return; + } - if (colorsFileLoadFailed && currentTheme === dynamic && rawWallpaperPath) { - console.info("Theme: Matugen now available, regenerating colors for dynamic theme") - const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) - const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default" - const selectedMatugenType = (typeof SettingsData !== "undefined" && SettingsData.matugenScheme) ? SettingsData.matugenScheme : "scheme-tonal-spot" - if (rawWallpaperPath.startsWith("#")) { - setDesiredTheme("hex", rawWallpaperPath, isLight, iconTheme, selectedMatugenType) - } else { - setDesiredTheme("image", rawWallpaperPath, isLight, iconTheme, selectedMatugenType) - } - return - } + if (colorsFileLoadFailed && currentTheme === dynamic && rawWallpaperPath) { + console.info("Theme: Matugen now available, regenerating colors for dynamic theme"); + const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode); + const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default"; + const selectedMatugenType = (typeof SettingsData !== "undefined" && SettingsData.matugenScheme) ? SettingsData.matugenScheme : "scheme-tonal-spot"; + if (rawWallpaperPath.startsWith("#")) { + setDesiredTheme("hex", rawWallpaperPath, isLight, iconTheme, selectedMatugenType); + } else { + setDesiredTheme("image", rawWallpaperPath, isLight, iconTheme, selectedMatugenType); + } + return; + } - const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) - const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default" + const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode); + const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default"; - if (currentTheme === dynamic) { - if (rawWallpaperPath) { - const selectedMatugenType = (typeof SettingsData !== "undefined" && SettingsData.matugenScheme) ? SettingsData.matugenScheme : "scheme-tonal-spot" - if (rawWallpaperPath.startsWith("#")) { - setDesiredTheme("hex", rawWallpaperPath, isLight, iconTheme, selectedMatugenType) - } else { - setDesiredTheme("image", rawWallpaperPath, isLight, iconTheme, selectedMatugenType) - } - } - } else { - let primaryColor - let matugenType - if (currentTheme === "custom") { - if (customThemeData && customThemeData.primary) { - primaryColor = customThemeData.primary - matugenType = customThemeData.matugen_type - } - } else { - primaryColor = currentThemeData.primary - matugenType = currentThemeData.matugen_type - } + if (currentTheme === dynamic) { + if (rawWallpaperPath) { + const selectedMatugenType = (typeof SettingsData !== "undefined" && SettingsData.matugenScheme) ? SettingsData.matugenScheme : "scheme-tonal-spot"; + if (rawWallpaperPath.startsWith("#")) { + setDesiredTheme("hex", rawWallpaperPath, isLight, iconTheme, selectedMatugenType); + } else { + setDesiredTheme("image", rawWallpaperPath, isLight, iconTheme, selectedMatugenType); + } + } + } else { + let primaryColor; + let matugenType; + if (currentTheme === "custom") { + if (customThemeData && customThemeData.primary) { + primaryColor = customThemeData.primary; + matugenType = customThemeData.matugen_type; + } + } else { + primaryColor = currentThemeData.primary; + matugenType = currentThemeData.matugen_type; + } - if (primaryColor) { - setDesiredTheme("hex", primaryColor, isLight, iconTheme, matugenType) - } - } - }, 0) + if (primaryColor) { + setDesiredTheme("hex", primaryColor, isLight, iconTheme, matugenType); + } + } + }, 0); if (typeof SessionData !== "undefined") { - SessionData.isLightModeChanged.connect(root.onLightModeChanged) + SessionData.isLightModeChanged.connect(root.onLightModeChanged); } if (typeof SettingsData !== "undefined" && SettingsData.currentThemeName) { - switchTheme(SettingsData.currentThemeName, false, false) + switchTheme(SettingsData.currentThemeName, false, false); } } function applyGreeterTheme(themeName) { - switchTheme(themeName, false, false) + switchTheme(themeName, false, false); if (themeName === dynamic && dynamicColorsFileView.path) { - dynamicColorsFileView.reload() + dynamicColorsFileView.reload(); } } function getMatugenColor(path, fallback) { - const colorMode = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "light" : "dark" - let cur = matugenColors && matugenColors.colors && matugenColors.colors[colorMode] + const colorMode = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "light" : "dark"; + let cur = matugenColors && matugenColors.colors && matugenColors.colors[colorMode]; for (const part of path.split(".")) { if (!cur || typeof cur !== "object" || !(part in cur)) - return fallback - cur = cur[part] + return fallback; + cur = cur[part]; } - return cur || fallback + return cur || fallback; } readonly property var currentThemeData: { if (currentTheme === "custom") { - return customThemeData || StockThemes.getThemeByName("blue", isLightMode) + return customThemeData || StockThemes.getThemeByName("blue", isLightMode); } else if (currentTheme === dynamic) { return { "primary": getMatugenColor("primary", "#42a5f5"), @@ -196,70 +196,61 @@ Singleton { "warning": "#FF9800", "info": "#2196F3", "success": "#4CAF50" - } + }; } else { - return StockThemes.getThemeByName(currentTheme, isLightMode) + return StockThemes.getThemeByName(currentTheme, isLightMode); } } readonly property var availableMatugenSchemes: [({ - "value": "scheme-tonal-spot", - "label": "Tonal Spot", - "description": I18n.tr("Balanced palette with focused accents (default).") - }), - ({ - "value": "scheme-vibrant", - "label": "Vibrant", - "description": I18n.tr("Lively palette with saturated accents.") - }), - ({ - "value": "scheme-dynamic-contrast", - "label": "Dynamic Contrast", - "description": I18n.tr("High-contrast palette for strong visual distinction.") - }), - ({ - "value": "scheme-content", - "label": "Content", - "description": I18n.tr("Derives colors that closely match the underlying image.") - }), - ({ - "value": "scheme-expressive", - "label": "Expressive", - "description": I18n.tr("Vibrant palette with playful saturation.") - }), - ({ - "value": "scheme-fidelity", - "label": "Fidelity", - "description": I18n.tr("High-fidelity palette that preserves source hues.") - }), - ({ - "value": "scheme-fruit-salad", - "label": "Fruit Salad", - "description": I18n.tr("Colorful mix of bright contrasting accents.") - }), - ({ - "value": "scheme-monochrome", - "label": "Monochrome", - "description": I18n.tr("Minimal palette built around a single hue.") - }), - ({ - "value": "scheme-neutral", - "label": "Neutral", - "description": I18n.tr("Muted palette with subdued, calming tones.") - }), - ({ - "value": "scheme-rainbow", - "label": "Rainbow", - "description": I18n.tr("Diverse palette spanning the full spectrum.") - })] + "value": "scheme-tonal-spot", + "label": "Tonal Spot", + "description": I18n.tr("Balanced palette with focused accents (default).") + }), ({ + "value": "scheme-vibrant", + "label": "Vibrant", + "description": I18n.tr("Lively palette with saturated accents.") + }), ({ + "value": "scheme-dynamic-contrast", + "label": "Dynamic Contrast", + "description": I18n.tr("High-contrast palette for strong visual distinction.") + }), ({ + "value": "scheme-content", + "label": "Content", + "description": I18n.tr("Derives colors that closely match the underlying image.") + }), ({ + "value": "scheme-expressive", + "label": "Expressive", + "description": I18n.tr("Vibrant palette with playful saturation.") + }), ({ + "value": "scheme-fidelity", + "label": "Fidelity", + "description": I18n.tr("High-fidelity palette that preserves source hues.") + }), ({ + "value": "scheme-fruit-salad", + "label": "Fruit Salad", + "description": I18n.tr("Colorful mix of bright contrasting accents.") + }), ({ + "value": "scheme-monochrome", + "label": "Monochrome", + "description": I18n.tr("Minimal palette built around a single hue.") + }), ({ + "value": "scheme-neutral", + "label": "Neutral", + "description": I18n.tr("Muted palette with subdued, calming tones.") + }), ({ + "value": "scheme-rainbow", + "label": "Rainbow", + "description": I18n.tr("Diverse palette spanning the full spectrum.") + })] function getMatugenScheme(value) { - const schemes = availableMatugenSchemes + const schemes = availableMatugenSchemes; for (var i = 0; i < schemes.length; i++) { if (schemes[i].value === value) - return schemes[i] + return schemes[i]; } - return schemes[0] + return schemes[0]; } property color primary: currentThemeData.primary @@ -322,37 +313,43 @@ Singleton { property color shadowMedium: Qt.rgba(0, 0, 0, 0.08) property color shadowStrong: Qt.rgba(0, 0, 0, 0.3) - readonly property var animationDurations: [{ + readonly property var animationDurations: [ + { "shorter": 0, "short": 0, "medium": 0, "long": 0, "extraLong": 0 - }, { + }, + { "shorter": 50, "short": 75, "medium": 150, "long": 250, "extraLong": 500 - }, { + }, + { "shorter": 100, "short": 150, "medium": 300, "long": 500, "extraLong": 1000 - }, { + }, + { "shorter": 150, "short": 225, "medium": 450, "long": 750, "extraLong": 1500 - }, { + }, + { "shorter": 200, "short": 300, "medium": 600, "long": 1000, "extraLong": 2000 - }] + } + ] readonly property int currentAnimationSpeed: typeof SettingsData !== "undefined" ? SettingsData.animationSpeed : SettingsData.AnimationSpeed.Short readonly property var currentDurations: animationDurations[currentAnimationSpeed] || animationDurations[SettingsData.AnimationSpeed.Short] @@ -386,14 +383,14 @@ Singleton { readonly property int currentAnimationBaseDuration: { if (typeof SettingsData === "undefined") - return 500 + return 500; if (SettingsData.animationSpeed === SettingsData.AnimationSpeed.Custom) { - return SettingsData.customAnimationDuration + return SettingsData.customAnimationDuration; } - const presetMap = [0, 250, 500, 750] - return presetMap[SettingsData.animationSpeed] !== undefined ? presetMap[SettingsData.animationSpeed] : 500 + const presetMap = [0, 250, 500, 750]; + return presetMap[SettingsData.animationSpeed] !== undefined ? presetMap[SettingsData.animationSpeed] : 500; } readonly property var expressiveDurations: { @@ -406,10 +403,10 @@ Singleton { "expressiveFastSpatial": 350, "expressiveDefaultSpatial": 500, "expressiveEffects": 200 - } + }; } - const baseDuration = currentAnimationBaseDuration + const baseDuration = currentAnimationBaseDuration; return { "fast": baseDuration * 0.4, "normal": baseDuration * 0.8, @@ -418,42 +415,42 @@ Singleton { "expressiveFastSpatial": baseDuration * 0.7, "expressiveDefaultSpatial": baseDuration, "expressiveEffects": baseDuration * 0.4 - } + }; } property real cornerRadius: { if (typeof SessionData !== "undefined" && SessionData.isGreeterMode && typeof GreetdSettings !== "undefined") { - return GreetdSettings.cornerRadius + return GreetdSettings.cornerRadius; } - return typeof SettingsData !== "undefined" ? SettingsData.cornerRadius : 12 + return typeof SettingsData !== "undefined" ? SettingsData.cornerRadius : 12; } property string fontFamily: { if (typeof SessionData !== "undefined" && SessionData.isGreeterMode && typeof GreetdSettings !== "undefined") { - return GreetdSettings.fontFamily + return GreetdSettings.fontFamily; } - return typeof SettingsData !== "undefined" ? SettingsData.fontFamily : "Inter Variable" + return typeof SettingsData !== "undefined" ? SettingsData.fontFamily : "Inter Variable"; } property string monoFontFamily: { if (typeof SessionData !== "undefined" && SessionData.isGreeterMode && typeof GreetdSettings !== "undefined") { - return GreetdSettings.monoFontFamily + return GreetdSettings.monoFontFamily; } - return typeof SettingsData !== "undefined" ? SettingsData.monoFontFamily : "Fira Code" + return typeof SettingsData !== "undefined" ? SettingsData.monoFontFamily : "Fira Code"; } property int fontWeight: { if (typeof SessionData !== "undefined" && SessionData.isGreeterMode && typeof GreetdSettings !== "undefined") { - return GreetdSettings.fontWeight + return GreetdSettings.fontWeight; } - return typeof SettingsData !== "undefined" ? SettingsData.fontWeight : Font.Normal + return typeof SettingsData !== "undefined" ? SettingsData.fontWeight : Font.Normal; } property real fontScale: { if (typeof SessionData !== "undefined" && SessionData.isGreeterMode && typeof GreetdSettings !== "undefined") { - return GreetdSettings.fontScale + return GreetdSettings.fontScale; } - return typeof SettingsData !== "undefined" ? SettingsData.fontScale : 1.0 + return typeof SettingsData !== "undefined" ? SettingsData.fontScale : 1.0; } property real spacingXS: 4 @@ -474,97 +471,97 @@ Singleton { property real popupTransparency: typeof SettingsData !== "undefined" && SettingsData.popupTransparency !== undefined ? SettingsData.popupTransparency : 1.0 function screenTransition() { - CompositorService.isNiri && NiriService.doScreenTransition() + CompositorService.isNiri && NiriService.doScreenTransition(); } function switchTheme(themeName, savePrefs = true, enableTransition = true) { if (enableTransition) { - screenTransition() - themeTransitionTimer.themeName = themeName - themeTransitionTimer.savePrefs = savePrefs - themeTransitionTimer.restart() - return + screenTransition(); + themeTransitionTimer.themeName = themeName; + themeTransitionTimer.savePrefs = savePrefs; + themeTransitionTimer.restart(); + return; } if (themeName === dynamic) { - currentTheme = dynamic - currentThemeCategory = dynamic + currentTheme = dynamic; + currentThemeCategory = dynamic; } else if (themeName === custom) { - currentTheme = custom - currentThemeCategory = custom + currentTheme = custom; + currentThemeCategory = custom; if (typeof SettingsData !== "undefined" && SettingsData.customThemeFile) { - loadCustomThemeFromFile(SettingsData.customThemeFile) + loadCustomThemeFromFile(SettingsData.customThemeFile); } } else { - currentTheme = themeName + currentTheme = themeName; if (StockThemes.isCatppuccinVariant(themeName)) { - currentThemeCategory = "catppuccin" + currentThemeCategory = "catppuccin"; } else { - currentThemeCategory = "generic" + currentThemeCategory = "generic"; } } - const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode) + const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode); if (savePrefs && typeof SettingsData !== "undefined" && !isGreeterMode) - SettingsData.set("currentThemeName", currentTheme) + SettingsData.set("currentThemeName", currentTheme); if (!isGreeterMode) { - generateSystemThemesFromCurrentTheme() + generateSystemThemesFromCurrentTheme(); } } function setLightMode(light, savePrefs = true, enableTransition = false) { if (enableTransition) { - screenTransition() - lightModeTransitionTimer.lightMode = light - lightModeTransitionTimer.savePrefs = savePrefs - lightModeTransitionTimer.restart() - return + screenTransition(); + lightModeTransitionTimer.lightMode = light; + lightModeTransitionTimer.savePrefs = savePrefs; + lightModeTransitionTimer.restart(); + return; } - const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode) + const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode); if (savePrefs && typeof SessionData !== "undefined" && !isGreeterMode) - SessionData.setLightMode(light) + SessionData.setLightMode(light); if (!isGreeterMode) { // Skip with matugen becuase, our script runner will do it. if (!matugenAvailable) { - PortalService.setLightMode(light) + PortalService.setLightMode(light); } - generateSystemThemesFromCurrentTheme() + generateSystemThemesFromCurrentTheme(); } } function toggleLightMode(savePrefs = true) { - setLightMode(!isLightMode, savePrefs, true) + setLightMode(!isLightMode, savePrefs, true); } function forceGenerateSystemThemes() { if (!matugenAvailable) { - return + return; } - generateSystemThemesFromCurrentTheme() + generateSystemThemesFromCurrentTheme(); } function getAvailableThemes() { - return StockThemes.getAllThemeNames() + return StockThemes.getAllThemeNames(); } function getThemeDisplayName(themeName) { - const themeData = StockThemes.getThemeByName(themeName, isLightMode) - return themeData.name + const themeData = StockThemes.getThemeByName(themeName, isLightMode); + return themeData.name; } function getThemeColors(themeName) { if (themeName === "custom" && customThemeData) { - return customThemeData + return customThemeData; } - return StockThemes.getThemeByName(themeName, isLightMode) + return StockThemes.getThemeByName(themeName, isLightMode); } function switchThemeCategory(category, defaultTheme) { - screenTransition() - themeCategoryTransitionTimer.category = category - themeCategoryTransitionTimer.defaultTheme = defaultTheme - themeCategoryTransitionTimer.restart() + screenTransition(); + themeCategoryTransitionTimer.category = category; + themeCategoryTransitionTimer.defaultTheme = defaultTheme; + themeCategoryTransitionTimer.restart(); } function getCatppuccinColor(variantName) { @@ -583,8 +580,8 @@ Singleton { "cat-sapphire": "#74c7ec", "cat-blue": "#89b4fa", "cat-lavender": "#b4befe" - } - return catColors[variantName] || "#cba6f7" + }; + return catColors[variantName] || "#cba6f7"; } function getCatppuccinVariantName(variantName) { @@ -603,218 +600,215 @@ Singleton { "cat-sapphire": "Sapphire", "cat-blue": "Blue", "cat-lavender": "Lavender" - } - return catNames[variantName] || "Unknown" + }; + return catNames[variantName] || "Unknown"; } function loadCustomTheme(themeData) { if (themeData.dark || themeData.light) { - const colorMode = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "light" : "dark" - const selectedTheme = themeData[colorMode] || themeData.dark || themeData.light - customThemeData = selectedTheme + const colorMode = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "light" : "dark"; + const selectedTheme = themeData[colorMode] || themeData.dark || themeData.light; + customThemeData = selectedTheme; } else { - customThemeData = themeData + customThemeData = themeData; } - generateSystemThemesFromCurrentTheme() + generateSystemThemesFromCurrentTheme(); } function loadCustomThemeFromFile(filePath) { - customThemeFileView.path = filePath + customThemeFileView.path = filePath; } property alias availableThemeNames: root._availableThemeNames readonly property var _availableThemeNames: StockThemes.getAllThemeNames() property string currentThemeName: currentTheme - function panelBackground() { - return Qt.rgba(surfaceContainer.r, surfaceContainer.g, surfaceContainer.b, panelTransparency) + return Qt.rgba(surfaceContainer.r, surfaceContainer.g, surfaceContainer.b, panelTransparency); } property real notepadTransparency: SettingsData.notepadTransparencyOverride >= 0 ? SettingsData.notepadTransparencyOverride : popupTransparency property bool widgetBackgroundHasAlpha: { - const colorMode = typeof SettingsData !== "undefined" ? SettingsData.widgetBackgroundColor : "sch" - return colorMode === "sth" + const colorMode = typeof SettingsData !== "undefined" ? SettingsData.widgetBackgroundColor : "sch"; + return colorMode === "sth"; } property var widgetBaseBackgroundColor: { - const colorMode = typeof SettingsData !== "undefined" ? SettingsData.widgetBackgroundColor : "sch" + const colorMode = typeof SettingsData !== "undefined" ? SettingsData.widgetBackgroundColor : "sch"; switch (colorMode) { - case "s": - return surface - case "sc": - return surfaceContainer - case "sch": - return surfaceContainerHigh - case "sth": - default: - return surfaceTextHover + case "s": + return surface; + case "sc": + return surfaceContainer; + case "sch": + return surfaceContainerHigh; + case "sth": + default: + return surfaceTextHover; } } property var widgetBaseHoverColor: { - const baseColor = widgetBaseBackgroundColor - const factor = 1.2 - return isLightMode ? Qt.darker(baseColor, factor) : Qt.lighter(baseColor, factor) + const baseColor = widgetBaseBackgroundColor; + const factor = 1.2; + return isLightMode ? Qt.darker(baseColor, factor) : Qt.lighter(baseColor, factor); } - property color widgetIconColor: { if (typeof SettingsData === "undefined") { - return surfaceText + return surfaceText; } switch (SettingsData.widgetColorMode) { - case "colorful": - return surfaceText - case "default": - default: - return surfaceText + case "colorful": + return surfaceText; + case "default": + default: + return surfaceText; } } property color widgetTextColor: { if (typeof SettingsData === "undefined") { - return surfaceText + return surfaceText; } switch (SettingsData.widgetColorMode) { - case "colorful": - return primary - case "default": - default: - return surfaceText + case "colorful": + return primary; + case "default": + default: + return surfaceText; } } - function isColorDark(c) { - return (0.299 * c.r + 0.587 * c.g + 0.114 * c.b) < 0.5 + return (0.299 * c.r + 0.587 * c.g + 0.114 * c.b) < 0.5; } function barIconSize(barThickness, offset) { - const defaultOffset = offset !== undefined ? offset : -6 - return Math.round((barThickness / 48) * (iconSize + defaultOffset)) + const defaultOffset = offset !== undefined ? offset : -6; + return Math.round((barThickness / 48) * (iconSize + defaultOffset)); } function barTextSize(barThickness, fontScale) { - const scale = barThickness / 48 - const dankBarScale = fontScale !== undefined ? fontScale : 1.0 + const scale = barThickness / 48; + const dankBarScale = fontScale !== undefined ? fontScale : 1.0; if (scale <= 0.75) - return Math.round(fontSizeSmall * 0.9 * dankBarScale) + return Math.round(fontSizeSmall * 0.9 * dankBarScale); if (scale >= 1.25) - return Math.round(fontSizeMedium * dankBarScale) - return Math.round(fontSizeSmall * dankBarScale) + return Math.round(fontSizeMedium * dankBarScale); + return Math.round(fontSizeSmall * dankBarScale); } function getBatteryIcon(level, isCharging, batteryAvailable) { if (!batteryAvailable) - return _getBatteryPowerProfileIcon() + return _getBatteryPowerProfileIcon(); if (isCharging) { if (level >= 90) - return "battery_charging_full" + return "battery_charging_full"; if (level >= 80) - return "battery_charging_90" + return "battery_charging_90"; if (level >= 60) - return "battery_charging_80" + return "battery_charging_80"; if (level >= 50) - return "battery_charging_60" + return "battery_charging_60"; if (level >= 30) - return "battery_charging_50" + return "battery_charging_50"; if (level >= 20) - return "battery_charging_30" - return "battery_charging_20" + return "battery_charging_30"; + return "battery_charging_20"; } else { if (level >= 95) - return "battery_full" + return "battery_full"; if (level >= 85) - return "battery_6_bar" + return "battery_6_bar"; if (level >= 70) - return "battery_5_bar" + return "battery_5_bar"; if (level >= 55) - return "battery_4_bar" + return "battery_4_bar"; if (level >= 40) - return "battery_3_bar" + return "battery_3_bar"; if (level >= 25) - return "battery_2_bar" + return "battery_2_bar"; if (level >= 10) - return "battery_1_bar" - return "battery_alert" + return "battery_1_bar"; + return "battery_alert"; } } function _getBatteryPowerProfileIcon() { if (typeof PowerProfiles === "undefined") - return "balance" + return "balance"; switch (PowerProfiles.profile) { case PowerProfile.PowerSaver: - return "energy_savings_leaf" + return "energy_savings_leaf"; case PowerProfile.Performance: - return "rocket_launch" + return "rocket_launch"; default: - return "balance" + return "balance"; } } function getPowerProfileIcon(profile) { switch (profile) { case PowerProfile.PowerSaver: - return "battery_saver" + return "battery_saver"; case PowerProfile.Balanced: - return "battery_std" + return "battery_std"; case PowerProfile.Performance: - return "flash_on" + return "flash_on"; default: - return "settings" + return "settings"; } } function getPowerProfileLabel(profile) { switch (profile) { case PowerProfile.PowerSaver: - return "Power Saver" + return "Power Saver"; case PowerProfile.Balanced: - return "Balanced" + return "Balanced"; case PowerProfile.Performance: - return "Performance" + return "Performance"; default: - return profile.charAt(0).toUpperCase() + profile.slice(1) + return profile.charAt(0).toUpperCase() + profile.slice(1); } } function getPowerProfileDescription(profile) { switch (profile) { case PowerProfile.PowerSaver: - return "Extend battery life" + return "Extend battery life"; case PowerProfile.Balanced: - return "Balance power and performance" + return "Balance power and performance"; case PowerProfile.Performance: - return "Prioritize performance" + return "Prioritize performance"; default: - return "Custom power profile" + return "Custom power profile"; } } function onLightModeChanged() { if (currentTheme === "custom" && customThemeFileView.path) { - customThemeFileView.reload() + customThemeFileView.reload(); } } function setDesiredTheme(kind, value, isLight, iconTheme, matugenType) { if (!matugenAvailable) { - console.warn("Theme: matugen not available or disabled - cannot set system theme") - return + console.warn("Theme: matugen not available or disabled - cannot set system theme"); + return; } - console.info("Theme: Setting desired theme -", kind, "mode:", isLight ? "light" : "dark", "type:", matugenType) + console.info("Theme: Setting desired theme -", kind, "mode:", isLight ? "light" : "dark", "type:", matugenType); if (typeof NiriService !== "undefined" && CompositorService.isNiri) { - NiriService.suppressNextToast() + NiriService.suppressNextToast(); } const desired = { @@ -824,198 +818,197 @@ Singleton { "iconTheme": iconTheme || "System Default", "matugenType": matugenType || "scheme-tonal-spot", "runUserTemplates": (typeof SettingsData !== "undefined") ? SettingsData.runUserMatugenTemplates : true - } + }; - const json = JSON.stringify(desired) - const desiredPath = stateDir + "/matugen.desired.json" + const json = JSON.stringify(desired); + const desiredPath = stateDir + "/matugen.desired.json"; - Quickshell.execDetached(["sh", "-c", `mkdir -p '${stateDir}' && cat > '${desiredPath}' << 'EOF'\n${json}\nEOF`]) - workerRunning = true - const syncModeWithPortal = (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal) ? "true" : "false" - const terminalsAlwaysDark = (typeof SettingsData !== "undefined" && SettingsData.terminalsAlwaysDark) ? "true" : "false" - console.log("Theme: Starting matugen worker") - systemThemeGenerator.command = [shellDir + "/scripts/matugen-worker.sh", stateDir, shellDir, configDir, syncModeWithPortal, terminalsAlwaysDark, "--run"] - systemThemeGenerator.running = true + Quickshell.execDetached(["sh", "-c", `mkdir -p '${stateDir}' && cat > '${desiredPath}' << 'EOF'\n${json}\nEOF`]); + workerRunning = true; + const syncModeWithPortal = (typeof SettingsData !== "undefined" && SettingsData.syncModeWithPortal) ? "true" : "false"; + const terminalsAlwaysDark = (typeof SettingsData !== "undefined" && SettingsData.terminalsAlwaysDark) ? "true" : "false"; + console.log("Theme: Starting matugen worker"); + systemThemeGenerator.command = [shellDir + "/scripts/matugen-worker.sh", stateDir, shellDir, configDir, syncModeWithPortal, terminalsAlwaysDark, "--run"]; + systemThemeGenerator.running = true; } function generateSystemThemesFromCurrentTheme() { - const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode) + const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode); if (!matugenAvailable || isGreeterMode) - return - - const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) - const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default" + return; + const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode); + const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default"; if (currentTheme === dynamic) { if (!rawWallpaperPath) { - return + return; } - const selectedMatugenType = (typeof SettingsData !== "undefined" && SettingsData.matugenScheme) ? SettingsData.matugenScheme : "scheme-tonal-spot" + const selectedMatugenType = (typeof SettingsData !== "undefined" && SettingsData.matugenScheme) ? SettingsData.matugenScheme : "scheme-tonal-spot"; if (rawWallpaperPath.startsWith("#")) { - setDesiredTheme("hex", rawWallpaperPath, isLight, iconTheme, selectedMatugenType) + setDesiredTheme("hex", rawWallpaperPath, isLight, iconTheme, selectedMatugenType); } else { - setDesiredTheme("image", rawWallpaperPath, isLight, iconTheme, selectedMatugenType) + setDesiredTheme("image", rawWallpaperPath, isLight, iconTheme, selectedMatugenType); } } else { - let primaryColor - let matugenType + let primaryColor; + let matugenType; if (currentTheme === "custom") { if (!customThemeData || !customThemeData.primary) { - console.warn("Custom theme data not available for system theme generation") - return + console.warn("Custom theme data not available for system theme generation"); + return; } - primaryColor = customThemeData.primary - matugenType = customThemeData.matugen_type + primaryColor = customThemeData.primary; + matugenType = customThemeData.matugen_type; } else { - primaryColor = currentThemeData.primary - matugenType = currentThemeData.matugen_type + primaryColor = currentThemeData.primary; + matugenType = currentThemeData.matugen_type; } if (!primaryColor) { - console.warn("No primary color available for theme:", currentTheme) - return + console.warn("No primary color available for theme:", currentTheme); + return; } - setDesiredTheme("hex", primaryColor, isLight, iconTheme, matugenType) + setDesiredTheme("hex", primaryColor, isLight, iconTheme, matugenType); } } function applyGtkColors() { if (!matugenAvailable) { if (typeof ToastService !== "undefined") { - ToastService.showError("matugen not available or disabled - cannot apply GTK colors") + ToastService.showError("matugen not available or disabled - cannot apply GTK colors"); } - return + return; } - const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "true" : "false" + const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "true" : "false"; Proc.runCommand("gtkApplier", [shellDir + "/scripts/gtk.sh", configDir, isLight, shellDir], (output, exitCode) => { - if (exitCode === 0) { - if (typeof ToastService !== "undefined" && typeof NiriService !== "undefined" && !NiriService.matugenSuppression) { - ToastService.showInfo("GTK colors applied successfully") - } - } else { - if (typeof ToastService !== "undefined") { - ToastService.showError("Failed to apply GTK colors") - } - } - }) + if (exitCode === 0) { + if (typeof ToastService !== "undefined" && typeof NiriService !== "undefined" && !NiriService.matugenSuppression) { + ToastService.showInfo("GTK colors applied successfully"); + } + } else { + if (typeof ToastService !== "undefined") { + ToastService.showError("Failed to apply GTK colors"); + } + } + }); } function applyQtColors() { if (!matugenAvailable) { if (typeof ToastService !== "undefined") { - ToastService.showError("matugen not available or disabled - cannot apply Qt colors") + ToastService.showError("matugen not available or disabled - cannot apply Qt colors"); } - return + return; } Proc.runCommand("qtApplier", [shellDir + "/scripts/qt.sh", configDir], (output, exitCode) => { - if (exitCode === 0) { - if (typeof ToastService !== "undefined") { - ToastService.showInfo("Qt colors applied successfully") - } - } else { - if (typeof ToastService !== "undefined") { - ToastService.showError("Failed to apply Qt colors") - } - } - }) + if (exitCode === 0) { + if (typeof ToastService !== "undefined") { + ToastService.showInfo("Qt colors applied successfully"); + } + } else { + if (typeof ToastService !== "undefined") { + ToastService.showError("Failed to apply Qt colors"); + } + } + }); } function withAlpha(c, a) { - return Qt.rgba(c.r, c.g, c.b, a) + return Qt.rgba(c.r, c.g, c.b, a); } function getFillMode(modeName) { switch (modeName) { case "Stretch": - return Image.Stretch + return Image.Stretch; case "Fit": case "PreserveAspectFit": - return Image.PreserveAspectFit + return Image.PreserveAspectFit; case "Fill": case "PreserveAspectCrop": - return Image.PreserveAspectCrop + return Image.PreserveAspectCrop; case "Tile": - return Image.Tile + return Image.Tile; case "TileVertically": - return Image.TileVertically + return Image.TileVertically; case "TileHorizontally": - return Image.TileHorizontally + return Image.TileHorizontally; case "Pad": - return Image.Pad + return Image.Pad; default: - return Image.PreserveAspectCrop + return Image.PreserveAspectCrop; } } function snap(value, dpr) { - const s = dpr || 1 - return Math.round(value * s) / s + const s = dpr || 1; + return Math.round(value * s) / s; } function px(value, dpr) { - const s = dpr || 1 - return Math.round(value * s) / s + const s = dpr || 1; + return Math.round(value * s) / s; } function hairline(dpr) { - return 1 / (dpr || 1) + return 1 / (dpr || 1); } function invertHex(hex) { - hex = hex.replace('#', '') + hex = hex.replace('#', ''); if (!/^[0-9A-Fa-f]{6}$/.test(hex)) { - return hex + return hex; } - const r = parseInt(hex.substr(0, 2), 16) - const g = parseInt(hex.substr(2, 2), 16) - const b = parseInt(hex.substr(4, 2), 16) + const r = parseInt(hex.substr(0, 2), 16); + const g = parseInt(hex.substr(2, 2), 16); + const b = parseInt(hex.substr(4, 2), 16); - const invR = (255 - r).toString(16).padStart(2, '0') - const invG = (255 - g).toString(16).padStart(2, '0') - const invB = (255 - b).toString(16).padStart(2, '0') + const invR = (255 - r).toString(16).padStart(2, '0'); + const invG = (255 - g).toString(16).padStart(2, '0'); + const invB = (255 - b).toString(16).padStart(2, '0'); - return `#${invR}${invG}${invB}` + return `#${invR}${invG}${invB}`; } property string baseLogoColor: { if (typeof SettingsData === "undefined") - return "" - const colorOverride = SettingsData.launcherLogoColorOverride + return ""; + const colorOverride = SettingsData.launcherLogoColorOverride; if (!colorOverride || colorOverride === "") - return "" + return ""; if (colorOverride === "primary") - return primary + return primary; if (colorOverride === "surface") - return surfaceText - return colorOverride + return surfaceText; + return colorOverride; } property string effectiveLogoColor: { if (typeof SettingsData === "undefined") - return "" + return ""; - const colorOverride = SettingsData.launcherLogoColorOverride + const colorOverride = SettingsData.launcherLogoColorOverride; if (!colorOverride || colorOverride === "") - return "" + return ""; if (colorOverride === "primary") - return primary + return primary; if (colorOverride === "surface") - return surfaceText + return surfaceText; if (!SettingsData.launcherLogoColorInvertOnMode) { - return colorOverride + return colorOverride; } if (isLightMode) { - return invertHex(colorOverride) + return invertHex(colorOverride); } - return colorOverride + return colorOverride; } Process { @@ -1023,21 +1016,21 @@ Singleton { running: false onExited: exitCode => { - workerRunning = false + workerRunning = false; if (exitCode === 0) { - console.info("Theme: Matugen worker completed successfully") + console.info("Theme: Matugen worker completed successfully"); if (currentTheme === dynamic) { - console.log("Theme: Reloading dynamic colors file") - dynamicColorsFileView.reload() + console.log("Theme: Reloading dynamic colors file"); + dynamicColorsFileView.reload(); } } else if (exitCode === 2) { - console.log("Theme: Matugen worker completed with code 2 (no changes needed)") + console.log("Theme: Matugen worker completed with code 2 (no changes needed)"); } else { if (typeof ToastService !== "undefined") { - ToastService.showError("Theme worker failed (" + exitCode + ")") + ToastService.showError("Theme worker failed (" + exitCode + ")"); } - console.warn("Theme: Matugen worker failed with exit code:", exitCode) + console.warn("Theme: Matugen worker failed with exit code:", exitCode); } } } @@ -1048,24 +1041,24 @@ Singleton { function parseAndLoadTheme() { try { - var themeData = JSON.parse(customThemeFileView.text()) - loadCustomTheme(themeData) + var themeData = JSON.parse(customThemeFileView.text()); + loadCustomTheme(themeData); } catch (e) { - ToastService.showError("Invalid JSON format: " + e.message) + ToastService.showError("Invalid JSON format: " + e.message); } } onLoaded: { - parseAndLoadTheme() + parseAndLoadTheme(); } onFileChanged: { - customThemeFileView.reload() + customThemeFileView.reload(); } onLoadFailed: function (error) { if (typeof ToastService !== "undefined") { - ToastService.showError("Failed to read theme file: " + error) + ToastService.showError("Failed to read theme file: " + error); } } } @@ -1073,58 +1066,58 @@ Singleton { FileView { id: dynamicColorsFileView path: { - const greetCfgDir = Quickshell.env("DMS_GREET_CFG_DIR") || "/etc/greetd/.dms" - const colorsPath = SessionData.isGreeterMode ? greetCfgDir + "/colors.json" : stateDir + "/dms-colors.json" - return colorsPath + const greetCfgDir = Quickshell.env("DMS_GREET_CFG_DIR") || "/etc/greetd/.dms"; + const colorsPath = SessionData.isGreeterMode ? greetCfgDir + "/colors.json" : stateDir + "/dms-colors.json"; + return colorsPath; } watchChanges: currentTheme === dynamic && !SessionData.isGreeterMode function parseAndLoadColors() { try { - const colorsText = dynamicColorsFileView.text() + const colorsText = dynamicColorsFileView.text(); if (colorsText) { - root.matugenColors = JSON.parse(colorsText) + root.matugenColors = JSON.parse(colorsText); if (typeof ToastService !== "undefined") { - ToastService.clearWallpaperError() + ToastService.clearWallpaperError(); } } } catch (e) { - console.error("Theme: Failed to parse dynamic colors:", e) + console.error("Theme: Failed to parse dynamic colors:", e); if (typeof ToastService !== "undefined") { - ToastService.wallpaperErrorStatus = "error" - ToastService.showError("Dynamic colors parse error: " + e.message) + ToastService.wallpaperErrorStatus = "error"; + ToastService.showError("Dynamic colors parse error: " + e.message); } } } onLoaded: { if (currentTheme === dynamic) { - console.info("Theme: Dynamic colors file loaded successfully") - colorsFileLoadFailed = false - parseAndLoadColors() + console.info("Theme: Dynamic colors file loaded successfully"); + colorsFileLoadFailed = false; + parseAndLoadColors(); } } onFileChanged: { if (currentTheme === dynamic) { - dynamicColorsFileView.reload() + dynamicColorsFileView.reload(); } } onLoadFailed: function (error) { if (currentTheme === dynamic) { - console.warn("Theme: Dynamic colors file load failed, marking for regeneration") - colorsFileLoadFailed = true - const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode) + console.warn("Theme: Dynamic colors file load failed, marking for regeneration"); + colorsFileLoadFailed = true; + const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode); if (!isGreeterMode && matugenAvailable && rawWallpaperPath) { - console.log("Theme: Matugen available, triggering immediate regeneration") - generateSystemThemesFromCurrentTheme() + console.log("Theme: Matugen available, triggering immediate regeneration"); + generateSystemThemesFromCurrentTheme(); } } } onPathChanged: { - colorsFileLoadFailed = false + colorsFileLoadFailed = false; } } @@ -1132,22 +1125,22 @@ Singleton { target: "theme" function toggle(): string { - root.toggleLightMode() - return root.isLightMode ? "dark" : "light" + root.toggleLightMode(); + return root.isLightMode ? "dark" : "light"; } function light(): string { - root.setLightMode(true, true, true) - return "light" + root.setLightMode(true, true, true); + return "light"; } function dark(): string { - root.setLightMode(false, true, true) - return "dark" + root.setLightMode(false, true, true); + return "dark"; } function getMode(): string { - return root.isLightMode ? "light" : "dark" + return root.isLightMode ? "light" : "dark"; } } @@ -1177,8 +1170,8 @@ Singleton { property string category: "" property string defaultTheme: "" onTriggered: { - root.currentThemeCategory = category - root.switchTheme(defaultTheme, true, false) + root.currentThemeCategory = category; + root.switchTheme(defaultTheme, true, false); } } } diff --git a/quickshell/Modules/Greetd/GreetdSettings.qml b/quickshell/Modules/Greetd/GreetdSettings.qml index 14574683..8faeaf65 100644 --- a/quickshell/Modules/Greetd/GreetdSettings.qml +++ b/quickshell/Modules/Greetd/GreetdSettings.qml @@ -11,8 +11,8 @@ Singleton { id: root readonly property string configPath: { - const greetCfgDir = Quickshell.env("DMS_GREET_CFG_DIR") || "/etc/greetd/.dms" - return greetCfgDir + "/settings.json" + const greetCfgDir = Quickshell.env("DMS_GREET_CFG_DIR") || "/etc/greetd/.dms"; + return greetCfgDir + "/settings.json"; } property string currentThemeName: "blue" @@ -44,64 +44,61 @@ Singleton { property int animationSpeed: 2 property string wallpaperFillMode: "Fill" - readonly property string defaultFontFamily: "Inter Variable" - readonly property string defaultMonoFontFamily: "Fira Code" - function parseSettings(content) { try { if (content && content.trim()) { - const settings = JSON.parse(content) - currentThemeName = settings.currentThemeName !== undefined ? settings.currentThemeName : "blue" - customThemeFile = settings.customThemeFile !== undefined ? settings.customThemeFile : "" - matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot" - 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 - iconTheme = settings.iconTheme !== undefined ? settings.iconTheme : "System Default" - useOSLogo = settings.useOSLogo !== undefined ? settings.useOSLogo : false - osLogoColorOverride = settings.osLogoColorOverride !== undefined ? settings.osLogoColorOverride : "" - osLogoBrightness = settings.osLogoBrightness !== undefined ? settings.osLogoBrightness : 0.5 - osLogoContrast = settings.osLogoContrast !== undefined ? settings.osLogoContrast : 1 - 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 - cornerRadius = settings.cornerRadius !== undefined ? settings.cornerRadius : 12 - widgetBackgroundColor = settings.widgetBackgroundColor !== undefined ? settings.widgetBackgroundColor : "sch" - lockDateFormat = settings.lockDateFormat !== undefined ? settings.lockDateFormat : "" - lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true - screenPreferences = settings.screenPreferences !== undefined ? settings.screenPreferences : ({}) - animationSpeed = settings.animationSpeed !== undefined ? settings.animationSpeed : 2 - wallpaperFillMode = settings.wallpaperFillMode !== undefined ? settings.wallpaperFillMode : "Fill" - settingsLoaded = true + const settings = JSON.parse(content); + currentThemeName = settings.currentThemeName !== undefined ? settings.currentThemeName : "blue"; + customThemeFile = settings.customThemeFile !== undefined ? settings.customThemeFile : ""; + matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot"; + 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; + iconTheme = settings.iconTheme !== undefined ? settings.iconTheme : "System Default"; + useOSLogo = settings.useOSLogo !== undefined ? settings.useOSLogo : false; + osLogoColorOverride = settings.osLogoColorOverride !== undefined ? settings.osLogoColorOverride : ""; + osLogoBrightness = settings.osLogoBrightness !== undefined ? settings.osLogoBrightness : 0.5; + osLogoContrast = settings.osLogoContrast !== undefined ? settings.osLogoContrast : 1; + fontFamily = settings.fontFamily !== undefined ? settings.fontFamily : Theme.defaultFontFamily; + monoFontFamily = settings.monoFontFamily !== undefined ? settings.monoFontFamily : Theme.defaultMonoFontFamily; + fontWeight = settings.fontWeight !== undefined ? settings.fontWeight : Font.Normal; + fontScale = settings.fontScale !== undefined ? settings.fontScale : 1.0; + cornerRadius = settings.cornerRadius !== undefined ? settings.cornerRadius : 12; + widgetBackgroundColor = settings.widgetBackgroundColor !== undefined ? settings.widgetBackgroundColor : "sch"; + lockDateFormat = settings.lockDateFormat !== undefined ? settings.lockDateFormat : ""; + lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true; + screenPreferences = settings.screenPreferences !== undefined ? settings.screenPreferences : ({}); + animationSpeed = settings.animationSpeed !== undefined ? settings.animationSpeed : 2; + wallpaperFillMode = settings.wallpaperFillMode !== undefined ? settings.wallpaperFillMode : "Fill"; + settingsLoaded = true; if (typeof Theme !== "undefined") { if (currentThemeName === "custom" && customThemeFile) { - Theme.loadCustomThemeFromFile(customThemeFile) + Theme.loadCustomThemeFromFile(customThemeFile); } - Theme.applyGreeterTheme(currentThemeName) + Theme.applyGreeterTheme(currentThemeName); } } } catch (e) { - console.warn("Failed to parse greetd settings:", e) + console.warn("Failed to parse greetd settings:", e); } } function getEffectiveLockDateFormat() { - return lockDateFormat && lockDateFormat.length > 0 ? lockDateFormat : Locale.LongFormat + return lockDateFormat && lockDateFormat.length > 0 ? lockDateFormat : Locale.LongFormat; } function getFilteredScreens(componentId) { - const prefs = screenPreferences && screenPreferences[componentId] || ["all"] + const prefs = screenPreferences && screenPreferences[componentId] || ["all"]; if (prefs.includes("all")) { - return Quickshell.screens + return Quickshell.screens; } - return Quickshell.screens.filter(screen => prefs.includes(screen.name)) + return Quickshell.screens.filter(screen => prefs.includes(screen.name)); } FileView { @@ -113,7 +110,7 @@ Singleton { watchChanges: false printErrors: true onLoaded: { - parseSettings(settingsFile.text()) + parseSettings(settingsFile.text()); } } } diff --git a/quickshell/Modules/Notepad/NotepadSettings.qml b/quickshell/Modules/Notepad/NotepadSettings.qml index 53bb5faf..9265ddf8 100644 --- a/quickshell/Modules/Notepad/NotepadSettings.qml +++ b/quickshell/Modules/Notepad/NotepadSettings.qml @@ -23,7 +23,7 @@ Item { var fontName = availableFonts[i]; if (fontName.startsWith(".")) continue; - if (fontName === SettingsData.defaultFontFamily) + if (fontName === Theme.defaultFontFamily) continue; var rootName = fontName.replace(/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i, "").replace(/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i, "").replace(/ (UI|Display|Text|Mono|Sans|Serif)$/i, function (match, suffix) { return match; diff --git a/quickshell/Modules/Settings/PersonalizationTab.qml b/quickshell/Modules/Settings/PersonalizationTab.qml index d6779a7f..e17c993c 100644 --- a/quickshell/Modules/Settings/PersonalizationTab.qml +++ b/quickshell/Modules/Settings/PersonalizationTab.qml @@ -17,33 +17,30 @@ Item { property var cachedFontFamilies: [] property bool fontsEnumerated: false property string selectedMonitorName: { - var screens = Quickshell.screens - return screens.length > 0 ? screens[0].name : "" + var screens = Quickshell.screens; + return screens.length > 0 ? screens[0].name : ""; } function enumerateFonts() { - var fonts = ["Default"] - var availableFonts = Qt.fontFamilies() - var rootFamilies = [] - var seenFamilies = new Set() + var fonts = ["Default"]; + var availableFonts = Qt.fontFamilies(); + var rootFamilies = []; + var seenFamilies = new Set(); for (var i = 0; i < availableFonts.length; i++) { - var fontName = availableFonts[i] + var fontName = availableFonts[i]; if (fontName.startsWith(".")) - continue - - if (fontName === SettingsData.defaultFontFamily) - continue - - var rootName = fontName.replace(/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i, "").replace(/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i, - "").replace(/ (UI|Display|Text|Mono|Sans|Serif)$/i, function (match, suffix) { - return match - }).trim() + continue; + if (fontName === Theme.defaultFontFamily) + continue; + var rootName = fontName.replace(/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i, "").replace(/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i, "").replace(/ (UI|Display|Text|Mono|Sans|Serif)$/i, function (match, suffix) { + return match; + }).trim(); if (!seenFamilies.has(rootName) && rootName !== "") { - seenFamilies.add(rootName) - rootFamilies.push(rootName) + seenFamilies.add(rootName); + rootFamilies.push(rootName); } } - cachedFontFamilies = fonts.concat(rootFamilies.sort()) + cachedFontFamilies = fonts.concat(rootFamilies.sort()); } Timer { @@ -52,17 +49,17 @@ Item { running: false onTriggered: { if (!fontsEnumerated) { - enumerateFonts() - fontsEnumerated = true + enumerateFonts(); + fontsEnumerated = true; } } } Component.onCompleted: { - WallpaperCyclingService.cyclingActive - fontEnumerationTimer.start() + WallpaperCyclingService.cyclingActive; + fontEnumerationTimer.start(); if (AudioService.gsettingsAvailable) { - AudioService.scanSoundThemes() + AudioService.scanSoundThemes(); } } @@ -130,13 +127,13 @@ Item { anchors.fill: parent anchors.margins: 1 source: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return (currentWallpaper !== "" && !currentWallpaper.startsWith("#")) ? "file://" + currentWallpaper : "" + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return (currentWallpaper !== "" && !currentWallpaper.startsWith("#")) ? "file://" + currentWallpaper : ""; } fillMode: Image.PreserveAspectCrop visible: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper !== "" && !currentWallpaper.startsWith("#") + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper !== "" && !currentWallpaper.startsWith("#"); } maxCacheSize: 160 layer.enabled: true @@ -154,12 +151,12 @@ Item { anchors.margins: 1 radius: Theme.cornerRadius - 1 color: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper.startsWith("#") ? currentWallpaper : "transparent" + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper.startsWith("#") ? currentWallpaper : "transparent"; } visible: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper !== "" && currentWallpaper.startsWith("#") + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper !== "" && currentWallpaper.startsWith("#"); } } @@ -180,8 +177,8 @@ Item { size: Theme.iconSizeLarge + 8 color: Theme.surfaceVariantText visible: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper === "" + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper === ""; } } @@ -213,7 +210,7 @@ Item { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - wallpaperBrowserLoader.active = true + wallpaperBrowserLoader.active = true; } } } @@ -236,17 +233,17 @@ Item { cursorShape: Qt.PointingHandCursor onClicked: { if (PopoutService.colorPickerModal) { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - PopoutService.colorPickerModal.selectedColor = currentWallpaper.startsWith("#") ? currentWallpaper : Theme.primary - PopoutService.colorPickerModal.pickerTitle = "Choose Wallpaper Color" + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + PopoutService.colorPickerModal.selectedColor = currentWallpaper.startsWith("#") ? currentWallpaper : Theme.primary; + PopoutService.colorPickerModal.pickerTitle = "Choose Wallpaper Color"; PopoutService.colorPickerModal.onColorSelectedCallback = function (selectedColor) { if (SessionData.perMonitorWallpaper) { - SessionData.setMonitorWallpaper(selectedMonitorName, selectedColor) + SessionData.setMonitorWallpaper(selectedMonitorName, selectedColor); } else { - SessionData.setWallpaperColor(selectedColor) + SessionData.setWallpaperColor(selectedColor); } - } - PopoutService.colorPickerModal.show() + }; + PopoutService.colorPickerModal.show(); } } } @@ -258,8 +255,8 @@ Item { radius: 16 color: Qt.rgba(255, 255, 255, 0.9) visible: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper !== "" + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper !== ""; } DankIcon { @@ -274,11 +271,11 @@ Item { cursorShape: Qt.PointingHandCursor onClicked: { if (SessionData.perMonitorWallpaper) { - SessionData.setMonitorWallpaper(selectedMonitorName, "") + SessionData.setMonitorWallpaper(selectedMonitorName, ""); } else { if (Theme.currentTheme === Theme.dynamic) - Theme.switchTheme("blue") - SessionData.clearWallpaper() + Theme.switchTheme("blue"); + SessionData.clearWallpaper(); } } } @@ -304,8 +301,8 @@ Item { StyledText { text: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper ? currentWallpaper.split('/').pop() : "No wallpaper selected" + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper ? currentWallpaper.split('/').pop() : "No wallpaper selected"; } font.pixelSize: Theme.fontSizeLarge color: Theme.surfaceText @@ -316,8 +313,8 @@ Item { StyledText { text: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper ? currentWallpaper : "" + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper ? currentWallpaper : ""; } font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceVariantText @@ -325,16 +322,16 @@ Item { maximumLineCount: 1 width: parent.width visible: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper !== "" + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper !== ""; } } Row { spacing: Theme.spacingS visible: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper !== "" + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper !== ""; } DankActionButton { @@ -342,20 +339,20 @@ Item { iconName: "skip_previous" iconSize: Theme.iconSizeSmall enabled: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we") + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we"); } opacity: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return (currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we")) ? 1 : 0.5 + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return (currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we")) ? 1 : 0.5; } backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) iconColor: Theme.surfaceText onClicked: { if (SessionData.perMonitorWallpaper) { - WallpaperCyclingService.cyclePrevForMonitor(selectedMonitorName) + WallpaperCyclingService.cyclePrevForMonitor(selectedMonitorName); } else { - WallpaperCyclingService.cyclePrevManually() + WallpaperCyclingService.cyclePrevManually(); } } } @@ -365,20 +362,20 @@ Item { iconName: "skip_next" iconSize: Theme.iconSizeSmall enabled: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we") + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we"); } opacity: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return (currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we")) ? 1 : 0.5 + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return (currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we")) ? 1 : 0.5; } backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) iconColor: Theme.surfaceText onClicked: { if (SessionData.perMonitorWallpaper) { - WallpaperCyclingService.cycleNextForMonitor(selectedMonitorName) + WallpaperCyclingService.cycleNextForMonitor(selectedMonitorName); } else { - WallpaperCyclingService.cycleNextManually() + WallpaperCyclingService.cycleNextManually(); } } } @@ -390,8 +387,8 @@ Item { width: parent.width height: fillModeGroup.height visible: { - var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - return currentWallpaper !== "" && !currentWallpaper.startsWith("#") + var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; + return currentWallpaper !== "" && !currentWallpaper.startsWith("#"); } DankButtonGroup { @@ -406,21 +403,21 @@ Item { textSize: Theme.fontSizeSmall checkEnabled: false currentIndex: { - const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"] - return modes.indexOf(SettingsData.wallpaperFillMode) + const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"]; + return modes.indexOf(SettingsData.wallpaperFillMode); } onSelectionChanged: (index, selected) => { - if (selected) { - const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"] - SettingsData.set("wallpaperFillMode", modes[index]) - } - } + if (selected) { + const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"]; + SettingsData.set("wallpaperFillMode", modes[index]); + } + } Connections { target: SettingsData function onWallpaperFillModeChanged() { - const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"] - fillModeGroup.currentIndex = modes.indexOf(SettingsData.wallpaperFillMode) + const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"]; + fillModeGroup.currentIndex = modes.indexOf(SettingsData.wallpaperFillMode); } } @@ -428,9 +425,9 @@ Item { target: personalizationTab function onSelectedMonitorNameChanged() { Qt.callLater(() => { - const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"] - fillModeGroup.currentIndex = modes.indexOf(SettingsData.wallpaperFillMode) - }) + const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"]; + fillModeGroup.currentIndex = modes.indexOf(SettingsData.wallpaperFillMode); + }); } } } @@ -486,8 +483,8 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SessionData.perModeWallpaper onToggled: toggled => { - return SessionData.setPerModeWallpaper(toggled) - } + return SessionData.setPerModeWallpaper(toggled); + } } } @@ -524,13 +521,13 @@ Item { anchors.fill: parent anchors.margins: 1 source: { - var lightWallpaper = SessionData.wallpaperPathLight - return (lightWallpaper !== "" && !lightWallpaper.startsWith("#")) ? "file://" + lightWallpaper : "" + var lightWallpaper = SessionData.wallpaperPathLight; + return (lightWallpaper !== "" && !lightWallpaper.startsWith("#")) ? "file://" + lightWallpaper : ""; } fillMode: Image.PreserveAspectCrop visible: { - var lightWallpaper = SessionData.wallpaperPathLight - return lightWallpaper !== "" && !lightWallpaper.startsWith("#") + var lightWallpaper = SessionData.wallpaperPathLight; + return lightWallpaper !== "" && !lightWallpaper.startsWith("#"); } maxCacheSize: 160 layer.enabled: true @@ -548,12 +545,12 @@ Item { anchors.margins: 1 radius: Theme.cornerRadius - 1 color: { - var lightWallpaper = SessionData.wallpaperPathLight - return lightWallpaper.startsWith("#") ? lightWallpaper : "transparent" + var lightWallpaper = SessionData.wallpaperPathLight; + return lightWallpaper.startsWith("#") ? lightWallpaper : "transparent"; } visible: { - var lightWallpaper = SessionData.wallpaperPathLight - return lightWallpaper !== "" && lightWallpaper.startsWith("#") + var lightWallpaper = SessionData.wallpaperPathLight; + return lightWallpaper !== "" && lightWallpaper.startsWith("#"); } } @@ -603,7 +600,7 @@ Item { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - lightWallpaperBrowserLoader.active = true + lightWallpaperBrowserLoader.active = true; } } } @@ -626,15 +623,15 @@ Item { cursorShape: Qt.PointingHandCursor onClicked: { if (PopoutService.colorPickerModal) { - var lightWallpaper = SessionData.wallpaperPathLight - PopoutService.colorPickerModal.selectedColor = lightWallpaper.startsWith("#") ? lightWallpaper : Theme.primary - PopoutService.colorPickerModal.pickerTitle = "Choose Light Mode Color" - PopoutService.colorPickerModal.onColorSelectedCallback = function(selectedColor) { - SessionData.wallpaperPathLight = selectedColor - SessionData.syncWallpaperForCurrentMode() - SessionData.saveSettings() - } - PopoutService.colorPickerModal.show() + var lightWallpaper = SessionData.wallpaperPathLight; + PopoutService.colorPickerModal.selectedColor = lightWallpaper.startsWith("#") ? lightWallpaper : Theme.primary; + PopoutService.colorPickerModal.pickerTitle = "Choose Light Mode Color"; + PopoutService.colorPickerModal.onColorSelectedCallback = function (selectedColor) { + SessionData.wallpaperPathLight = selectedColor; + SessionData.syncWallpaperForCurrentMode(); + SessionData.saveSettings(); + }; + PopoutService.colorPickerModal.show(); } } } @@ -658,9 +655,9 @@ Item { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - SessionData.wallpaperPathLight = "" - SessionData.syncWallpaperForCurrentMode() - SessionData.saveSettings() + SessionData.wallpaperPathLight = ""; + SessionData.syncWallpaperForCurrentMode(); + SessionData.saveSettings(); } } } @@ -679,8 +676,8 @@ Item { StyledText { text: { - var lightWallpaper = SessionData.wallpaperPathLight - return lightWallpaper ? lightWallpaper.split('/').pop() : "Not set" + var lightWallpaper = SessionData.wallpaperPathLight; + return lightWallpaper ? lightWallpaper.split('/').pop() : "Not set"; } font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceVariantText @@ -713,13 +710,13 @@ Item { anchors.fill: parent anchors.margins: 1 source: { - var darkWallpaper = SessionData.wallpaperPathDark - return (darkWallpaper !== "" && !darkWallpaper.startsWith("#")) ? "file://" + darkWallpaper : "" + var darkWallpaper = SessionData.wallpaperPathDark; + return (darkWallpaper !== "" && !darkWallpaper.startsWith("#")) ? "file://" + darkWallpaper : ""; } fillMode: Image.PreserveAspectCrop visible: { - var darkWallpaper = SessionData.wallpaperPathDark - return darkWallpaper !== "" && !darkWallpaper.startsWith("#") + var darkWallpaper = SessionData.wallpaperPathDark; + return darkWallpaper !== "" && !darkWallpaper.startsWith("#"); } maxCacheSize: 160 layer.enabled: true @@ -737,12 +734,12 @@ Item { anchors.margins: 1 radius: Theme.cornerRadius - 1 color: { - var darkWallpaper = SessionData.wallpaperPathDark - return darkWallpaper.startsWith("#") ? darkWallpaper : "transparent" + var darkWallpaper = SessionData.wallpaperPathDark; + return darkWallpaper.startsWith("#") ? darkWallpaper : "transparent"; } visible: { - var darkWallpaper = SessionData.wallpaperPathDark - return darkWallpaper !== "" && darkWallpaper.startsWith("#") + var darkWallpaper = SessionData.wallpaperPathDark; + return darkWallpaper !== "" && darkWallpaper.startsWith("#"); } } @@ -792,7 +789,7 @@ Item { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - darkWallpaperBrowserLoader.active = true + darkWallpaperBrowserLoader.active = true; } } } @@ -815,15 +812,15 @@ Item { cursorShape: Qt.PointingHandCursor onClicked: { if (PopoutService.colorPickerModal) { - var darkWallpaper = SessionData.wallpaperPathDark - PopoutService.colorPickerModal.selectedColor = darkWallpaper.startsWith("#") ? darkWallpaper : Theme.primary - PopoutService.colorPickerModal.pickerTitle = "Choose Dark Mode Color" - PopoutService.colorPickerModal.onColorSelectedCallback = function(selectedColor) { - SessionData.wallpaperPathDark = selectedColor - SessionData.syncWallpaperForCurrentMode() - SessionData.saveSettings() - } - PopoutService.colorPickerModal.show() + var darkWallpaper = SessionData.wallpaperPathDark; + PopoutService.colorPickerModal.selectedColor = darkWallpaper.startsWith("#") ? darkWallpaper : Theme.primary; + PopoutService.colorPickerModal.pickerTitle = "Choose Dark Mode Color"; + PopoutService.colorPickerModal.onColorSelectedCallback = function (selectedColor) { + SessionData.wallpaperPathDark = selectedColor; + SessionData.syncWallpaperForCurrentMode(); + SessionData.saveSettings(); + }; + PopoutService.colorPickerModal.show(); } } } @@ -847,9 +844,9 @@ Item { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - SessionData.wallpaperPathDark = "" - SessionData.syncWallpaperForCurrentMode() - SessionData.saveSettings() + SessionData.wallpaperPathDark = ""; + SessionData.syncWallpaperForCurrentMode(); + SessionData.saveSettings(); } } } @@ -868,8 +865,8 @@ Item { StyledText { text: { - var darkWallpaper = SessionData.wallpaperPathDark - return darkWallpaper ? darkWallpaper.split('/').pop() : "Not set" + var darkWallpaper = SessionData.wallpaperPathDark; + return darkWallpaper ? darkWallpaper.split('/').pop() : "Not set"; } font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceVariantText @@ -929,8 +926,8 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.blurWallpaperOnOverview onToggled: checked => { - SettingsData.set("blurWallpaperOnOverview", checked) - } + SettingsData.set("blurWallpaperOnOverview", checked); + } } } @@ -984,8 +981,8 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SessionData.perMonitorWallpaper onToggled: toggled => { - return SessionData.setPerMonitorWallpaper(toggled) - } + return SessionData.setPerMonitorWallpaper(toggled); + } } } @@ -1008,28 +1005,28 @@ Item { text: I18n.tr("Wallpaper Monitor") description: I18n.tr("Select monitor to configure wallpaper") currentValue: { - var screens = Quickshell.screens + var screens = Quickshell.screens; for (var i = 0; i < screens.length; i++) { if (screens[i].name === selectedMonitorName) { - return SettingsData.getScreenDisplayName(screens[i]) + return SettingsData.getScreenDisplayName(screens[i]); } } - return "No monitors" + return "No monitors"; } options: { - var screenNames = [] - var screens = Quickshell.screens + var screenNames = []; + var screens = Quickshell.screens; for (var i = 0; i < screens.length; i++) { - screenNames.push(SettingsData.getScreenDisplayName(screens[i])) + screenNames.push(SettingsData.getScreenDisplayName(screens[i])); } - return screenNames + return screenNames; } onValueChanged: value => { - var screens = Quickshell.screens + var screens = Quickshell.screens; for (var i = 0; i < screens.length; i++) { if (SettingsData.getScreenDisplayName(screens[i]) === value) { - selectedMonitorName = screens[i].name - return + selectedMonitorName = screens[i].name; + return; } } } @@ -1041,36 +1038,36 @@ Item { text: I18n.tr("Matugen Target Monitor") description: I18n.tr("Monitor whose wallpaper drives dynamic theming colors") currentValue: { - var screens = Quickshell.screens + var screens = Quickshell.screens; if (!SettingsData.matugenTargetMonitor || SettingsData.matugenTargetMonitor === "") { - return screens.length > 0 ? SettingsData.getScreenDisplayName(screens[0]) + " (Default)" : "No monitors" + return screens.length > 0 ? SettingsData.getScreenDisplayName(screens[0]) + " (Default)" : "No monitors"; } for (var i = 0; i < screens.length; i++) { if (screens[i].name === SettingsData.matugenTargetMonitor) { - return SettingsData.getScreenDisplayName(screens[i]) + return SettingsData.getScreenDisplayName(screens[i]); } } - return SettingsData.matugenTargetMonitor + return SettingsData.matugenTargetMonitor; } options: { - var screenNames = [] - var screens = Quickshell.screens + var screenNames = []; + var screens = Quickshell.screens; for (var i = 0; i < screens.length; i++) { - var label = SettingsData.getScreenDisplayName(screens[i]) + var label = SettingsData.getScreenDisplayName(screens[i]); if (i === 0 && (!SettingsData.matugenTargetMonitor || SettingsData.matugenTargetMonitor === "")) { - label += " (Default)" + label += " (Default)"; } - screenNames.push(label) + screenNames.push(label); } - return screenNames + return screenNames; } onValueChanged: value => { - var cleanValue = value.replace(" (Default)", "") - var screens = Quickshell.screens + var cleanValue = value.replace(" (Default)", ""); + var screens = Quickshell.screens; for (var i = 0; i < screens.length; i++) { if (SettingsData.getScreenDisplayName(screens[i]) === cleanValue) { - SettingsData.setMatugenTargetMonitor(screens[i].name) - return + SettingsData.setMatugenTargetMonitor(screens[i].name); + return; } } } @@ -1128,19 +1125,19 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SessionData.perMonitorWallpaper ? SessionData.getMonitorCyclingSettings(selectedMonitorName).enabled : SessionData.wallpaperCyclingEnabled onToggled: toggled => { - if (SessionData.perMonitorWallpaper) { - return SessionData.setMonitorCyclingEnabled(selectedMonitorName, toggled) - } else { - return SessionData.setWallpaperCyclingEnabled(toggled) - } - } + if (SessionData.perMonitorWallpaper) { + return SessionData.setMonitorCyclingEnabled(selectedMonitorName, toggled); + } else { + return SessionData.setWallpaperCyclingEnabled(toggled); + } + } Connections { target: personalizationTab function onSelectedMonitorNameChanged() { cyclingToggle.checked = Qt.binding(() => { - return SessionData.perMonitorWallpaper ? SessionData.getMonitorCyclingSettings(selectedMonitorName).enabled : SessionData.wallpaperCyclingEnabled - }) + return SessionData.perMonitorWallpaper ? SessionData.getMonitorCyclingSettings(selectedMonitorName).enabled : SessionData.wallpaperCyclingEnabled; + }); } } } @@ -1172,39 +1169,42 @@ Item { width: 200 height: 45 - model: [{ + model: [ + { "text": "Interval", "icon": "schedule" - }, { + }, + { "text": "Time", "icon": "access_time" - }] + } + ] currentIndex: { if (SessionData.perMonitorWallpaper) { - return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "time" ? 1 : 0 + return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "time" ? 1 : 0; } else { - return SessionData.wallpaperCyclingMode === "time" ? 1 : 0 + return SessionData.wallpaperCyclingMode === "time" ? 1 : 0; } } onTabClicked: index => { - if (SessionData.perMonitorWallpaper) { - SessionData.setMonitorCyclingMode(selectedMonitorName, index === 1 ? "time" : "interval") - } else { - SessionData.setWallpaperCyclingMode(index === 1 ? "time" : "interval") - } - } + if (SessionData.perMonitorWallpaper) { + SessionData.setMonitorCyclingMode(selectedMonitorName, index === 1 ? "time" : "interval"); + } else { + SessionData.setWallpaperCyclingMode(index === 1 ? "time" : "interval"); + } + } Connections { target: personalizationTab function onSelectedMonitorNameChanged() { modeTabBar.currentIndex = Qt.binding(() => { - if (SessionData.perMonitorWallpaper) { - return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "time" ? 1 : 0 - } else { - return SessionData.wallpaperCyclingMode === "time" ? 1 : 0 - } - }) - Qt.callLater(modeTabBar.updateIndicator) + if (SessionData.perMonitorWallpaper) { + return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "time" ? 1 : 0; + } else { + return SessionData.wallpaperCyclingMode === "time" ? 1 : 0; + } + }); + Qt.callLater(modeTabBar.updateIndicator); } } } @@ -1220,49 +1220,49 @@ Item { width: parent.width - parent.leftPadding visible: { if (SessionData.perMonitorWallpaper) { - return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "interval" + return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "interval"; } else { - return SessionData.wallpaperCyclingMode === "interval" + return SessionData.wallpaperCyclingMode === "interval"; } } text: I18n.tr("Interval") description: I18n.tr("How often to change wallpaper") options: intervalOptions currentValue: { - var currentSeconds + var currentSeconds; if (SessionData.perMonitorWallpaper) { - currentSeconds = SessionData.getMonitorCyclingSettings(selectedMonitorName).interval + currentSeconds = SessionData.getMonitorCyclingSettings(selectedMonitorName).interval; } else { - currentSeconds = SessionData.wallpaperCyclingInterval + currentSeconds = SessionData.wallpaperCyclingInterval; } - const index = intervalValues.indexOf(currentSeconds) - return index >= 0 ? intervalOptions[index] : "5 minutes" + const index = intervalValues.indexOf(currentSeconds); + return index >= 0 ? intervalOptions[index] : "5 minutes"; } onValueChanged: value => { - const index = intervalOptions.indexOf(value) - if (index >= 0) { - if (SessionData.perMonitorWallpaper) { - SessionData.setMonitorCyclingInterval(selectedMonitorName, intervalValues[index]) - } else { - SessionData.setWallpaperCyclingInterval(intervalValues[index]) - } - } - } + const index = intervalOptions.indexOf(value); + if (index >= 0) { + if (SessionData.perMonitorWallpaper) { + SessionData.setMonitorCyclingInterval(selectedMonitorName, intervalValues[index]); + } else { + SessionData.setWallpaperCyclingInterval(intervalValues[index]); + } + } + } Connections { target: personalizationTab function onSelectedMonitorNameChanged() { // Force dropdown to refresh its currentValue Qt.callLater(() => { - var currentSeconds - if (SessionData.perMonitorWallpaper) { - currentSeconds = SessionData.getMonitorCyclingSettings(selectedMonitorName).interval - } else { - currentSeconds = SessionData.wallpaperCyclingInterval - } - const index = intervalDropdown.intervalValues.indexOf(currentSeconds) - intervalDropdown.currentValue = index >= 0 ? intervalDropdown.intervalOptions[index] : "5 minutes" - }) + var currentSeconds; + if (SessionData.perMonitorWallpaper) { + currentSeconds = SessionData.getMonitorCyclingSettings(selectedMonitorName).interval; + } else { + currentSeconds = SessionData.wallpaperCyclingInterval; + } + const index = intervalDropdown.intervalValues.indexOf(currentSeconds); + intervalDropdown.currentValue = index >= 0 ? intervalDropdown.intervalOptions[index] : "5 minutes"; + }); } } } @@ -1272,9 +1272,9 @@ Item { spacing: Theme.spacingM visible: { if (SessionData.perMonitorWallpaper) { - return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "time" + return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "time"; } else { - return SessionData.wallpaperCyclingMode === "time" + return SessionData.wallpaperCyclingMode === "time"; } } width: parent.width - parent.leftPadding @@ -1292,9 +1292,9 @@ Item { height: 40 text: { if (SessionData.perMonitorWallpaper) { - return SessionData.getMonitorCyclingSettings(selectedMonitorName).time + return SessionData.getMonitorCyclingSettings(selectedMonitorName).time; } else { - return SessionData.wallpaperCyclingTime + return SessionData.wallpaperCyclingTime; } } placeholderText: "00:00" @@ -1302,34 +1302,34 @@ Item { topPadding: Theme.spacingS bottomPadding: Theme.spacingS onAccepted: { - var isValid = /^([0-1][0-9]|2[0-3]):[0-5][0-9]$/.test(text) + var isValid = /^([0-1][0-9]|2[0-3]):[0-5][0-9]$/.test(text); if (isValid) { if (SessionData.perMonitorWallpaper) { - SessionData.setMonitorCyclingTime(selectedMonitorName, text) + SessionData.setMonitorCyclingTime(selectedMonitorName, text); } else { - SessionData.setWallpaperCyclingTime(text) + SessionData.setWallpaperCyclingTime(text); } } else { if (SessionData.perMonitorWallpaper) { - text = SessionData.getMonitorCyclingSettings(selectedMonitorName).time + text = SessionData.getMonitorCyclingSettings(selectedMonitorName).time; } else { - text = SessionData.wallpaperCyclingTime + text = SessionData.wallpaperCyclingTime; } } } onEditingFinished: { - var isValid = /^([0-1][0-9]|2[0-3]):[0-5][0-9]$/.test(text) + var isValid = /^([0-1][0-9]|2[0-3]):[0-5][0-9]$/.test(text); if (isValid) { if (SessionData.perMonitorWallpaper) { - SessionData.setMonitorCyclingTime(selectedMonitorName, text) + SessionData.setMonitorCyclingTime(selectedMonitorName, text); } else { - SessionData.setWallpaperCyclingTime(text) + SessionData.setWallpaperCyclingTime(text); } } else { if (SessionData.perMonitorWallpaper) { - text = SessionData.getMonitorCyclingSettings(selectedMonitorName).time + text = SessionData.getMonitorCyclingSettings(selectedMonitorName).time; } else { - text = SessionData.wallpaperCyclingTime + text = SessionData.wallpaperCyclingTime; } } } @@ -1344,12 +1344,12 @@ Item { function onSelectedMonitorNameChanged() { // Force text field to refresh its value Qt.callLater(() => { - if (SessionData.perMonitorWallpaper) { - timeTextField.text = SessionData.getMonitorCyclingSettings(selectedMonitorName).time - } else { - timeTextField.text = SessionData.wallpaperCyclingTime - } - }) + if (SessionData.perMonitorWallpaper) { + timeTextField.text = SessionData.getMonitorCyclingSettings(selectedMonitorName).time; + } else { + timeTextField.text = SessionData.wallpaperCyclingTime; + } + }); } } } @@ -1376,14 +1376,14 @@ Item { description: I18n.tr("Visual effect used when wallpaper changes") currentValue: { if (SessionData.wallpaperTransition === "random") - return "Random" - return SessionData.wallpaperTransition.charAt(0).toUpperCase() + SessionData.wallpaperTransition.slice(1) + return "Random"; + return SessionData.wallpaperTransition.charAt(0).toUpperCase() + SessionData.wallpaperTransition.slice(1); } options: ["Random"].concat(SessionData.availableWallpaperTransitions.map(t => t.charAt(0).toUpperCase() + t.slice(1))) onValueChanged: value => { - var transition = value.toLowerCase() - SessionData.setWallpaperTransition(transition) - } + var transition = value.toLowerCase(); + SessionData.setWallpaperTransition(transition); + } } Column { @@ -1415,17 +1415,17 @@ Item { currentSelection: SessionData.includedTransitions onSelectionChanged: (index, selected) => { - const transition = model[index] - let newIncluded = [...SessionData.includedTransitions] + const transition = model[index]; + let newIncluded = [...SessionData.includedTransitions]; - if (selected && !newIncluded.includes(transition)) { - newIncluded.push(transition) - } else if (!selected && newIncluded.includes(transition)) { - newIncluded = newIncluded.filter(t => t !== transition) - } + if (selected && !newIncluded.includes(transition)) { + newIncluded.push(transition); + } else if (!selected && newIncluded.includes(transition)) { + newIncluded = newIncluded.filter(t => t !== transition); + } - SessionData.includedTransitions = newIncluded - } + SessionData.includedTransitions = newIncluded; + } } } } @@ -1485,8 +1485,8 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.blurredWallpaperLayer onToggled: checked => { - SettingsData.set("blurredWallpaperLayer", checked) - } + SettingsData.set("blurredWallpaperLayer", checked); + } } } } @@ -1542,9 +1542,9 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SessionData.isLightMode onToggleCompleted: checked => { - Theme.screenTransition() - Theme.setLightMode(checked) - } + Theme.screenTransition(); + Theme.setLightMode(checked); + } } } } @@ -1596,15 +1596,15 @@ Item { selectionMode: "single" currentIndex: SettingsData.animationSpeed onSelectionChanged: (index, selected) => { - if (selected) { - SettingsData.set("animationSpeed", index) - } - } + if (selected) { + SettingsData.set("animationSpeed", index); + } + } Connections { target: SettingsData function onAnimationSpeedChanged() { - animationSpeedGroup.currentIndex = SettingsData.animationSpeed + animationSpeedGroup.currentIndex = SettingsData.animationSpeed; } } } @@ -1678,15 +1678,15 @@ Item { wheelEnabled: false onSliderValueChanged: newValue => { - SettingsData.set("animationSpeed", SettingsData.AnimationSpeed.Custom) - SettingsData.set("customAnimationDuration", newValue) - } + SettingsData.set("animationSpeed", SettingsData.AnimationSpeed.Custom); + SettingsData.set("customAnimationDuration", newValue); + } Connections { target: SettingsData function onAnimationSpeedChanged() { if (SettingsData.animationSpeed !== SettingsData.AnimationSpeed.Custom) { - customDurationSlider.value = Theme.currentAnimationBaseDuration + customDurationSlider.value = Theme.currentAnimationBaseDuration; } } } @@ -1695,7 +1695,7 @@ Item { target: Theme function onCurrentAnimationBaseDurationChanged() { if (SettingsData.animationSpeed !== SettingsData.AnimationSpeed.Custom) { - customDurationSlider.value = Theme.currentAnimationBaseDuration + customDurationSlider.value = Theme.currentAnimationBaseDuration; } } } @@ -1796,11 +1796,11 @@ Item { checked: Theme.wallpaperPath !== "" && Theme.currentTheme === Theme.dynamic enabled: ToastService.wallpaperErrorStatus !== "matugen_missing" && Theme.wallpaperPath !== "" onToggled: toggled => { - if (toggled) - Theme.switchTheme(Theme.dynamic) - else - Theme.switchTheme("blue") - } + if (toggled) + Theme.switchTheme(Theme.dynamic); + else + Theme.switchTheme("blue"); + } } } @@ -1809,26 +1809,26 @@ Item { text: I18n.tr("Matugen Palette") description: I18n.tr("Select the palette algorithm used for wallpaper-based colors") options: Theme.availableMatugenSchemes.map(function (option) { - return option.label + return option.label; }) currentValue: Theme.getMatugenScheme(SettingsData.matugenScheme).label enabled: Theme.matugenAvailable opacity: enabled ? 1 : 0.4 onValueChanged: value => { - for (var i = 0; i < Theme.availableMatugenSchemes.length; i++) { - var option = Theme.availableMatugenSchemes[i] - if (option.label === value) { - SettingsData.setMatugenScheme(option.value) - break - } - } - } + for (var i = 0; i < Theme.availableMatugenSchemes.length; i++) { + var option = Theme.availableMatugenSchemes[i]; + if (option.label === value) { + SettingsData.setMatugenScheme(option.value); + break; + } + } + } } StyledText { text: { - var scheme = Theme.getMatugenScheme(SettingsData.matugenScheme) - return scheme.description + " (" + scheme.value + ")" + var scheme = Theme.getMatugenScheme(SettingsData.matugenScheme); + return scheme.description + " (" + scheme.value + ")"; } font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceVariantText @@ -1881,8 +1881,8 @@ Item { checked: SettingsData.runUserMatugenTemplates enabled: Theme.matugenAvailable onToggled: checked => { - SettingsData.setRunUserMatugenTemplates(checked) - } + SettingsData.setRunUserMatugenTemplates(checked); + } } } @@ -1950,8 +1950,8 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.soundsEnabled onToggled: checked => { - SettingsData.set("soundsEnabled", checked) - } + SettingsData.set("soundsEnabled", checked); + } } } @@ -1998,8 +1998,8 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.useSystemSoundTheme onToggled: checked => { - SettingsData.set("useSystemSoundTheme", checked) - } + SettingsData.set("useSystemSoundTheme", checked); + } } } @@ -2013,17 +2013,17 @@ Item { enabled: SettingsData.useSystemSoundTheme && AudioService.availableSoundThemes.length > 0 options: AudioService.availableSoundThemes currentValue: { - const theme = AudioService.currentSoundTheme + const theme = AudioService.currentSoundTheme; if (theme && AudioService.availableSoundThemes.includes(theme)) { - return theme + return theme; } - return AudioService.availableSoundThemes.length > 0 ? AudioService.availableSoundThemes[0] : "" + return AudioService.availableSoundThemes.length > 0 ? AudioService.availableSoundThemes[0] : ""; } onValueChanged: value => { - if (value && value !== AudioService.currentSoundTheme) { - AudioService.setSoundTheme(value) - } - } + if (value && value !== AudioService.currentSoundTheme) { + AudioService.setSoundTheme(value); + } + } } Rectangle { @@ -2063,8 +2063,8 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.soundNewNotification onToggled: checked => { - SettingsData.set("soundNewNotification", checked) - } + SettingsData.set("soundNewNotification", checked); + } } } @@ -2097,8 +2097,8 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.soundVolumeChanged onToggled: checked => { - SettingsData.set("soundVolumeChanged", checked) - } + SettingsData.set("soundVolumeChanged", checked); + } } } @@ -2132,8 +2132,8 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.soundPluggedIn onToggled: checked => { - SettingsData.set("soundPluggedIn", checked) - } + SettingsData.set("soundPluggedIn", checked); + } } } } @@ -2150,7 +2150,7 @@ Item { sourceComponent: FileBrowserModal { parentModal: personalizationTab.parentModal Component.onCompleted: { - open() + open(); } browserTitle: I18n.tr("Select Wallpaper", "wallpaper file browser title") browserIcon: "wallpaper" @@ -2158,15 +2158,15 @@ Item { showHiddenFiles: true fileExtensions: ["*.jpg", "*.jpeg", "*.png", "*.bmp", "*.gif", "*.webp"] onFileSelected: path => { - if (SessionData.perMonitorWallpaper) { - SessionData.setMonitorWallpaper(selectedMonitorName, path) - } else { - SessionData.setWallpaper(path) - } - close() - } + if (SessionData.perMonitorWallpaper) { + SessionData.setMonitorWallpaper(selectedMonitorName, path); + } else { + SessionData.setWallpaper(path); + } + close(); + } onDialogClosed: { - Qt.callLater(() => wallpaperBrowserLoader.active = false) + Qt.callLater(() => wallpaperBrowserLoader.active = false); } } } @@ -2179,7 +2179,7 @@ Item { sourceComponent: FileBrowserModal { parentModal: personalizationTab.parentModal Component.onCompleted: { - open() + open(); } browserTitle: I18n.tr("Select Wallpaper", "light mode wallpaper file browser title") browserIcon: "light_mode" @@ -2187,13 +2187,13 @@ Item { showHiddenFiles: true fileExtensions: ["*.jpg", "*.jpeg", "*.png", "*.bmp", "*.gif", "*.webp"] onFileSelected: path => { - SessionData.wallpaperPathLight = path - SessionData.syncWallpaperForCurrentMode() - SessionData.saveSettings() - close() - } + SessionData.wallpaperPathLight = path; + SessionData.syncWallpaperForCurrentMode(); + SessionData.saveSettings(); + close(); + } onDialogClosed: { - Qt.callLater(() => lightWallpaperBrowserLoader.active = false) + Qt.callLater(() => lightWallpaperBrowserLoader.active = false); } } } @@ -2206,7 +2206,7 @@ Item { sourceComponent: FileBrowserModal { parentModal: personalizationTab.parentModal Component.onCompleted: { - open() + open(); } browserTitle: I18n.tr("Select Wallpaper", "dark mode wallpaper file browser title") browserIcon: "dark_mode" @@ -2214,13 +2214,13 @@ Item { showHiddenFiles: true fileExtensions: ["*.jpg", "*.jpeg", "*.png", "*.bmp", "*.gif", "*.webp"] onFileSelected: path => { - SessionData.wallpaperPathDark = path - SessionData.syncWallpaperForCurrentMode() - SessionData.saveSettings() - close() - } + SessionData.wallpaperPathDark = path; + SessionData.syncWallpaperForCurrentMode(); + SessionData.saveSettings(); + close(); + } onDialogClosed: { - Qt.callLater(() => darkWallpaperBrowserLoader.active = false) + Qt.callLater(() => darkWallpaperBrowserLoader.active = false); } } } diff --git a/quickshell/Modules/Settings/ThemeColorsTab.qml b/quickshell/Modules/Settings/ThemeColorsTab.qml index beb04ede..92daaa14 100644 --- a/quickshell/Modules/Settings/ThemeColorsTab.qml +++ b/quickshell/Modules/Settings/ThemeColorsTab.qml @@ -1,10 +1,7 @@ import QtQuick -import QtQuick.Controls import QtQuick.Effects import Quickshell -import Quickshell.Io import qs.Common -import qs.Modals import qs.Modals.FileBrowser import qs.Services import qs.Widgets @@ -19,47 +16,44 @@ Item { property bool fontsEnumerated: false function enumerateFonts() { - var fonts = [] - var availableFonts = Qt.fontFamilies() + var fonts = []; + var availableFonts = Qt.fontFamilies(); for (var i = 0; i < availableFonts.length; i++) { - var fontName = availableFonts[i] + var fontName = availableFonts[i]; if (fontName.startsWith(".")) - continue - fonts.push(fontName) + continue; + fonts.push(fontName); } - fonts.sort() - fonts.unshift("Default") - cachedFontFamilies = fonts + fonts.sort(); + fonts.unshift("Default"); + cachedFontFamilies = fonts; - var monoFonts = [] + var monoFonts = []; for (var j = 0; j < availableFonts.length; j++) { - var fontName2 = availableFonts[j] + var fontName2 = availableFonts[j]; if (fontName2.startsWith(".")) - continue - - var lowerName = fontName2.toLowerCase() - if (lowerName.includes("mono") || lowerName.includes("code") || - lowerName.includes("console") || lowerName.includes("terminal") || - lowerName.includes("courier") || lowerName.includes("jetbrains") || - lowerName.includes("fira") || lowerName.includes("hack") || - lowerName.includes("source code") || lowerName.includes("cascadia")) { - monoFonts.push(fontName2) + continue; + var lowerName = fontName2.toLowerCase(); + if (lowerName.includes("mono") || lowerName.includes("code") || lowerName.includes("console") || lowerName.includes("terminal") || lowerName.includes("courier") || lowerName.includes("jetbrains") || lowerName.includes("fira") || lowerName.includes("hack") || lowerName.includes("source code") || lowerName.includes("cascadia")) { + monoFonts.push(fontName2); } } - monoFonts.sort() - monoFonts.unshift("Default") - cachedMonoFamilies = monoFonts + monoFonts.sort(); + monoFonts.unshift("Default"); + cachedMonoFamilies = monoFonts; } Component.onCompleted: { if (!fontsEnumerated) { - enumerateFonts() - fontsEnumerated = true + enumerateFonts(); + fontsEnumerated = true; } - SettingsData.detectAvailableIconThemes() - cachedIconThemes = SettingsData.availableIconThemes - cachedMatugenSchemes = Theme.availableMatugenSchemes.map(function (option) { return option.label }) + SettingsData.detectAvailableIconThemes(); + cachedIconThemes = SettingsData.availableIconThemes; + cachedMatugenSchemes = Theme.availableMatugenSchemes.map(function (option) { + return option.label; + }); } DankFlickable { @@ -74,15 +68,13 @@ Item { width: parent.width spacing: Theme.spacingXL - // Theme Color StyledRect { width: parent.width height: themeSection.implicitHeight + Theme.spacingL * 2 radius: Theme.cornerRadius color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) - border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, - Theme.outline.b, 0.2) + border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) border.width: 0 Column { @@ -119,11 +111,11 @@ Item { StyledText { text: { if (Theme.currentTheme === Theme.dynamic) { - return "Current Theme: Dynamic" + return "Current Theme: Dynamic"; } else if (Theme.currentThemeCategory === "catppuccin") { - return "Current Theme: Catppuccin " + Theme.getThemeColors(Theme.currentThemeName).name + return "Current Theme: Catppuccin " + Theme.getThemeColors(Theme.currentThemeName).name; } else { - return "Current Theme: " + Theme.getThemeColors(Theme.currentThemeName).name + return "Current Theme: " + Theme.getThemeColors(Theme.currentThemeName).name; } } font.pixelSize: Theme.fontSizeMedium @@ -135,15 +127,15 @@ Item { StyledText { text: { if (Theme.currentTheme === Theme.dynamic) { - return "Material colors generated from wallpaper" + return "Material colors generated from wallpaper"; } if (Theme.currentThemeCategory === "catppuccin") { - return "Soothing pastel theme based on Catppuccin" + return "Soothing pastel theme based on Catppuccin"; } if (Theme.currentTheme === Theme.custom) { - return "Custom theme loaded from JSON file" + return "Custom theme loaded from JSON file"; } - return "Material Design inspired color themes" + return "Material Design inspired color themes"; } font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceVariantText @@ -154,17 +146,19 @@ Item { } } - Column { spacing: Theme.spacingM anchors.horizontalCenter: parent.horizontalCenter DankButtonGroup { property int currentThemeIndex: { - if (Theme.currentTheme === Theme.dynamic) return 2 - if (Theme.currentThemeName === "custom") return 3 - if (Theme.currentThemeCategory === "catppuccin") return 1 - return 0 + if (Theme.currentTheme === Theme.dynamic) + return 2; + if (Theme.currentThemeName === "custom") + return 3; + if (Theme.currentThemeCategory === "catppuccin") + return 1; + return 0; } property int pendingThemeIndex: -1 @@ -173,29 +167,35 @@ Item { selectionMode: "single" anchors.horizontalCenter: parent.horizontalCenter onSelectionChanged: (index, selected) => { - if (!selected) return - pendingThemeIndex = index + if (!selected) + return; + pendingThemeIndex = index; } onAnimationCompleted: { - if (pendingThemeIndex === -1) return + if (pendingThemeIndex === -1) + return; switch (pendingThemeIndex) { - case 0: Theme.switchThemeCategory("generic", "blue"); break - case 1: Theme.switchThemeCategory("catppuccin", "cat-mauve"); break - case 2: - if (ToastService.wallpaperErrorStatus === "matugen_missing") - ToastService.showError("matugen not found - install matugen package for dynamic theming") - else if (ToastService.wallpaperErrorStatus === "error") - ToastService.showError("Wallpaper processing failed - check wallpaper path") - else - Theme.switchTheme(Theme.dynamic, true, true) - break - case 3: - if (Theme.currentThemeName !== "custom") { - Theme.switchTheme("custom", true, true) - } - break + case 0: + Theme.switchThemeCategory("generic", "blue"); + break; + case 1: + Theme.switchThemeCategory("catppuccin", "cat-mauve"); + break; + case 2: + if (ToastService.wallpaperErrorStatus === "matugen_missing") + ToastService.showError("matugen not found - install matugen package for dynamic theming"); + else if (ToastService.wallpaperErrorStatus === "error") + ToastService.showError("Wallpaper processing failed - check wallpaper path"); + else + Theme.switchTheme(Theme.dynamic, true, true); + break; + case 3: + if (Theme.currentThemeName !== "custom") { + Theme.switchTheme("custom", true, true); + } + break; } - pendingThemeIndex = -1 + pendingThemeIndex = -1; } } @@ -248,7 +248,7 @@ Item { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - Theme.switchTheme(themeName) + Theme.switchTheme(themeName); } } @@ -313,7 +313,7 @@ Item { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - Theme.switchTheme(themeName) + Theme.switchTheme(themeName); } } @@ -384,7 +384,7 @@ Item { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - Theme.switchTheme(themeName) + Theme.switchTheme(themeName); } } @@ -449,7 +449,7 @@ Item { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - Theme.switchTheme(themeName) + Theme.switchTheme(themeName); } } @@ -525,16 +525,16 @@ Item { anchors.centerIn: parent name: { if (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing") - return "error" + return "error"; else - return "palette" + return "palette"; } size: Theme.iconSizeLarge color: { if (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing") - return Theme.error + return Theme.error; else - return Theme.surfaceVariantText + return Theme.surfaceVariantText; } visible: !Theme.wallpaperPath } @@ -548,13 +548,13 @@ Item { StyledText { text: { if (ToastService.wallpaperErrorStatus === "error") - return "Wallpaper Error" + return "Wallpaper Error"; else if (ToastService.wallpaperErrorStatus === "matugen_missing") - return "Matugen Missing" + return "Matugen Missing"; else if (Theme.wallpaperPath) - return Theme.wallpaperPath.split('/').pop() + return Theme.wallpaperPath.split('/').pop(); else - return "No wallpaper selected" + return "No wallpaper selected"; } font.pixelSize: Theme.fontSizeLarge color: Theme.surfaceText @@ -566,20 +566,20 @@ Item { StyledText { text: { if (ToastService.wallpaperErrorStatus === "error") - return "Wallpaper processing failed" + return "Wallpaper processing failed"; else if (ToastService.wallpaperErrorStatus === "matugen_missing") - return "Install matugen package for dynamic theming" + return "Install matugen package for dynamic theming"; else if (Theme.wallpaperPath) - return Theme.wallpaperPath + return Theme.wallpaperPath; else - return "Dynamic colors from wallpaper" + return "Dynamic colors from wallpaper"; } font.pixelSize: Theme.fontSizeSmall color: { if (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing") - return Theme.error + return Theme.error; else - return Theme.surfaceVariantText + return Theme.surfaceVariantText; } elide: Text.ElideMiddle maximumLineCount: 2 @@ -599,10 +599,10 @@ Item { opacity: enabled ? 1 : 0.4 onValueChanged: value => { for (var i = 0; i < Theme.availableMatugenSchemes.length; i++) { - var option = Theme.availableMatugenSchemes[i] + var option = Theme.availableMatugenSchemes[i]; if (option.label === value) { - SettingsData.setMatugenScheme(option.value) - break + SettingsData.setMatugenScheme(option.value); + break; } } } @@ -610,8 +610,8 @@ Item { StyledText { text: { - var scheme = Theme.getMatugenScheme(SettingsData.matugenScheme) - return scheme.description + " (" + scheme.value + ")" + var scheme = Theme.getMatugenScheme(SettingsData.matugenScheme); + return scheme.description + " (" + scheme.value + ")"; } font.pixelSize: Theme.fontSizeSmall color: Theme.surfaceVariantText @@ -673,8 +673,7 @@ Item { height: transparencySection.implicitHeight + Theme.spacingL * 2 radius: Theme.cornerRadius color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) - border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, - Theme.outline.b, 0.2) + border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) border.width: 0 Column { @@ -736,9 +735,12 @@ Item { id: widgetColorModeGroup property int currentColorModeIndex: { switch (SettingsData.widgetColorMode) { - case "default": return 0 - case "colorful": return 1 - default: return 0 + case "default": + return 0; + case "colorful": + return 1; + default: + return 0; } } @@ -748,9 +750,10 @@ Item { anchors.verticalCenter: parent.verticalCenter onSelectionChanged: (index, selected) => { - if (!selected) return - const colorModeOptions = ["default", "colorful"] - SettingsData.set("widgetColorMode", colorModeOptions[index]) + if (!selected) + return; + const colorModeOptions = ["default", "colorful"]; + SettingsData.set("widgetColorMode", colorModeOptions[index]); } } } @@ -790,11 +793,16 @@ Item { id: widgetColorGroup property int currentColorIndex: { switch (SettingsData.widgetBackgroundColor) { - case "sth": return 0 - case "s": return 1 - case "sc": return 2 - case "sch": return 3 - default: return 0 + case "sth": + return 0; + case "s": + return 1; + case "sc": + return 2; + case "sch": + return 3; + default: + return 0; } } @@ -812,9 +820,10 @@ Item { spacing: 1 onSelectionChanged: (index, selected) => { - if (!selected) return - const colorOptions = ["sth", "s", "sc", "sch"] - SettingsData.set("widgetBackgroundColor", colorOptions[index]) + if (!selected) + return; + const colorOptions = ["sth", "s", "sc", "sch"]; + SettingsData.set("widgetBackgroundColor", colorOptions[index]); } } } @@ -842,8 +851,7 @@ Item { DankSlider { width: parent.width height: 24 - value: Math.round( - SettingsData.popupTransparency * 100) + value: Math.round(SettingsData.popupTransparency * 100) minimum: 0 maximum: 100 unit: "" @@ -851,9 +859,8 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.set("popupTransparency", - newValue / 100) - } + SettingsData.set("popupTransparency", newValue / 100); + } } } @@ -886,9 +893,8 @@ Item { wheelEnabled: false thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) onSliderValueChanged: newValue => { - SettingsData.setCornerRadius( - newValue) - } + SettingsData.setCornerRadius(newValue); + } } } @@ -930,7 +936,7 @@ Item { anchors.verticalCenter: parent.verticalCenter checked: SettingsData.modalDarkenBackground onToggled: checked => { - SettingsData.set("modalDarkenBackground", checked) + SettingsData.set("modalDarkenBackground", checked); } } } @@ -942,8 +948,7 @@ Item { height: fontSection.implicitHeight + Theme.spacingL * 2 radius: Theme.cornerRadius color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) - border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, - Theme.outline.b, 0.2) + border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) border.width: 0 Column { @@ -977,21 +982,21 @@ Item { text: I18n.tr("Font Family") description: I18n.tr("Select system font family") currentValue: { - if (SettingsData.fontFamily === SettingsData.defaultFontFamily) - return "Default" + if (SettingsData.fontFamily === Theme.defaultFontFamily) + return "Default"; else - return SettingsData.fontFamily || "Default" + return SettingsData.fontFamily || "Default"; } enableFuzzySearch: true popupWidthOffset: 100 maxPopupHeight: 400 options: cachedFontFamilies onValueChanged: value => { - if (value.startsWith("Default")) - SettingsData.set("fontFamily", SettingsData.defaultFontFamily) - else - SettingsData.set("fontFamily", value) - } + if (value.startsWith("Default")) + SettingsData.set("fontFamily", Theme.defaultFontFamily); + else + SettingsData.set("fontFamily", value); + } } DankDropdown { @@ -1000,64 +1005,64 @@ Item { currentValue: { switch (SettingsData.fontWeight) { case Font.Thin: - return "Thin" + return "Thin"; case Font.ExtraLight: - return "Extra Light" + return "Extra Light"; case Font.Light: - return "Light" + return "Light"; case Font.Normal: - return "Regular" + return "Regular"; case Font.Medium: - return "Medium" + return "Medium"; case Font.DemiBold: - return "Demi Bold" + return "Demi Bold"; case Font.Bold: - return "Bold" + return "Bold"; case Font.ExtraBold: - return "Extra Bold" + return "Extra Bold"; case Font.Black: - return "Black" + return "Black"; default: - return "Regular" + return "Regular"; } } options: ["Thin", "Extra Light", "Light", "Regular", "Medium", "Demi Bold", "Bold", "Extra Bold", "Black"] onValueChanged: value => { - var weight - switch (value) { - case "Thin": - weight = Font.Thin - break - case "Extra Light": - weight = Font.ExtraLight - break - case "Light": - weight = Font.Light - break - case "Regular": - weight = Font.Normal - break - case "Medium": - weight = Font.Medium - break - case "Demi Bold": - weight = Font.DemiBold - break - case "Bold": - weight = Font.Bold - break - case "Extra Bold": - weight = Font.ExtraBold - break - case "Black": - weight = Font.Black - break - default: - weight = Font.Normal - break - } - SettingsData.set("fontWeight", weight) - } + var weight; + switch (value) { + case "Thin": + weight = Font.Thin; + break; + case "Extra Light": + weight = Font.ExtraLight; + break; + case "Light": + weight = Font.Light; + break; + case "Regular": + weight = Font.Normal; + break; + case "Medium": + weight = Font.Medium; + break; + case "Demi Bold": + weight = Font.DemiBold; + break; + case "Bold": + weight = Font.Bold; + break; + case "Extra Bold": + weight = Font.ExtraBold; + break; + case "Black": + weight = Font.Black; + break; + default: + weight = Font.Normal; + break; + } + SettingsData.set("fontWeight", weight); + } } DankDropdown { @@ -1065,20 +1070,20 @@ Item { description: I18n.tr("Select monospace font for process list and technical displays") currentValue: { if (SettingsData.monoFontFamily === SettingsData.defaultMonoFontFamily) - return "Default" + return "Default"; - return SettingsData.monoFontFamily || "Default" + return SettingsData.monoFontFamily || "Default"; } enableFuzzySearch: true popupWidthOffset: 100 maxPopupHeight: 400 options: cachedMonoFamilies onValueChanged: value => { - if (value === "Default") - SettingsData.set("monoFontFamily", SettingsData.defaultMonoFontFamily) - else - SettingsData.set("monoFontFamily", value) - } + if (value === "Default") + SettingsData.set("monoFontFamily", SettingsData.defaultMonoFontFamily); + else + SettingsData.set("monoFontFamily", value); + } } Rectangle { @@ -1126,8 +1131,8 @@ Item { backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) iconColor: Theme.surfaceText onClicked: { - var newScale = Math.max(1.0, SettingsData.fontScale - 0.05) - SettingsData.set("fontScale", newScale) + var newScale = Math.max(1.0, SettingsData.fontScale - 0.05); + SettingsData.set("fontScale", newScale); } } @@ -1136,15 +1141,12 @@ Item { height: 32 radius: Theme.cornerRadius color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) - border.color: Qt.rgba(Theme.outline.r, - Theme.outline.g, - Theme.outline.b, 0.2) + border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) border.width: 0 StyledText { anchors.centerIn: parent - text: (SettingsData.fontScale * 100).toFixed( - 0) + "%" + text: (SettingsData.fontScale * 100).toFixed(0) + "%" font.pixelSize: Theme.fontSizeSmall font.weight: Font.Medium color: Theme.surfaceText @@ -1159,9 +1161,8 @@ Item { backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) iconColor: Theme.surfaceText onClicked: { - var newScale = Math.min(2.0, - SettingsData.fontScale + 0.05) - SettingsData.set("fontScale", newScale) + var newScale = Math.min(2.0, SettingsData.fontScale + 0.05); + SettingsData.set("fontScale", newScale); } } } @@ -1174,8 +1175,7 @@ Item { height: applicationsSection.implicitHeight + Theme.spacingL * 2 radius: Theme.cornerRadius color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) - border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, - Theme.outline.b, 0.2) + border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) border.width: 0 Column { @@ -1211,7 +1211,7 @@ Item { description: I18n.tr("Sync dark mode with settings portals for system-wide theme hints") checked: SettingsData.syncModeWithPortal onToggled: checked => { - return SettingsData.set("syncModeWithPortal", checked) + return SettingsData.set("syncModeWithPortal", checked); } } @@ -1221,7 +1221,7 @@ Item { description: I18n.tr("Force terminal applications to always use dark color schemes") checked: SettingsData.terminalsAlwaysDark onToggled: checked => { - return SettingsData.set("terminalsAlwaysDark", checked) + return SettingsData.set("terminalsAlwaysDark", checked); } } } @@ -1231,10 +1231,8 @@ Item { width: parent.width height: warningText.implicitHeight + Theme.spacingM * 2 radius: Theme.cornerRadius - color: Qt.rgba(Theme.warning.r, Theme.warning.g, - Theme.warning.b, 0.12) - border.color: Qt.rgba(Theme.warning.r, Theme.warning.g, - Theme.warning.b, 0.3) + color: Qt.rgba(Theme.warning.r, Theme.warning.g, Theme.warning.b, 0.12) + border.color: Qt.rgba(Theme.warning.r, Theme.warning.g, Theme.warning.b, 0.3) border.width: 0 Row { @@ -1266,8 +1264,7 @@ Item { height: iconThemeSection.implicitHeight + Theme.spacingL * 2 radius: Theme.cornerRadius color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) - border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, - Theme.outline.b, 0.2) + border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) border.width: 0 Column { @@ -1299,13 +1296,11 @@ Item { maxPopupHeight: 236 options: cachedIconThemes onValueChanged: value => { - SettingsData.setIconTheme(value) - if (Quickshell.env("QT_QPA_PLATFORMTHEME") != "gtk3" && - Quickshell.env("QT_QPA_PLATFORMTHEME") != "qt6ct" && - Quickshell.env("QT_QPA_PLATFORMTHEME_QT6") != "qt6ct") { - ToastService.showError("Missing Environment Variables", "You need to set either:\nQT_QPA_PLATFORMTHEME=gtk3 OR\nQT_QPA_PLATFORMTHEME=qt6ct\nas environment variables, and then restart the shell.\n\nqt6ct requires qt6ct-kde to be installed.") - } - } + SettingsData.setIconTheme(value); + if (Quickshell.env("QT_QPA_PLATFORMTHEME") != "gtk3" && Quickshell.env("QT_QPA_PLATFORMTHEME") != "qt6ct" && Quickshell.env("QT_QPA_PLATFORMTHEME_QT6") != "qt6ct") { + ToastService.showError("Missing Environment Variables", "You need to set either:\nQT_QPA_PLATFORMTHEME=gtk3 OR\nQT_QPA_PLATFORMTHEME=qt6ct\nas environment variables, and then restart the shell.\n\nqt6ct requires qt6ct-kde to be installed."); + } + } } } } @@ -1317,8 +1312,7 @@ Item { height: systemThemingSection.implicitHeight + Theme.spacingL * 2 radius: Theme.cornerRadius color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) - border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, - Theme.outline.b, 0.2) + border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) border.width: 0 visible: Theme.matugenAvailable @@ -1446,7 +1440,6 @@ Item { } } } - } } @@ -1457,14 +1450,14 @@ Item { showHiddenFiles: true function selectCustomTheme() { - shouldBeVisible = true + shouldBeVisible = true; } - onFileSelected: function(filePath) { + onFileSelected: function (filePath) { if (filePath.endsWith(".json")) { - SettingsData.set("customThemeFile", filePath) - Theme.switchTheme("custom") - close() + SettingsData.set("customThemeFile", filePath); + Theme.switchTheme("custom"); + close(); } } } diff --git a/quickshell/Widgets/StyledText.qml b/quickshell/Widgets/StyledText.qml index 888dc9d7..3c07ab1f 100644 --- a/quickshell/Widgets/StyledText.qml +++ b/quickshell/Widgets/StyledText.qml @@ -1,6 +1,5 @@ import QtQuick import qs.Common -import qs.Services Text { property bool isMonospace: false @@ -16,13 +15,13 @@ Text { } readonly property string resolvedFontFamily: { - const requestedFont = isMonospace ? Theme.monoFontFamily : Theme.fontFamily - const defaultFont = isMonospace ? "Fira Code" : "Inter Variable" + const requestedFont = isMonospace ? Theme.monoFontFamily : Theme.fontFamily; + const defaultFont = isMonospace ? Theme.defaultMonoFontFamily : Theme.defaultFontFamily; if (requestedFont === defaultFont) { - return isMonospace ? firaCodeFont.name : interFont.name + return isMonospace ? firaCodeFont.name : interFont.name; } - return requestedFont + return requestedFont; } readonly property var standardAnimation: { @@ -47,4 +46,4 @@ Text { easing.bezierCurve: standardAnimation["easing.bezierCurve"] } } -} \ No newline at end of file +} diff --git a/quickshell/Widgets/StyledTextMetrics.qml b/quickshell/Widgets/StyledTextMetrics.qml index de1146b9..b2973852 100644 --- a/quickshell/Widgets/StyledTextMetrics.qml +++ b/quickshell/Widgets/StyledTextMetrics.qml @@ -6,19 +6,19 @@ TextMetrics { property bool isMonospace: false readonly property string resolvedFontFamily: { - const requestedFont = isMonospace ? SettingsData.monoFontFamily : SettingsData.fontFamily - const defaultFont = isMonospace ? SettingsData.defaultMonoFontFamily : SettingsData.defaultFontFamily + const requestedFont = isMonospace ? SettingsData.monoFontFamily : SettingsData.fontFamily; + const defaultFont = isMonospace ? Theme.defaultMonoFontFamily : Theme.defaultFontFamily; if (requestedFont === defaultFont) { - const availableFonts = Qt.fontFamilies() + const availableFonts = Qt.fontFamilies(); if (!availableFonts.includes(requestedFont)) { - return isMonospace ? "Monospace" : "DejaVu Sans" + return isMonospace ? "Monospace" : "DejaVu Sans"; } } - return requestedFont + return requestedFont; } font.pixelSize: Appearance.fontSize.normal font.family: resolvedFontFamily font.weight: SettingsData.fontWeight -} \ No newline at end of file +}