diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-08-06 14:32:40 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-08-07 17:27:45 +0800 |
| commit | 97c2e2bf5a6e0a497e0a11cde6611c68f3767cd6 (patch) | |
| tree | 1e0dc8e2106f09232a74740cba2dab6c6dda0359 /launcher | |
| parent | 2f857a56d14ec5937df5bf94f6d2775e47cbf817 (diff) | |
fix(launcher:selection): widget switching
Diffstat (limited to 'launcher')
| -rw-r--r-- | launcher/Launcher.qml | 68 | ||||
| -rw-r--r-- | launcher/components/App.qml | 35 | ||||
| -rw-r--r-- | launcher/components/IComponent.qml | 4 | ||||
| -rw-r--r-- | launcher/components/SelectionState.qml | 10 | ||||
| -rw-r--r-- | launcher/components/Spell.qml | 13 |
5 files changed, 84 insertions, 46 deletions
diff --git a/launcher/Launcher.qml b/launcher/Launcher.qml index e1edecf..bfbf986 100644 --- a/launcher/Launcher.qml +++ b/launcher/Launcher.qml @@ -262,89 +262,57 @@ ILauncher { // not Keys.onPressed because textinput will steal it Shortcut { - sequence: "Ctrl+H" + sequence: "Escape" context: Qt.ApplicationShortcut - onActivated: { - changePos(1); - } + onActivated: parentLoader.active = false } Shortcut { - sequence: "Ctrl+J" + sequence: "Ctrl+H" context: Qt.ApplicationShortcut - onActivated: { - changePos(-2); - } + onActivated: changePos(1) } Shortcut { - sequence: "Ctrl+K" + sequence: "Ctrl+J" context: Qt.ApplicationShortcut - onActivated: { - changePos(2); - } + onActivated: changePos(-2) } Shortcut { - sequence: "Ctrl+L" + sequence: "Ctrl+K" context: Qt.ApplicationShortcut - onActivated: { - changePos(-1); - } + onActivated: changePos(2) } Shortcut { - sequence: "Escape" + sequence: "Ctrl+L" context: Qt.ApplicationShortcut - onActivated: parentLoader.active = false + onActivated: changePos(-1) } Shortcut { sequence: "Down" context: Qt.ApplicationShortcut - onActivated: { - changePos(-2); - } + onActivated: changePos(-2) } Shortcut { sequence: "Up" context: Qt.ApplicationShortcut - onActivated: { - changePos(2); - } + onActivated: changePos(2) } Shortcut { sequence: "PageDown" context: Qt.ApplicationShortcut - onActivated: - // changePos(1); - {} + onActivated: changePos(-20) } Shortcut { sequence: "PageUp" context: Qt.ApplicationShortcut - onActivated: - // changePos(-1); - {} - } - - Shortcut { - sequence: "Home" - context: Qt.ApplicationShortcut - onActivated: - // - {} - } - - Shortcut { - sequence: "End" - context: Qt.ApplicationShortcut - onActivated: - // - {} + onActivated: changePos(20) } } // 1 = left @@ -375,6 +343,14 @@ ILauncher { if (item.down()) set = 1; break; + case 20: + if (item.pgup()) + set = -1; + break; + case -20: + if (item.pgdn()) + set = 1; + break; } switch (set) { diff --git a/launcher/components/App.qml b/launcher/components/App.qml index 6f0e4ce..f36e10e 100644 --- a/launcher/components/App.qml +++ b/launcher/components/App.qml @@ -53,6 +53,41 @@ IComponent { selectedIndex++; } + home: function () { + if (repeater.count === 0) + return true; + selectedIndex = -1; + selectedIndex = 0; + } + end: function () { + if (repeater.count === 0) + return true; + selectedIndex = repeater.count; + selectedIndex = repeater.count - 1; + } + + pgup: function () { + if (repeater.count === 0) + return true; + const pageSize = Math.floor(flickable.height / (General.appIconSize + Launcher.innerMargin * 2)); + if (selectedIndex - pageSize < 0) { + selectedIndex = 0; + } else { + selectedIndex -= pageSize; + } + } + + pgdn: function () { + if (repeater.count === 0) + return true; + const pageSize = Math.floor(flickable.height / (General.appIconSize + Launcher.innerMargin * 2)); + if (selectedIndex + pageSize >= repeater.count) { + selectedIndex = repeater.count - 1; + } else { + selectedIndex += pageSize; + } + } + onEntriesChanged: { selectedIndex = 0; flickable.contentY = 0; diff --git a/launcher/components/IComponent.qml b/launcher/components/IComponent.qml index b8963d2..661dd67 100644 --- a/launcher/components/IComponent.qml +++ b/launcher/components/IComponent.qml @@ -39,6 +39,10 @@ IRect { property var prev: () => {} property var next: () => {} property var exec: () => {} + property var home: () => {} + property var end: () => {} + property var pgup: () => {} + property var pgdn: () => {} signal close diff --git a/launcher/components/SelectionState.qml b/launcher/components/SelectionState.qml index 2e53155..6df7116 100644 --- a/launcher/components/SelectionState.qml +++ b/launcher/components/SelectionState.qml @@ -8,8 +8,18 @@ Singleton { property int cursorPosition: 0 property var priorities: [] property int selectedPriority: 0 + property int previousSelectedPriority: 0 property var widgets: [] + onSelectedPriorityChanged: { + if (selectedPriority > previousSelectedPriority) + priorities[selectedPriority].home(); + else + priorities[selectedPriority].end(); + + previousSelectedPriority = selectedPriority; + } + // order them based on widgets(which came from order from config) onPrioritiesChanged: { for (let i = priorities.length - 1; i >= 0; i--) diff --git a/launcher/components/Spell.qml b/launcher/components/Spell.qml index 4501132..5d45e0b 100644 --- a/launcher/components/Spell.qml +++ b/launcher/components/Spell.qml @@ -72,6 +72,19 @@ IComponent { }; } + home: function () { + if (loader.repeater.count === 0) + return true; + selectedIndex = -1; + selectedIndex = 0; + } + end: function () { + if (loader.repeater.count === 0) + return true; + selectedIndex = loader.repeater.count; + selectedIndex = loader.repeater.count - 1; + } + prev: function () { if (selectedIndex <= 0) return true; |
