1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-07 19:59:14 -04:00

launcher: add /d /f file search prefixes. Fix prefix not always

triggering
This commit is contained in:
bbedward
2026-05-21 21:10:30 -04:00
parent 7ddd0ca90d
commit f0c31bd7b3
8 changed files with 49 additions and 20 deletions
+6
View File
@@ -187,6 +187,7 @@ Singleton {
property string timeLocale: "" property string timeLocale: ""
property string launcherLastMode: "all" property string launcherLastMode: "all"
property string launcherLastFileSearchType: "all"
property string launcherLastQuery: "" property string launcherLastQuery: ""
property var launcherQueryHistory: [] property var launcherQueryHistory: []
property string appDrawerLastMode: "apps" property string appDrawerLastMode: "apps"
@@ -1178,6 +1179,11 @@ Singleton {
saveSettings(); saveSettings();
} }
function setLauncherLastFileSearchType(type) {
launcherLastFileSearchType = type;
saveSettings();
}
function setLauncherLastQuery(query) { function setLauncherLastQuery(query) {
launcherLastQuery = query; launcherLastQuery = query;
saveSettings(); saveSettings();
@@ -87,6 +87,7 @@ var SPEC = {
timeLocale: { def: "" }, timeLocale: { def: "" },
launcherLastMode: { def: "all" }, launcherLastMode: { def: "all" },
launcherLastFileSearchType: { def: "all" },
launcherLastQuery: { def: "" }, launcherLastQuery: { def: "" },
launcherQueryHistory: { def: [] }, launcherQueryHistory: { def: [] },
appDrawerLastMode: { def: "apps" }, appDrawerLastMode: { def: "apps" },
@@ -420,15 +420,34 @@ Item {
searchQuery = query; searchQuery = query;
searchDebounce.restart(); 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); var filesInAll = searchMode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll);
if (searchMode !== "plugins" && (searchMode === "files" || query.startsWith("/") || filesInAll) && query.length > 0) { if (searchMode !== "plugins" && (searchMode === "files" || query.startsWith("/") || filesInAll) && query.length > 0) {
fileSearchDebounce.restart(); fileSearchDebounce.restart();
} }
} }
function setMode(mode, isAutoSwitch) { function setMode(mode, isAutoSwitch, fileTypeOverride) {
if (searchMode === mode) if (searchMode === mode) {
if (mode === "files" && fileTypeOverride !== undefined && fileSearchType !== fileTypeOverride) {
fileSearchType = fileTypeOverride;
performFileSearch();
}
return; return;
}
if (isAutoSwitch) { if (isAutoSwitch) {
previousSearchMode = searchMode; previousSearchMode = searchMode;
autoSwitchedToFiles = true; autoSwitchedToFiles = true;
@@ -436,6 +455,9 @@ Item {
autoSwitchedToFiles = false; autoSwitchedToFiles = false;
} }
searchMode = mode; searchMode = mode;
if (mode === "files") {
fileSearchType = fileTypeOverride !== undefined ? fileTypeOverride : (SessionData.launcherLastFileSearchType || "all");
}
modeChanged(mode); modeChanged(mode);
performSearch(); performSearch();
var filesInAll = mode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll) && searchQuery.length > 0; var filesInAll = mode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll) && searchQuery.length > 0;
@@ -545,6 +567,7 @@ Item {
if (fileSearchType === type) if (fileSearchType === type)
return; return;
fileSearchType = type; fileSearchType = type;
SessionData.setLauncherLastFileSearchType(type);
performFileSearch(); performFileSearch();
} }
@@ -715,7 +738,8 @@ Item {
clearActivePluginViewPreference(); clearActivePluginViewPreference();
if (searchMode === "files") { 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; isFileSearching = fileQuery.length >= 2 && DSearchService.dsearchAvailable;
sections = []; sections = [];
flatModel = []; flatModel = [];
@@ -1005,7 +1029,8 @@ Item {
var includeFolders = SettingsData.dankLauncherV2IncludeFoldersInAll; var includeFolders = SettingsData.dankLauncherV2IncludeFoldersInAll;
if (searchQuery.startsWith("/")) { 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") { } else if (searchMode === "files") {
fileQuery = searchQuery.trim(); fileQuery = searchQuery.trim();
} else if (searchMode === "all" && (includeFiles || includeFolders)) { } else if (searchMode === "all" && (includeFiles || includeFolders)) {
@@ -159,3 +159,14 @@ function sortPluginsOrdered(plugins, order) {
return aOrder - bOrder; 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() };
}
@@ -401,7 +401,7 @@ Item {
spotlightContent.controller.activePluginId = ""; spotlightContent.controller.activePluginId = "";
spotlightContent.controller.activePluginName = ""; spotlightContent.controller.activePluginName = "";
spotlightContent.controller.pluginFilter = ""; spotlightContent.controller.pluginFilter = "";
spotlightContent.controller.fileSearchType = "all"; spotlightContent.controller.fileSearchType = SessionData.launcherLastFileSearchType || "all";
spotlightContent.controller.fileSearchExt = ""; spotlightContent.controller.fileSearchExt = "";
spotlightContent.controller.fileSearchFolder = ""; spotlightContent.controller.fileSearchFolder = "";
spotlightContent.controller.fileSearchSort = "score"; spotlightContent.controller.fileSearchSort = "score";
@@ -153,7 +153,7 @@ Item {
spotlightContent.controller.activePluginId = ""; spotlightContent.controller.activePluginId = "";
spotlightContent.controller.activePluginName = ""; spotlightContent.controller.activePluginName = "";
spotlightContent.controller.pluginFilter = ""; spotlightContent.controller.pluginFilter = "";
spotlightContent.controller.fileSearchType = "all"; spotlightContent.controller.fileSearchType = SessionData.launcherLastFileSearchType || "all";
spotlightContent.controller.fileSearchExt = ""; spotlightContent.controller.fileSearchExt = "";
spotlightContent.controller.fileSearchFolder = ""; spotlightContent.controller.fileSearchFolder = "";
spotlightContent.controller.fileSearchSort = "score"; spotlightContent.controller.fileSearchSort = "score";
@@ -289,13 +289,6 @@ FocusScope {
} }
event.accepted = false; event.accepted = false;
return; return;
case Qt.Key_Slash:
if (event.modifiers === Qt.NoModifier && searchField.text.length === 0) {
controller.setMode("files", true);
return;
}
event.accepted = false;
return;
default: default:
event.accepted = false; event.accepted = false;
} }
@@ -195,13 +195,6 @@ FocusScope {
return; return;
} }
break; 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; event.accepted = false;