diff --git a/quickshell/Common/SessionData.qml b/quickshell/Common/SessionData.qml index 2fbedca9..47d52044 100644 --- a/quickshell/Common/SessionData.qml +++ b/quickshell/Common/SessionData.qml @@ -187,6 +187,7 @@ Singleton { property string timeLocale: "" property string launcherLastMode: "all" + property string launcherLastFileSearchType: "all" property string launcherLastQuery: "" property var launcherQueryHistory: [] property string appDrawerLastMode: "apps" @@ -1178,6 +1179,11 @@ Singleton { saveSettings(); } + function setLauncherLastFileSearchType(type) { + launcherLastFileSearchType = type; + saveSettings(); + } + function setLauncherLastQuery(query) { launcherLastQuery = query; saveSettings(); diff --git a/quickshell/Common/settings/SessionSpec.js b/quickshell/Common/settings/SessionSpec.js index 07ff393e..8504cbdd 100644 --- a/quickshell/Common/settings/SessionSpec.js +++ b/quickshell/Common/settings/SessionSpec.js @@ -87,6 +87,7 @@ var SPEC = { timeLocale: { def: "" }, launcherLastMode: { def: "all" }, + launcherLastFileSearchType: { def: "all" }, launcherLastQuery: { def: "" }, launcherQueryHistory: { def: [] }, appDrawerLastMode: { def: "apps" }, diff --git a/quickshell/Modals/DankLauncherV2/Controller.qml b/quickshell/Modals/DankLauncherV2/Controller.qml index a2b4de57..d47d86d4 100644 --- a/quickshell/Modals/DankLauncherV2/Controller.qml +++ b/quickshell/Modals/DankLauncherV2/Controller.qml @@ -420,15 +420,34 @@ Item { searchQuery = query; searchDebounce.restart(); + if (searchMode !== "plugins" && query.startsWith("/")) { + var prefix = Utils.parseFileSearchPrefix(query); + var explicitType = prefix && prefix.type !== null ? prefix.type : null; + var targetType = explicitType !== null ? explicitType : (SessionData.launcherLastFileSearchType || "all"); + if (searchMode !== "files") { + setMode("files", true, targetType); + } else if (fileSearchType !== targetType) { + fileSearchType = targetType; + } + if (explicitType !== null && SessionData.launcherLastFileSearchType !== explicitType) { + SessionData.setLauncherLastFileSearchType(explicitType); + } + } + var filesInAll = searchMode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll); if (searchMode !== "plugins" && (searchMode === "files" || query.startsWith("/") || filesInAll) && query.length > 0) { fileSearchDebounce.restart(); } } - function setMode(mode, isAutoSwitch) { - if (searchMode === mode) + function setMode(mode, isAutoSwitch, fileTypeOverride) { + if (searchMode === mode) { + if (mode === "files" && fileTypeOverride !== undefined && fileSearchType !== fileTypeOverride) { + fileSearchType = fileTypeOverride; + performFileSearch(); + } return; + } if (isAutoSwitch) { previousSearchMode = searchMode; autoSwitchedToFiles = true; @@ -436,6 +455,9 @@ Item { autoSwitchedToFiles = false; } searchMode = mode; + if (mode === "files") { + fileSearchType = fileTypeOverride !== undefined ? fileTypeOverride : (SessionData.launcherLastFileSearchType || "all"); + } modeChanged(mode); performSearch(); var filesInAll = mode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll) && searchQuery.length > 0; @@ -545,6 +567,7 @@ Item { if (fileSearchType === type) return; fileSearchType = type; + SessionData.setLauncherLastFileSearchType(type); performFileSearch(); } @@ -715,7 +738,8 @@ Item { clearActivePluginViewPreference(); if (searchMode === "files") { - var fileQuery = searchQuery.startsWith("/") ? searchQuery.substring(1).trim() : searchQuery.trim(); + var prefixInfo = Utils.parseFileSearchPrefix(searchQuery); + var fileQuery = prefixInfo ? prefixInfo.query : searchQuery.trim(); isFileSearching = fileQuery.length >= 2 && DSearchService.dsearchAvailable; sections = []; flatModel = []; @@ -1005,7 +1029,8 @@ Item { var includeFolders = SettingsData.dankLauncherV2IncludeFoldersInAll; if (searchQuery.startsWith("/")) { - fileQuery = searchQuery.substring(1).trim(); + var prefixInfo = Utils.parseFileSearchPrefix(searchQuery); + fileQuery = prefixInfo ? prefixInfo.query : searchQuery.substring(1).trim(); } else if (searchMode === "files") { fileQuery = searchQuery.trim(); } else if (searchMode === "all" && (includeFiles || includeFolders)) { diff --git a/quickshell/Modals/DankLauncherV2/ControllerUtils.js b/quickshell/Modals/DankLauncherV2/ControllerUtils.js index b4f5ebe3..f68f9539 100644 --- a/quickshell/Modals/DankLauncherV2/ControllerUtils.js +++ b/quickshell/Modals/DankLauncherV2/ControllerUtils.js @@ -159,3 +159,14 @@ function sortPluginsOrdered(plugins, order) { return aOrder - bOrder; }); } + +function parseFileSearchPrefix(query) { + if (!query || !query.startsWith("/")) + return null; + var rest = query.substring(1); + if (rest === "d" || rest.startsWith("d ") || rest.startsWith("d\t")) + return { type: "dir", query: rest.substring(1).trim() }; + if (rest === "f" || rest.startsWith("f ") || rest.startsWith("f\t")) + return { type: "file", query: rest.substring(1).trim() }; + return { type: null, query: rest.trim() }; +} diff --git a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalConnected.qml b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalConnected.qml index bc7d9c85..3a5e3d29 100644 --- a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalConnected.qml +++ b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalConnected.qml @@ -401,7 +401,7 @@ Item { spotlightContent.controller.activePluginId = ""; spotlightContent.controller.activePluginName = ""; spotlightContent.controller.pluginFilter = ""; - spotlightContent.controller.fileSearchType = "all"; + spotlightContent.controller.fileSearchType = SessionData.launcherLastFileSearchType || "all"; spotlightContent.controller.fileSearchExt = ""; spotlightContent.controller.fileSearchFolder = ""; spotlightContent.controller.fileSearchSort = "score"; diff --git a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml index 0ea1e276..a4e832a8 100644 --- a/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml +++ b/quickshell/Modals/DankLauncherV2/DankLauncherV2ModalStandalone.qml @@ -153,7 +153,7 @@ Item { spotlightContent.controller.activePluginId = ""; spotlightContent.controller.activePluginName = ""; spotlightContent.controller.pluginFilter = ""; - spotlightContent.controller.fileSearchType = "all"; + spotlightContent.controller.fileSearchType = SessionData.launcherLastFileSearchType || "all"; spotlightContent.controller.fileSearchExt = ""; spotlightContent.controller.fileSearchFolder = ""; spotlightContent.controller.fileSearchSort = "score"; diff --git a/quickshell/Modals/DankLauncherV2/LauncherContent.qml b/quickshell/Modals/DankLauncherV2/LauncherContent.qml index 9549fee8..025b9f2f 100644 --- a/quickshell/Modals/DankLauncherV2/LauncherContent.qml +++ b/quickshell/Modals/DankLauncherV2/LauncherContent.qml @@ -289,13 +289,6 @@ FocusScope { } event.accepted = false; return; - case Qt.Key_Slash: - if (event.modifiers === Qt.NoModifier && searchField.text.length === 0) { - controller.setMode("files", true); - return; - } - event.accepted = false; - return; default: event.accepted = false; } diff --git a/quickshell/Modals/DankLauncherV2/SpotlightLauncherContent.qml b/quickshell/Modals/DankLauncherV2/SpotlightLauncherContent.qml index 6740f2e6..af6656b3 100644 --- a/quickshell/Modals/DankLauncherV2/SpotlightLauncherContent.qml +++ b/quickshell/Modals/DankLauncherV2/SpotlightLauncherContent.qml @@ -195,13 +195,6 @@ FocusScope { return; } break; - case Qt.Key_Slash: - if (event.modifiers === Qt.NoModifier && searchInput.text.length === 0) { - searchController.setMode("files", true); - event.accepted = true; - return; - } - break; } event.accepted = false;