From 04d4670f933431f5deaad4b2045baeccc2a4494e Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 23 Aug 2026 11:59:36 +0800 Subject: fix: don't set priority to -1 when indexOf returns that --- bar/Workspace.qml | 2 +- components/ISpringAnimation.qml | 6 ++-- popups/launcher/Launcher.qml | 44 ++++++++++++++++----------- popups/launcher/components/App.qml | 2 +- popups/launcher/components/Clip.qml | 6 ++-- popups/launcher/components/Emoji.qml | 4 +-- popups/launcher/components/IComponent.qml | 20 ++++++++---- popups/launcher/components/SelectionState.qml | 12 +------- popups/launcher/components/Spell.qml | 2 +- shell.qml | 1 + 10 files changed, 55 insertions(+), 44 deletions(-) diff --git a/bar/Workspace.qml b/bar/Workspace.qml index 662b9e2..a0f5f0e 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -234,7 +234,7 @@ Item { // no idea wats wrong w/ prev so we just unify it to use +/- 1 if (event.angleDelta.y < 0) { if (activeIndex + 1 < Bar.wss) - Hyprland.dispatch(`hl.dsp.focus({ workspace = '+1' })`); + Hyprland.dispatch(`hl.dsp.focus({ workspace = '+1' })`); else Hyprland.dispatch(`hl.dsp.focus({ workspace = '1' })`); } else if (event.angleDelta.y > 0) { diff --git a/components/ISpringAnimation.qml b/components/ISpringAnimation.qml index 099cab4..0d13b59 100644 --- a/components/ISpringAnimation.qml +++ b/components/ISpringAnimation.qml @@ -2,6 +2,8 @@ import QtQuick import qs.config SpringAnimation { - spring: General.springAnimationSpring - damping: General.springAnimationDamping + property real speed: 1.0 + + spring: General.springAnimationSpring * (speed * speed) + damping: General.springAnimationDamping * (speed) } diff --git a/popups/launcher/Launcher.qml b/popups/launcher/Launcher.qml index f59722c..fdc14c6 100644 --- a/popups/launcher/Launcher.qml +++ b/popups/launcher/Launcher.qml @@ -15,15 +15,6 @@ ILauncher { name: "quickshell::launcher::launcher" - Connections { - target: parentLoader - function onActiveChanged() { - if (!parentLoader.active && launcher.state) { - launcher.state.selected = null; - } - } - } - anchors.top: true margins.top: Launcher.topMargin aboveWindows: true @@ -65,16 +56,31 @@ ILauncher { radius: Launcher.borderRadius color: Qt.rgba(Colors.background1.r, Colors.background1.g, Colors.background1.b, Launcher.bgTransparency) Behavior on x { - ISpringAnimation {} + ISpringAnimation { + id: springAnim + speed: 1.5 + } } Behavior on y { - ISpringAnimation {} + ISpringAnimation { + speed: 1.5 + } } Behavior on implicitWidth { - ISpringAnimation {} + NumberAnimation { + duration: springAnim.duration + easing.type: Easing.BezierSpline + // fast slow + easing.bezierCurve: [0.33, 0.8, 0, 1] + } } - Behavior on height { - ISpringAnimation {} + Behavior on implicitHeight { + NumberAnimation { + duration: springAnim.duration + easing.type: Easing.BezierSpline + // fast slow + easing.bezierCurve: [0.33, 0.8, 0, 1] + } } } color: Qt.rgba(Colors.background3.r, Colors.background3.g, Colors.background3.b, Launcher.bgTransparency) @@ -375,7 +381,7 @@ ILauncher { // 2 = up // -2 = down function changePos(direction: int) { - const item = launcher.state?.priorities[launcher.state.selectedPriority] || null; + const item = launcher.state?.priorities[launcher.state.selectedPriority]; if (!item) return; @@ -418,12 +424,16 @@ ILauncher { switch (set) { case 1: - if (launcher.state.selectedPriority < launcher.state.priorities.length - 1) + if (launcher.state.selectedPriority < launcher.state.priorities.length - 1) { launcher.state.selectedPriority++; + launcher.state.priorities[launcher.state.selectedPriority].home(); + } break; case -1: - if (launcher.state.selectedPriority > 0) + if (launcher.state.selectedPriority > 0) { launcher.state.selectedPriority--; + launcher.state.priorities[launcher.state.selectedPriority].end(); + } break; } } diff --git a/popups/launcher/components/App.qml b/popups/launcher/components/App.qml index a6616c4..964211d 100644 --- a/popups/launcher/components/App.qml +++ b/popups/launcher/components/App.qml @@ -111,7 +111,7 @@ IComponent { if (selectedIndex < 0 || selectedIndex >= listView.count || !root.visible) return; - state.selectedPriority = root.getSelfPriority(); + trySetSelfPriority(); state.selected = listView.itemAtIndex(selectedIndex); }); } diff --git a/popups/launcher/components/Clip.qml b/popups/launcher/components/Clip.qml index 2552b60..ebcc8c4 100644 --- a/popups/launcher/components/Clip.qml +++ b/popups/launcher/components/Clip.qml @@ -65,11 +65,11 @@ IComponent { } onSelectedIndexChanged: { - if (selectedIndex >= 0 && selectedIndex < listView.count) { + if (selectedIndex >= 0 && selectedIndex < listView.count) Qt.callLater(() => { listView.positionViewAtIndex(selectedIndex, ListView.Contain); }); - } + syncSelectionState(); } @@ -78,7 +78,7 @@ IComponent { if (!root.visible || selectedIndex < 0 || selectedIndex >= listView.count) return; - state.selectedPriority = root.getSelfPriority(); + trySetSelfPriority(); state.selected = listView.itemAtIndex(selectedIndex); }); } diff --git a/popups/launcher/components/Emoji.qml b/popups/launcher/components/Emoji.qml index 62412d7..36aacb0 100644 --- a/popups/launcher/components/Emoji.qml +++ b/popups/launcher/components/Emoji.qml @@ -95,7 +95,7 @@ IComponent { if (!loader.view || selectedIndex < 0 || selectedIndex >= loader.view.count || !root.visible) return; - state.selectedPriority = root.getSelfPriority(); + trySetSelfPriority(); state.selected = loader.view.itemAtIndex(selectedIndex); }); } @@ -134,7 +134,7 @@ IComponent { required property int index width: grid.cellWidth height: chipContent.implicitHeight + Launcher.innerMargin * 2 - scale: index === selectedIndex ? 1.03 : 0.97 + scale: index === root.selectedIndex ? 1.03 : 0.97 IRect { anchors.fill: parent diff --git a/popups/launcher/components/IComponent.qml b/popups/launcher/components/IComponent.qml index 4333998..e06ed98 100644 --- a/popups/launcher/components/IComponent.qml +++ b/popups/launcher/components/IComponent.qml @@ -64,6 +64,13 @@ IRect { return state.priorities.indexOf(root); } + function trySetSelfPriority() { + let self = getSelfPriority(); + // ??? why tf is it -1 not null or undefined this is why rust is better + if (self !== -1) + state.selectedPriority = self; + } + // this doesn't change launcher size but only hides the actual content but the outside still think the content is there visible: active opacity: valid ? 1 : 0 @@ -98,13 +105,14 @@ IRect { HoverHandler { onHoveredChanged: { if (hovered) - root.state.selectedPriority = root.getSelfPriority(); + root.trySetSelfPriority(); } } - Component.onCompleted: { - Qt.callLater(() => { - syncSelectionState(); - }); - } + // causes all of them fighting for selection state + // Component.onCompleted: { + // Qt.callLater(() => { + // syncSelectionState(); + // }); + // } } diff --git a/popups/launcher/components/SelectionState.qml b/popups/launcher/components/SelectionState.qml index d999baa..4231234 100644 --- a/popups/launcher/components/SelectionState.qml +++ b/popups/launcher/components/SelectionState.qml @@ -27,17 +27,7 @@ Singleton { signal syncSelectionState onSelectedPriorityChanged: { - // so it won't mess w/ if we changed it via mouse - if (Math.abs(selectedPriority - previousSelectedPriority) == 1) { - if (selectedPriority > previousSelectedPriority) { - priorities[selectedPriority].home(); - } else { - priorities[selectedPriority].end(); - } - } - priorities[selectedPriority].syncSelectionState(); - - previousSelectedPriority = selectedPriority; + priorities[selectedPriority]?.syncSelectionState(); } // order them based on widgets(which came from order from config) diff --git a/popups/launcher/components/Spell.qml b/popups/launcher/components/Spell.qml index 5bb128d..5e62ae8 100644 --- a/popups/launcher/components/Spell.qml +++ b/popups/launcher/components/Spell.qml @@ -118,7 +118,7 @@ IComponent { if (!loader.view || selectedIndex < 0 || selectedIndex >= loader.view.count || !root.visible) return; - state.selectedPriority = root.getSelfPriority(); + trySetSelfPriority(); state.selected = loader.view.itemAtIndex(selectedIndex); }); } diff --git a/shell.qml b/shell.qml index 08712da..1e6ce11 100644 --- a/shell.qml +++ b/shell.qml @@ -61,6 +61,7 @@ Scope { import "popups/launcher/components" LazyLoader { + // TODO: just use the same selectionState property QtObject selectionState: QtObject { property Item selected: null property string input: "" -- cgit v1.2.3