diff --git a/dank-qml-common b/dank-qml-common index 83518beaf..3373281fd 160000 --- a/dank-qml-common +++ b/dank-qml-common @@ -1 +1 @@ -Subproject commit 83518beaf2c28b87ca0b3862eceeb0917a6c47a0 +Subproject commit 3373281fdba24e030ef47325f9db01494780a4a3 diff --git a/flake.lock b/flake.lock index 1440d5973..8784a1229 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "dank-qml-common": { "flake": false, "locked": { - "lastModified": 1786309712, - "narHash": "sha256-VMUI9bvzHOXdyp99EoJ917KgsV9AaEg9dMVL6Xh+w4M=", + "lastModified": 1786649745, + "narHash": "sha256-61G4G6nQqSV4DWNyZAYlZOLAY6+Ug+JQA1SaifacaSI=", "owner": "AvengeMedia", "repo": "dank-qml-common", - "rev": "83518beaf2c28b87ca0b3862eceeb0917a6c47a0", + "rev": "3373281fdba24e030ef47325f9db01494780a4a3", "type": "github" }, "original": { diff --git a/quickshell/Common/SessionData.qml b/quickshell/Common/SessionData.qml index 2bd1e8021..8e7b76b1f 100644 --- a/quickshell/Common/SessionData.qml +++ b/quickshell/Common/SessionData.qml @@ -167,6 +167,7 @@ Singleton { property real longitude: 0.0 property bool nightModeUseIPLocation: false property string nightModeLocationProvider: "" + property string nightModeLocationName: "" property bool themeModeAutoEnabled: false property string themeModeAutoMode: "time" @@ -1048,6 +1049,11 @@ Singleton { saveSettings(); } + function setNightModeLocationName(name) { + nightModeLocationName = name; + saveSettings(); + } + function setThemeModeAutoEnabled(enabled) { themeModeAutoEnabled = enabled; saveSettings(); diff --git a/quickshell/Common/settings/SessionSpec.js b/quickshell/Common/settings/SessionSpec.js index 00f6d1904..15d555493 100644 --- a/quickshell/Common/settings/SessionSpec.js +++ b/quickshell/Common/settings/SessionSpec.js @@ -38,6 +38,7 @@ var SPEC = { longitude: { def: 0.0 }, nightModeUseIPLocation: { def: false }, nightModeLocationProvider: { def: "" }, + nightModeLocationName: { def: "" }, themeModeAutoEnabled: { def: false }, themeModeAutoMode: { def: "time" }, diff --git a/quickshell/Modules/Settings/ThemeColorsTab.qml b/quickshell/Modules/Settings/ThemeColorsTab.qml index 5df1f99a1..ccf3fe39d 100644 --- a/quickshell/Modules/Settings/ThemeColorsTab.qml +++ b/quickshell/Modules/Settings/ThemeColorsTab.qml @@ -1508,7 +1508,6 @@ Item { SettingsLocationSection { width: parent.width visible: SessionData.themeModeAutoMode === "location" && !SessionData.themeModeShareGammaSettings - centered: true description: I18n.tr("Uses sunrise/sunset times based on your location.") } diff --git a/quickshell/Modules/Settings/TimeWeatherTab.qml b/quickshell/Modules/Settings/TimeWeatherTab.qml index 648e59625..4c7973cf8 100644 --- a/quickshell/Modules/Settings/TimeWeatherTab.qml +++ b/quickshell/Modules/Settings/TimeWeatherTab.qml @@ -9,6 +9,8 @@ import qs.Modules.Settings.Widgets Item { id: root + property bool _internalChange: false + readonly property string _systemDefaultLabel: I18n.tr("System Default") function weekStartQt() { @@ -564,11 +566,13 @@ Item { keyNavigationTab: longitudeInput Component.onCompleted: { + root._internalChange = true; if (SettingsData.weatherCoordinates) { const coords = SettingsData.weatherCoordinates.split(','); if (coords.length > 0) text = coords[0].trim(); } + root._internalChange = false; } Connections { @@ -583,6 +587,8 @@ Item { } onTextEdited: { + if (root._internalChange) + return; if (text && longitudeInput.text) { const coords = text + "," + longitudeInput.text; SessionData.weatherCoordinates = coords; @@ -615,11 +621,13 @@ Item { keyNavigationBacktab: latitudeInput Component.onCompleted: { + root._internalChange = true; if (SettingsData.weatherCoordinates) { const coords = SettingsData.weatherCoordinates.split(','); if (coords.length > 1) text = coords[1].trim(); } + root._internalChange = false; } Connections { @@ -634,6 +642,8 @@ Item { } onTextEdited: { + if (root._internalChange) + return; if (text && latitudeInput.text) { const coords = latitudeInput.text + "," + text; SessionData.weatherCoordinates = coords; @@ -659,16 +669,18 @@ Item { DankLocationSearch { id: locationSearchInput width: parent.width - currentLocation: "" + currentLocation: SettingsData.weatherLocation placeholderText: I18n.tr("New York, NY") keyNavigationBacktab: longitudeInput onLocationSelected: (displayName, coordinates) => { + root._internalChange = true; SettingsData.setWeatherLocation(displayName, coordinates); const coords = coordinates.split(','); if (coords.length >= 2) { latitudeInput.text = coords[0].trim(); longitudeInput.text = coords[1].trim(); } + root._internalChange = false; } } } diff --git a/quickshell/Modules/Settings/Widgets/SettingsLocationSection.qml b/quickshell/Modules/Settings/Widgets/SettingsLocationSection.qml index 7a56c52f3..b47fb9557 100644 --- a/quickshell/Modules/Settings/Widgets/SettingsLocationSection.qml +++ b/quickshell/Modules/Settings/Widgets/SettingsLocationSection.qml @@ -8,7 +8,6 @@ Column { id: root property string description: I18n.tr("Uses sunrise/sunset times based on your location.") - property bool centered: false width: parent.width spacing: Theme.spacingM @@ -32,7 +31,8 @@ Column { } Column { - width: parent.width + width: parent.width - Theme.spacingM * 2 + x: Theme.spacingM spacing: Theme.spacingM visible: !SessionData.nightModeUseIPLocation @@ -40,15 +40,15 @@ Column { text: I18n.tr("Manual Coordinates") font.pixelSize: Theme.fontSizeMedium color: Theme.surfaceText - width: parent.width - horizontalAlignment: root.centered ? Text.AlignHCenter : Text.AlignLeft + font.weight: Font.Medium } Row { - spacing: Theme.spacingL - anchors.horizontalCenter: root.centered ? parent.horizontalCenter : undefined + width: parent.width + spacing: Theme.spacingM Column { + width: (parent.width - Theme.spacingM) / 2 spacing: Theme.spacingXS StyledText { @@ -59,10 +59,14 @@ Column { DankTextField { id: latitudeField - width: 120 - height: 40 + width: parent.width + height: 48 text: "" - placeholderText: "0.0" + placeholderText: "40.7128" + backgroundColor: Theme.surfaceVariant + normalBorderColor: Theme.primarySelected + focusedBorderColor: Theme.primary + keyNavigationTab: longitudeField Component.onCompleted: { text = SessionData.latitude.toString(); @@ -79,12 +83,14 @@ Column { const lat = parseFloat(text); if (!isNaN(lat) && lat >= -90 && lat <= 90 && lat !== SessionData.latitude) { SessionData.setLatitude(lat); + SessionData.setNightModeLocationName(""); } } } } Column { + width: (parent.width - Theme.spacingM) / 2 spacing: Theme.spacingXS StyledText { @@ -95,10 +101,14 @@ Column { DankTextField { id: longitudeField - width: 120 - height: 40 + width: parent.width + height: 48 text: "" - placeholderText: "0.0" + placeholderText: "-74.0060" + backgroundColor: Theme.surfaceVariant + normalBorderColor: Theme.primarySelected + focusedBorderColor: Theme.primary + keyNavigationBacktab: latitudeField Component.onCompleted: { text = SessionData.longitude.toString(); @@ -115,6 +125,7 @@ Column { const lon = parseFloat(text); if (!isNaN(lon) && lon >= -180 && lon <= 180 && lon !== SessionData.longitude) { SessionData.setLongitude(lon); + SessionData.setNightModeLocationName(""); } } } @@ -130,7 +141,9 @@ Column { DankLocationSearch { width: parent.width + currentLocation: SessionData.nightModeLocationName onLocationSelected: (displayName, coordinates) => { + SessionData.setNightModeLocationName(displayName); const coords = coordinates.split(','); if (coords.length >= 2) { const lat = parseFloat(coords[0]); @@ -153,7 +166,6 @@ Column { color: Theme.surfaceVariantText width: parent.width wrapMode: Text.WordWrap - horizontalAlignment: root.centered ? Text.AlignHCenter : Text.AlignLeft } } }