1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05:00

launcher v2: improve danksearch context switching behavior

This commit is contained in:
bbedward
2026-01-20 21:55:05 -05:00
parent 553f5257b3
commit 0e7f628c4a
3 changed files with 50 additions and 24 deletions

View File

@@ -11,6 +11,9 @@ Item {
property string searchQuery: ""
property string searchMode: "all"
property string previousSearchMode: "all"
property bool autoSwitchedToFiles: false
property bool isFileSearching: false
property var sections: []
property var flatModel: []
property int selectedFlatIndex: 0
@@ -198,9 +201,15 @@ Item {
}
}
function setMode(mode) {
function setMode(mode, isAutoSwitch) {
if (searchMode === mode)
return;
if (isAutoSwitch) {
previousSearchMode = searchMode;
autoSwitchedToFiles = true;
} else {
autoSwitchedToFiles = false;
}
searchMode = mode;
modeChanged(mode);
performSearch();
@@ -209,6 +218,15 @@ Item {
}
}
function restorePreviousMode() {
if (!autoSwitchedToFiles)
return;
autoSwitchedToFiles = false;
searchMode = previousSearchMode;
modeChanged(previousSearchMode);
performSearch();
}
function cycleMode() {
var modes = ["all", "apps", "files", "plugins"];
var currentIndex = modes.indexOf(searchMode);
@@ -219,6 +237,9 @@ Item {
function reset() {
searchQuery = "";
searchMode = "all";
previousSearchMode = "all";
autoSwitchedToFiles = false;
isFileSearching = false;
sections = [];
flatModel = [];
selectedFlatIndex = 0;
@@ -307,6 +328,8 @@ Item {
clearActivePluginViewPreference();
if (searchMode === "files") {
var fileQuery = searchQuery.startsWith("/") ? searchQuery.substring(1).trim() : searchQuery.trim();
isFileSearching = fileQuery.length >= 2 && DSearchService.dsearchAvailable;
sections = [];
flatModel = [];
selectedFlatIndex = 0;
@@ -482,8 +505,12 @@ Item {
return;
}
if (fileQuery.length < 2)
if (fileQuery.length < 2) {
isFileSearching = false;
return;
}
isFileSearching = true;
var params = {
limit: 20,
fuzzy: true,
@@ -492,6 +519,7 @@ Item {
};
DSearchService.search(fileQuery, params, function (response) {
isFileSearching = false;
if (response.error)
return;
var fileItems = [];