From 171adffaf50854040ea8696a09dba10d1d635133 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 23 Aug 2026 12:09:32 +0800 Subject: cleanup: remove prevSelectedPriority, use a smarter way to fallback selecftedPriority --- popups/launcher/components/SelectionState.qml | 22 ++++++++++++---------- shell.qml | 1 - 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/popups/launcher/components/SelectionState.qml b/popups/launcher/components/SelectionState.qml index 4231234..7180129 100644 --- a/popups/launcher/components/SelectionState.qml +++ b/popups/launcher/components/SelectionState.qml @@ -14,7 +14,6 @@ Singleton { property string input: "" property int cursorPosition: 0 property int selectedPriority: 0 - property int previousSelectedPriority: 0 } property Item selected: null @@ -22,7 +21,6 @@ Singleton { property alias cursorPosition: persist.cursorPosition property var priorities: [] property alias selectedPriority: persist.selectedPriority - property alias previousSelectedPriority: persist.previousSelectedPriority property var widgets: [] signal syncSelectionState @@ -38,14 +36,18 @@ Singleton { priorities.sort((a, b) => (widgets.indexOf(a) - widgets.indexOf(b)) || 0); - if (!priorities[selectedPriority]) { - if (priorities[previousSelectedPriority]) { - selectedPriority = previousSelectedPriority; - } else { - selectedPriority = 0; + Qt.callLater(() => { + let prevSelectedPriority = selectedPriority; + while (!priorities[selectedPriority] && selectedPriority > 0) { + if (prevSelectedPriority === selectedPriority) { + Qt.callLater(() => { + if (!priorities[selectedPriority] && selectedPriority > 0) + selectedPriority--; + priorities[selectedPriority]?.syncSelectionState(); + }); + } + prevSelectedPriority = selectedPriority; } - } - - priorities[selectedPriority]?.syncSelectionState(); + }); } } diff --git a/shell.qml b/shell.qml index 1e6ce11..5805429 100644 --- a/shell.qml +++ b/shell.qml @@ -68,7 +68,6 @@ Scope { property int cursorPosition: 0 property var priorities: [] property int selectedPriority: 0 - property int previousSelectedPriority: 0 property var widgets: [] } readonly property list widgets: [ -- cgit v1.2.3