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:
@@ -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();
|
||||
|
||||
@@ -87,6 +87,7 @@ var SPEC = {
|
||||
timeLocale: { def: "" },
|
||||
|
||||
launcherLastMode: { def: "all" },
|
||||
launcherLastFileSearchType: { def: "all" },
|
||||
launcherLastQuery: { def: "" },
|
||||
launcherQueryHistory: { def: [] },
|
||||
appDrawerLastMode: { def: "apps" },
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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() };
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user