mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-08 04:09:15 -04:00
feat(Launcher/Spotlight): improve context keyboard navigation and mode persistence (#2467)
* feat(Spotlight): fix submenu keyboard navigation * feat(Launcher/Spotlight): disable persisting last mode when changed by triggers * feat(Launcher/Spotlight): add option to disable last mode being persisted * fix(Launcher/Spotlight): fix context menu keys navigation * fix(NiriOverviewOverlay): fix context menu keys navigation and position
This commit is contained in:
@@ -39,7 +39,7 @@ Item {
|
||||
|
||||
signal itemExecuted
|
||||
signal searchCompleted
|
||||
signal modeChanged(string mode)
|
||||
signal modeChanged(string mode, bool userInitiated)
|
||||
signal queryChanged(string query)
|
||||
signal viewModeChanged(string sectionId, string mode)
|
||||
signal searchQueryRequested(string query)
|
||||
@@ -440,7 +440,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
function setMode(mode, isAutoSwitch, fileTypeOverride) {
|
||||
function setMode(mode, isAutoSwitch, fileTypeOverride, notPersist) {
|
||||
if (searchMode === mode) {
|
||||
if (mode === "files" && fileTypeOverride !== undefined && fileSearchType !== fileTypeOverride) {
|
||||
fileSearchType = fileTypeOverride;
|
||||
@@ -458,7 +458,7 @@ Item {
|
||||
if (mode === "files") {
|
||||
fileSearchType = fileTypeOverride !== undefined ? fileTypeOverride : (SessionData.launcherLastFileSearchType || "all");
|
||||
}
|
||||
modeChanged(mode);
|
||||
modeChanged(mode, !isAutoSwitch && notPersist !== true);
|
||||
performSearch();
|
||||
var filesInAll = mode === "all" && (SettingsData.dankLauncherV2IncludeFilesInAll || SettingsData.dankLauncherV2IncludeFoldersInAll) && searchQuery.length > 0;
|
||||
if (mode === "files" || filesInAll) {
|
||||
@@ -471,7 +471,7 @@ Item {
|
||||
return;
|
||||
autoSwitchedToFiles = false;
|
||||
searchMode = previousSearchMode;
|
||||
modeChanged(previousSearchMode);
|
||||
modeChanged(previousSearchMode, false);
|
||||
performSearch();
|
||||
}
|
||||
|
||||
@@ -1897,7 +1897,7 @@ Item {
|
||||
if (browseTrigger && browseTrigger.length > 0) {
|
||||
searchQueryRequested(browseTrigger);
|
||||
} else {
|
||||
setMode("plugins");
|
||||
setMode("plugins", false, undefined, true);
|
||||
pluginFilter = browsePluginId;
|
||||
performSearch();
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ Item {
|
||||
spotlightContent.searchField.text = query;
|
||||
}
|
||||
if (spotlightContent.controller) {
|
||||
var targetMode = mode || SessionData.launcherLastMode || "all";
|
||||
var targetMode = mode || SessionData.getLauncherRestoreMode();
|
||||
spotlightContent.controller.searchMode = targetMode;
|
||||
spotlightContent.controller.activePluginId = "";
|
||||
spotlightContent.controller.activePluginName = "";
|
||||
@@ -539,8 +539,8 @@ Item {
|
||||
|
||||
Connections {
|
||||
target: spotlightContent?.controller ?? null
|
||||
function onModeChanged(mode) {
|
||||
if (spotlightContent.controller.autoSwitchedToFiles)
|
||||
function onModeChanged(mode, userInitiated) {
|
||||
if (!userInitiated || !SettingsData.rememberLastMode)
|
||||
return;
|
||||
SessionData.setLauncherLastMode(mode);
|
||||
}
|
||||
@@ -928,8 +928,12 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: event => root.spotlightContent?.activeContextMenu?.handleKey(event)
|
||||
|
||||
Keys.onEscapePressed: event => {
|
||||
root.hide();
|
||||
root.spotlightContent?.activeContextMenu?.handleKey(event);
|
||||
if (!event.accepted)
|
||||
root.hide();
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ Item {
|
||||
spotlightContent.closeTransientUi?.();
|
||||
|
||||
const targetQuery = query || (SettingsData.rememberLastQuery ? (SessionData.launcherLastQuery || "") : "");
|
||||
const targetMode = mode || SessionData.launcherLastMode || "all";
|
||||
const targetMode = mode || SessionData.getLauncherRestoreMode();
|
||||
|
||||
if (spotlightContent.searchField) {
|
||||
spotlightContent.searchField.text = targetQuery;
|
||||
@@ -489,8 +489,12 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: event => root.spotlightContent?.activeContextMenu?.handleKey(event)
|
||||
|
||||
Keys.onEscapePressed: event => {
|
||||
root.hide();
|
||||
root.spotlightContent?.activeContextMenu?.handleKey(event);
|
||||
if (!event.accepted)
|
||||
root.hide();
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ Item {
|
||||
spotlightContent.searchField.text = targetQuery;
|
||||
}
|
||||
if (spotlightContent.controller) {
|
||||
var targetMode = mode || SessionData.launcherLastMode || "all";
|
||||
var targetMode = mode || SessionData.getLauncherRestoreMode();
|
||||
spotlightContent.controller.searchMode = targetMode;
|
||||
spotlightContent.controller.activePluginId = "";
|
||||
spotlightContent.controller.activePluginName = "";
|
||||
@@ -260,8 +260,8 @@ Item {
|
||||
Connections {
|
||||
target: spotlightContent?.controller ?? null
|
||||
|
||||
function onModeChanged(mode) {
|
||||
if (spotlightContent.controller.autoSwitchedToFiles)
|
||||
function onModeChanged(mode, userInitiated) {
|
||||
if (!userInitiated || !SettingsData.rememberLastMode || (mode !== "all" && mode !== "apps"))
|
||||
return;
|
||||
SessionData.setLauncherLastMode(mode);
|
||||
}
|
||||
@@ -536,8 +536,12 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: event => root.spotlightContent?.activeContextMenu?.handleKey(event)
|
||||
|
||||
Keys.onEscapePressed: event => {
|
||||
root.hide();
|
||||
root.spotlightContent?.activeContextMenu?.handleKey(event);
|
||||
if (!event.accepted)
|
||||
root.hide();
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ FocusScope {
|
||||
property alias controller: controller
|
||||
property alias resultsList: resultsList
|
||||
property alias actionPanel: actionPanel
|
||||
readonly property alias activeContextMenu: contextMenu
|
||||
|
||||
property bool editMode: false
|
||||
property var editingApp: null
|
||||
|
||||
@@ -340,6 +340,31 @@ Item {
|
||||
return count;
|
||||
}
|
||||
|
||||
function handleKey(event) {
|
||||
if (!openState)
|
||||
return;
|
||||
switch (event.key) {
|
||||
case Qt.Key_Down:
|
||||
selectNext();
|
||||
event.accepted = true;
|
||||
return;
|
||||
case Qt.Key_Up:
|
||||
selectPrevious();
|
||||
event.accepted = true;
|
||||
return;
|
||||
case Qt.Key_Return:
|
||||
case Qt.Key_Enter:
|
||||
activateSelected();
|
||||
event.accepted = true;
|
||||
return;
|
||||
case Qt.Key_Left:
|
||||
case Qt.Key_Escape:
|
||||
hide();
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function selectNext() {
|
||||
if (visibleItemCount > 0) {
|
||||
keyboardNavigation = true;
|
||||
|
||||
@@ -12,6 +12,7 @@ FocusScope {
|
||||
property var parentModal: null
|
||||
property alias searchField: searchInput
|
||||
property alias controller: searchController
|
||||
readonly property alias activeContextMenu: contextMenu
|
||||
|
||||
readonly property bool _hasQuery: searchInput.text.length > 0
|
||||
readonly property real _searchBarH: 56
|
||||
@@ -239,8 +240,8 @@ FocusScope {
|
||||
|
||||
Connections {
|
||||
target: searchController
|
||||
function onModeChanged(mode) {
|
||||
if (searchController.autoSwitchedToFiles)
|
||||
function onModeChanged(mode, userInitiated) {
|
||||
if (!userInitiated || !SettingsData.rememberLastMode)
|
||||
return;
|
||||
SessionData.setLauncherLastMode(mode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user