diff --git a/.config/quickshell/modules/common/ConfigOptions.qml b/.config/quickshell/modules/common/ConfigOptions.qml index 902049729..470f438df 100644 --- a/.config/quickshell/modules/common/ConfigOptions.qml +++ b/.config/quickshell/modules/common/ConfigOptions.qml @@ -66,8 +66,8 @@ Singleton { property QtObject language: QtObject { property QtObject translator: QtObject { property string engine: "auto" // Run `trans -list-engines` for available engines. auto should use google + property string targetLanguage: "auto" // Run `trans -list-all` for available languages property string sourceLanguage: "auto" - property string targetLanguage: "English" // Run `trans -list-all` for available languages } } diff --git a/.config/quickshell/modules/common/widgets/SelectionDialog.qml b/.config/quickshell/modules/common/widgets/SelectionDialog.qml index 1e1446b51..affd13bc9 100644 --- a/.config/quickshell/modules/common/widgets/SelectionDialog.qml +++ b/.config/quickshell/modules/common/widgets/SelectionDialog.qml @@ -13,7 +13,8 @@ Item { property real dialogMargin: 30 property string titleText: "Selection Dialog" property alias items: choiceModel.values - property int selectedId: -1 // -1 means no selection + property int selectedId: choiceListView.currentIndex + property var defaultChoice signal canceled(); signal selected(var result); @@ -68,6 +69,7 @@ Item { Layout.fillWidth: true Layout.fillHeight: true clip: true + currentIndex: root.defaultChoice !== undefined ? root.items.indexOf(root.defaultChoice) : -1 model: ScriptModel { id: choiceModel @@ -85,11 +87,11 @@ Item { } description: modelData.toString() - checked: index === root.selectedId + checked: index === choiceListView.currentIndex onCheckedChanged: { if (checked) { - root.selectedId = index; + choiceListView.currentIndex = index; } } } diff --git a/.config/quickshell/modules/sidebarLeft/Translator.qml b/.config/quickshell/modules/sidebarLeft/Translator.qml index aacc35868..8f93b50d7 100644 --- a/.config/quickshell/modules/sidebarLeft/Translator.qml +++ b/.config/quickshell/modules/sidebarLeft/Translator.qml @@ -29,12 +29,10 @@ Item { property bool showLanguageSelector: false property bool languageSelectorTarget: false // true for target language, false for source language - property string languageSelectorLanguage: "" function showLanguageSelectorDialog(isTargetLang: bool) { - root.showLanguageSelector = true root.languageSelectorTarget = isTargetLang; - root.languageSelectorLanguage = isTargetLang ? root.targetLanguage : root.sourceLanguage; + root.showLanguageSelector = true } onFocusChanged: (focus) => { @@ -93,9 +91,12 @@ Item { } } onExited: (exitCode, exitStatus) => { - root.languages = getLanguagesProc.bufferList - .filter(lang => lang.trim().length > 0) // Filter out empty lines - .sort((a, b) => a.localeCompare(b)); // Sort alphabetically + // Ensure "auto" is always the first language + let langs = getLanguagesProc.bufferList + .filter(lang => lang.trim().length > 0 && lang !== "auto") + .sort((a, b) => a.localeCompare(b)); + langs.unshift("auto"); + root.languages = langs; getLanguagesProc.bufferList = []; // Clear the buffer } } @@ -224,6 +225,7 @@ Item { id: languageSelectorDialog titleText: qsTr("Select Language") items: root.languages + defaultChoice: root.languageSelectorTarget ? root.targetLanguage : root.sourceLanguage onCanceled: () => { root.showLanguageSelector = false; } @@ -233,10 +235,10 @@ Item { if (root.languageSelectorTarget) { root.targetLanguage = result; - ConfigOptions.language.translator.targetLanguage = result; // Save to config + ConfigLoader.setConfigValueAndSave("language.translator.targetLanguage", result); // Save to config } else { root.sourceLanguage = result; - ConfigOptions.language.translator.sourceLanguage = result; // Save to config + ConfigLoader.setConfigValueAndSave("language.translator.sourceLanguage", result); // Save to config } translateTimer.restart(); // Restart translation after language change diff --git a/.config/quickshell/services/ConfigLoader.qml b/.config/quickshell/services/ConfigLoader.qml index 61aa9b4ed..688bb47bb 100644 --- a/.config/quickshell/services/ConfigLoader.qml +++ b/.config/quickshell/services/ConfigLoader.qml @@ -14,13 +14,18 @@ import Qt.labs.platform /** * Loads and manages the shell configuration file. * The config file is by default at XDG_CONFIG_HOME/illogical-impulse/config.json. - * Automatically reloaded when the file changes, but does not provide a way to save changes. + * Automatically reloaded when the file changes. */ Singleton { id: root property string filePath: Directories.shellConfigPath property bool firstLoad: true property bool preventNextLoad: false + property var preventNextNotification: false + + onPreventNextNotificationChanged: { + console.log("HMM: preventNextNotification:", root.preventNextNotification); + } function loadConfig() { configFileView.reload() @@ -87,11 +92,19 @@ Singleton { Hyprland.dispatch(`exec echo '${StringUtils.shellSingleQuoteEscape(JSON.stringify(plainConfig, null, 2))}' > '${root.filePath}'`) } + function setConfigValueAndSave(nestedKey, value, preventNextNotification = true) { + setLiveConfigValue(nestedKey, value); + root.preventNextNotification = preventNextNotification; + console.log("SETTING: preventNextNotification:", root.preventNextNotification); + saveConfig(); + } + Timer { id: delayedFileRead interval: ConfigOptions.hacks.arbitraryRaceConditionDelay running: false onTriggered: { + console.log("GONNA APPLY KONFIG preventNextNotification:", root.preventNextNotification); if (root.preventNextLoad) { root.preventNextLoad = false; return; @@ -99,8 +112,13 @@ Singleton { if (root.firstLoad) { root.applyConfig(configFileView.text()) } else { + console.log("APPLYING: preventNextNotification:", root.preventNextNotification); root.applyConfig(configFileView.text()) - Hyprland.dispatch(`exec notify-send "${qsTr("Shell configuration reloaded")}" "${root.filePath}"`) + if (!root.preventNextNotification) { + Hyprland.dispatch(`exec notify-send "${qsTr("Shell configuration reloaded")}" "${root.filePath}"`) + } else { + // root.preventNextNotification = false; + } } } }