1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-12 00:32:17 -04:00

feat(danklauncher): add launcher history (#2086)

* remember last search query

* add launcherLastQuery SessionSpec

* add rememberLastQuery option

* Add remember last query for appdrawer

* Add query history sessiondata

* Complete and cleanup

* Discard changes to quickshell/Modules/Settings/LauncherTab.qml

* Cleanup logic

* Add rememberLastQuery option

* Add rememberLastQuery option description

* Move setLauncherLastQuery above validation

* Fix logic bug with empty query
This commit is contained in:
Triệu Kha
2026-03-30 20:09:39 +07:00
committed by GitHub
parent 03d2a3fd39
commit 577863b969
9 changed files with 119 additions and 25 deletions

View File

@@ -39,11 +39,14 @@ Item {
signal itemExecuted
signal searchCompleted
signal modeChanged(string mode)
signal queryChanged(string query)
signal viewModeChanged(string sectionId, string mode)
signal searchQueryRequested(string query)
onActiveChanged: {
if (!active) {
SessionData.addLauncherHistory(searchQuery);
sections = [];
flatModel = [];
selectedItem = null;
@@ -175,6 +178,33 @@ Item {
}
]
property int historyIndex: -1
property string typingBackup: ""
function navigateHistory(direction) {
let history = SessionData.launcherQueryHistory;
if (history.length === 0)
return;
if (historyIndex === -1)
typingBackup = searchQuery;
let nextIndex = historyIndex + (direction === "up" ? 1 : -1);
if (nextIndex >= history.length)
nextIndex = history.length - 1;
if (nextIndex < -1)
nextIndex = -1;
if (nextIndex === historyIndex)
return;
historyIndex = nextIndex;
let targetText = (historyIndex === -1) ? typingBackup : history[historyIndex];
setSearchQuery(targetText);
searchQueryRequested(targetText);
}
property string fileSearchType: "all"
property string fileSearchExt: ""
property string fileSearchFolder: ""
@@ -496,6 +526,8 @@ Item {
}
function performSearch() {
queryChanged(searchQuery);
var currentVersion = _searchVersion;
isSearching = true;
var shouldResetSelection = _queryDrivenSearch;
@@ -1654,6 +1686,9 @@ Item {
function executeItem(item) {
if (!item)
return;
SessionData.addLauncherHistory(searchQuery);
if (item.type === "plugin_browse") {
var browsePluginId = item.data?.pluginId;
if (!browsePluginId)