1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-15 02:02:08 -04:00

launcher: add ability to search files/folders in all tab

fixes #2032
This commit is contained in:
bbedward
2026-04-14 11:49:35 -04:00
parent eff728fdf5
commit bc6bbdbe9d
6 changed files with 260 additions and 104 deletions

View File

@@ -359,6 +359,8 @@ Singleton {
property string dankLauncherV2BorderColor: "primary" property string dankLauncherV2BorderColor: "primary"
property bool dankLauncherV2ShowFooter: true property bool dankLauncherV2ShowFooter: true
property bool dankLauncherV2UnloadOnClose: false property bool dankLauncherV2UnloadOnClose: false
property bool dankLauncherV2IncludeFilesInAll: false
property bool dankLauncherV2IncludeFoldersInAll: false
property string _legacyWeatherLocation: "New York, NY" property string _legacyWeatherLocation: "New York, NY"
property string _legacyWeatherCoordinates: "40.7128,-74.0060" property string _legacyWeatherCoordinates: "40.7128,-74.0060"

View File

@@ -204,6 +204,8 @@ var SPEC = {
dankLauncherV2BorderColor: { def: "primary" }, dankLauncherV2BorderColor: { def: "primary" },
dankLauncherV2ShowFooter: { def: true }, dankLauncherV2ShowFooter: { def: true },
dankLauncherV2UnloadOnClose: { def: false }, dankLauncherV2UnloadOnClose: { def: false },
dankLauncherV2IncludeFilesInAll: { def: false },
dankLauncherV2IncludeFoldersInAll: { def: false },
useAutoLocation: { def: false }, useAutoLocation: { def: false },
weatherEnabled: { def: true }, weatherEnabled: { def: true },

View File

@@ -352,7 +352,8 @@ Item {
searchQuery = query; searchQuery = query;
searchDebounce.restart(); searchDebounce.restart();
if (searchMode !== "plugins" && (searchMode === "files" || query.startsWith("/")) && query.length > 0) { var filesInAll = searchMode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll);
if (searchMode !== "plugins" && (searchMode === "files" || query.startsWith("/") || filesInAll) && query.length > 0) {
fileSearchDebounce.restart(); fileSearchDebounce.restart();
} }
} }
@@ -369,7 +370,8 @@ Item {
searchMode = mode; searchMode = mode;
modeChanged(mode); modeChanged(mode);
performSearch(); performSearch();
if (mode === "files") { var filesInAll = mode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll) && searchQuery.length > 0;
if (mode === "files" || filesInAll) {
fileSearchDebounce.restart(); fileSearchDebounce.restart();
} }
} }
@@ -927,10 +929,22 @@ Item {
if (!DSearchService.dsearchAvailable) if (!DSearchService.dsearchAvailable)
return; return;
var fileQuery = ""; var fileQuery = "";
var effectiveType = fileSearchType || "all";
var includeFiles = SettingsData.dankLauncherV2IncludeFilesInAll;
var includeFolders = SettingsData.dankLauncherV2IncludeFoldersInAll;
if (searchQuery.startsWith("/")) { if (searchQuery.startsWith("/")) {
fileQuery = searchQuery.substring(1).trim(); fileQuery = searchQuery.substring(1).trim();
} else if (searchMode === "files") { } else if (searchMode === "files") {
fileQuery = searchQuery.trim(); fileQuery = searchQuery.trim();
} else if (searchMode === "all" && (includeFiles || includeFolders)) {
fileQuery = searchQuery.trim();
if (includeFiles && !includeFolders)
effectiveType = "file";
else if (!includeFiles && includeFolders)
effectiveType = "dir";
else
effectiveType = "all";
} else { } else {
return; return;
} }
@@ -941,109 +955,129 @@ Item {
} }
isFileSearching = true; isFileSearching = true;
var params = {
limit: 20,
fuzzy: true,
sort: fileSearchSort || "score",
desc: true
};
if (DSearchService.supportsTypeFilter) { var splitBothTypes = searchMode === "all" && includeFiles && includeFolders && DSearchService.supportsTypeFilter;
params.type = (fileSearchType && fileSearchType !== "all") ? fileSearchType : "all"; var queryTypes = splitBothTypes ? ["file", "dir"] : [effectiveType];
} var pending = queryTypes.length;
if (fileSearchExt) { var aggregatedItems = [];
params.ext = fileSearchExt;
}
if (fileSearchFolder) {
params.folder = fileSearchFolder;
}
DSearchService.search(fileQuery, params, function (response) { for (var t = 0; t < queryTypes.length; t++) {
isFileSearching = false; var queryType = queryTypes[t];
if (response.error) var params = {
return; limit: 20,
var fileItems = []; fuzzy: true,
var hits = response.result?.hits || []; sort: fileSearchSort || "score",
desc: true
};
for (var i = 0; i < hits.length; i++) { if (DSearchService.supportsTypeFilter) {
var hit = hits[i]; params.type = (queryType && queryType !== "all") ? queryType : "all";
var docTypes = hit.locations?.doc_type; }
var isDir = docTypes ? !!docTypes["dir"] : false; if (fileSearchExt) {
fileItems.push(transformFileResult({ params.ext = fileSearchExt;
path: hit.id || "", }
score: hit.score || 0, if (fileSearchFolder) {
is_dir: isDir params.folder = fileSearchFolder;
}));
} }
var fileSections = []; DSearchService.search(fileQuery, params, function (response) {
var showType = fileSearchType || "all"; pending--;
if (!response.error) {
var hits = response.result?.hits || [];
for (var i = 0; i < hits.length; i++) {
var hit = hits[i];
var docTypes = hit.locations?.doc_type;
var isDir = docTypes ? !!docTypes["dir"] : false;
aggregatedItems.push(transformFileResult({
path: hit.id || "",
score: hit.score || 0,
is_dir: isDir
}));
}
}
if (pending > 0)
return;
if (showType === "all" && DSearchService.supportsTypeFilter) { isFileSearching = false;
var onlyFiles = []; _applyFileSearchResults(aggregatedItems, effectiveType);
var onlyDirs = [];
for (var j = 0; j < fileItems.length; j++) {
if (fileItems[j].data?.is_dir)
onlyDirs.push(fileItems[j]);
else
onlyFiles.push(fileItems[j]);
}
if (onlyFiles.length > 0) {
fileSections.push({
id: "files",
title: I18n.tr("Files"),
icon: "insert_drive_file",
priority: 4,
items: onlyFiles,
collapsed: collapsedSections["files"] || false,
flatStartIndex: 0
});
}
if (onlyDirs.length > 0) {
fileSections.push({
id: "folders",
title: I18n.tr("Folders"),
icon: "folder",
priority: 4.1,
items: onlyDirs,
collapsed: collapsedSections["folders"] || false,
flatStartIndex: 0
});
}
} else {
var filesIcon = showType === "dir" ? "folder" : showType === "file" ? "insert_drive_file" : "folder";
var filesTitle = showType === "dir" ? I18n.tr("Folders") : I18n.tr("Files");
if (fileItems.length > 0) {
fileSections.push({
id: "files",
title: filesTitle,
icon: filesIcon,
priority: 4,
items: fileItems,
collapsed: collapsedSections["files"] || false,
flatStartIndex: 0
});
}
}
var newSections;
if (searchMode === "files") {
newSections = fileSections;
} else {
var existingNonFile = sections.filter(function (s) {
return s.id !== "files" && s.id !== "folders";
});
newSections = existingNonFile.concat(fileSections);
}
newSections.sort(function (a, b) {
return a.priority - b.priority;
}); });
_applyHighlights(newSections, searchQuery); }
flatModel = Scorer.flattenSections(newSections); }
sections = newSections;
selectedFlatIndex = getFirstItemIndex(); function _applyFileSearchResults(fileItems, effectiveType) {
updateSelectedItem(); var fileSections = [];
var showType = effectiveType;
var order = SettingsData.launcherPluginOrder || [];
var filesOrderIdx = order.indexOf("__files");
var foldersOrderIdx = order.indexOf("__folders");
var filesPriority = filesOrderIdx !== -1 ? 2.6 + filesOrderIdx * 0.01 : 4;
var foldersPriority = foldersOrderIdx !== -1 ? 2.6 + foldersOrderIdx * 0.01 : 4.1;
if (showType === "all" && DSearchService.supportsTypeFilter) {
var onlyFiles = [];
var onlyDirs = [];
for (var j = 0; j < fileItems.length; j++) {
if (fileItems[j].data?.is_dir)
onlyDirs.push(fileItems[j]);
else
onlyFiles.push(fileItems[j]);
}
if (onlyFiles.length > 0) {
fileSections.push({
id: "files",
title: I18n.tr("Files"),
icon: "insert_drive_file",
priority: filesPriority,
items: onlyFiles,
collapsed: collapsedSections["files"] || false,
flatStartIndex: 0
});
}
if (onlyDirs.length > 0) {
fileSections.push({
id: "folders",
title: I18n.tr("Folders"),
icon: "folder",
priority: foldersPriority,
items: onlyDirs,
collapsed: collapsedSections["folders"] || false,
flatStartIndex: 0
});
}
} else {
var filesIcon = showType === "dir" ? "folder" : showType === "file" ? "insert_drive_file" : "folder";
var filesTitle = showType === "dir" ? I18n.tr("Folders") : I18n.tr("Files");
var singlePriority = showType === "dir" ? foldersPriority : filesPriority;
if (fileItems.length > 0) {
fileSections.push({
id: "files",
title: filesTitle,
icon: filesIcon,
priority: singlePriority,
items: fileItems,
collapsed: collapsedSections["files"] || false,
flatStartIndex: 0
});
}
}
var newSections;
if (searchMode === "files") {
newSections = fileSections;
} else {
var existingNonFile = sections.filter(function (s) {
return s.id !== "files" && s.id !== "folders";
});
newSections = existingNonFile.concat(fileSections);
}
newSections.sort(function (a, b) {
return a.priority - b.priority;
}); });
_applyHighlights(newSections, searchQuery);
flatModel = Scorer.flattenSections(newSections);
sections = newSections;
selectedFlatIndex = getFirstItemIndex();
updateSelectedItem();
} }
function searchApps(query) { function searchApps(query) {
@@ -1276,7 +1310,11 @@ Item {
function buildDynamicSectionDefs(items) { function buildDynamicSectionDefs(items) {
var baseDefs = sectionDefinitions.slice(); var baseDefs = sectionDefinitions.slice();
var pluginSections = {}; var pluginSections = {};
var basePriority = 2.6; var order = SettingsData.launcherPluginOrder || [];
var orderMap = {};
for (var k = 0; k < order.length; k++)
orderMap[order[k]] = k;
var unorderedPriority = 2.6 + order.length * 0.01;
for (var i = 0; i < items.length; i++) { for (var i = 0; i < items.length; i++) {
var section = items[i].section; var section = items[i].section;
@@ -1287,19 +1325,25 @@ Item {
var pluginId = section.substring(7); var pluginId = section.substring(7);
var meta = getPluginMetadata(pluginId); var meta = getPluginMetadata(pluginId);
var viewPref = getPluginViewPref(pluginId); var viewPref = getPluginViewPref(pluginId);
var orderIdx = orderMap[pluginId];
var priority;
if (orderIdx !== undefined) {
priority = 2.6 + orderIdx * 0.01;
} else {
priority = unorderedPriority;
unorderedPriority += 0.01;
}
pluginSections[section] = { pluginSections[section] = {
id: section, id: section,
title: meta.name, title: meta.name,
icon: meta.icon, icon: meta.icon,
priority: basePriority, priority: priority,
defaultViewMode: viewPref.mode || "list" defaultViewMode: viewPref.mode || "list"
}; };
if (viewPref.mode) if (viewPref.mode)
setPluginViewPreference(section, viewPref.mode, viewPref.enforced); setPluginViewPreference(section, viewPref.mode, viewPref.enforced);
basePriority += 0.01;
} }
for (var sectionId in pluginSections) { for (var sectionId in pluginSections) {

View File

@@ -606,6 +606,8 @@ Item {
property var allLauncherPlugins: { property var allLauncherPlugins: {
SettingsData.launcherPluginVisibility; SettingsData.launcherPluginVisibility;
SettingsData.launcherPluginOrder; SettingsData.launcherPluginOrder;
SettingsData.dankLauncherV2IncludeFilesInAll;
SettingsData.dankLauncherV2IncludeFoldersInAll;
var plugins = []; var plugins = [];
var builtIn = AppSearchService.getBuiltInLauncherPlugins() || {}; var builtIn = AppSearchService.getBuiltInLauncherPlugins() || {};
for (var pluginId in builtIn) { for (var pluginId in builtIn) {
@@ -616,6 +618,7 @@ Item {
icon: plugin.cornerIcon || "extension", icon: plugin.cornerIcon || "extension",
iconType: "material", iconType: "material",
isBuiltIn: true, isBuiltIn: true,
isVirtual: false,
trigger: AppSearchService.getBuiltInPluginTrigger(pluginId) || "" trigger: AppSearchService.getBuiltInPluginTrigger(pluginId) || ""
}); });
} }
@@ -629,9 +632,32 @@ Item {
icon: rawIcon.startsWith("material:") ? rawIcon.substring(9) : rawIcon.startsWith("unicode:") ? rawIcon.substring(8) : rawIcon, icon: rawIcon.startsWith("material:") ? rawIcon.substring(9) : rawIcon.startsWith("unicode:") ? rawIcon.substring(8) : rawIcon,
iconType: rawIcon.startsWith("unicode:") ? "unicode" : "material", iconType: rawIcon.startsWith("unicode:") ? "unicode" : "material",
isBuiltIn: false, isBuiltIn: false,
isVirtual: false,
trigger: PluginService.getPluginTrigger(pluginId) || "" trigger: PluginService.getPluginTrigger(pluginId) || ""
}); });
} }
if (SettingsData.dankLauncherV2IncludeFilesInAll) {
plugins.push({
id: "__files",
name: I18n.tr("Files"),
icon: "insert_drive_file",
iconType: "material",
isBuiltIn: false,
isVirtual: true,
trigger: "/"
});
}
if (SettingsData.dankLauncherV2IncludeFoldersInAll) {
plugins.push({
id: "__folders",
name: I18n.tr("Folders"),
icon: "folder",
iconType: "material",
isBuiltIn: false,
isVirtual: true,
trigger: "/"
});
}
return SettingsData.getOrderedLauncherPlugins(plugins); return SettingsData.getOrderedLauncherPlugins(plugins);
} }
@@ -750,9 +776,27 @@ Item {
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Theme.spacingM anchors.rightMargin: Theme.spacingM
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.getPluginAllowWithoutTrigger(visibilityDelegateItem.modelData.id) checked: {
switch (visibilityDelegateItem.modelData.id) {
case "__files":
return SettingsData.dankLauncherV2IncludeFilesInAll;
case "__folders":
return SettingsData.dankLauncherV2IncludeFoldersInAll;
default:
return SettingsData.getPluginAllowWithoutTrigger(visibilityDelegateItem.modelData.id);
}
}
onToggled: function (isChecked) { onToggled: function (isChecked) {
SettingsData.setPluginAllowWithoutTrigger(visibilityDelegateItem.modelData.id, isChecked); switch (visibilityDelegateItem.modelData.id) {
case "__files":
SettingsData.set("dankLauncherV2IncludeFilesInAll", isChecked);
break;
case "__folders":
SettingsData.set("dankLauncherV2IncludeFoldersInAll", isChecked);
break;
default:
SettingsData.setPluginAllowWithoutTrigger(visibilityDelegateItem.modelData.id, isChecked);
}
} }
} }
} }
@@ -840,6 +884,24 @@ Item {
checked: SettingsData.rememberLastQuery checked: SettingsData.rememberLastQuery
onToggled: checked => SettingsData.set("rememberLastQuery", checked) onToggled: checked => SettingsData.set("rememberLastQuery", checked)
} }
SettingsToggleRow {
settingKey: "dankLauncherV2IncludeFilesInAll"
tags: ["launcher", "files", "dsearch", "all", "results", "indexed"]
text: I18n.tr("Include Files in All Tab")
description: I18n.tr("Merge indexed file results into the All tab (requires dsearch).")
checked: SettingsData.dankLauncherV2IncludeFilesInAll
onToggled: checked => SettingsData.set("dankLauncherV2IncludeFilesInAll", checked)
}
SettingsToggleRow {
settingKey: "dankLauncherV2IncludeFoldersInAll"
tags: ["launcher", "folders", "dirs", "dsearch", "all", "results", "indexed"]
text: I18n.tr("Include Folders in All Tab")
description: I18n.tr("Merge indexed folder results into the All tab (requires dsearch).")
checked: SettingsData.dankLauncherV2IncludeFoldersInAll
onToggled: checked => SettingsData.set("dankLauncherV2IncludeFoldersInAll", checked)
}
} }
SettingsCard { SettingsCard {

View File

@@ -138,7 +138,8 @@ Singleton {
} }
} }
Proc.runCommand("dsearch-search", args, (stdout, exitCode) => { const procId = "dsearch-search-" + (params?.type || "all");
Proc.runCommand(procId, args, (stdout, exitCode) => {
if (exitCode === 0) { if (exitCode === 0) {
try { try {
const response = JSON.parse(stdout); const response = JSON.parse(stdout);

View File

@@ -1982,6 +1982,51 @@
], ],
"icon": "visibility_off" "icon": "visibility_off"
}, },
{
"section": "dankLauncherV2IncludeFilesInAll",
"label": "Include Files in All Tab",
"tabIndex": 9,
"category": "Launcher",
"keywords": [
"all",
"drawer",
"dsearch",
"file",
"files",
"include",
"indexed",
"launcher",
"menu",
"merge",
"results",
"start",
"tab"
],
"description": "Merge indexed file results into the All tab (requires dsearch)."
},
{
"section": "dankLauncherV2IncludeFoldersInAll",
"label": "Include Folders in All Tab",
"tabIndex": 9,
"category": "Launcher",
"keywords": [
"all",
"dirs",
"drawer",
"dsearch",
"folder",
"folders",
"include",
"indexed",
"launcher",
"menu",
"merge",
"results",
"start",
"tab"
],
"description": "Merge indexed folder results into the All tab (requires dsearch)."
},
{ {
"section": "launcherLogoColorInvertOnMode", "section": "launcherLogoColorInvertOnMode",
"label": "Invert on mode change", "label": "Invert on mode change",