From 468a145514756f6bd4ed7a2f35b5b62657df8994 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 27 Oct 2026 20:25:35 +0800 Subject: Launcher: launch position sync with bar center --- SharedState.qml | 9 +++++++++ bar/Bar.qml | 6 ++++++ popups/launcher/Launcher.qml | 17 ++++++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 SharedState.qml diff --git a/SharedState.qml b/SharedState.qml new file mode 100644 index 0000000..24ddd11 --- /dev/null +++ b/SharedState.qml @@ -0,0 +1,9 @@ +pragma Singleton +import Quickshell +import QtQuick + +Singleton { + id: root + + property int centerBarWidth +} diff --git a/bar/Bar.qml b/bar/Bar.qml index 2ad13d1..372f6f4 100644 --- a/bar/Bar.qml +++ b/bar/Bar.qml @@ -3,6 +3,8 @@ import Quickshell import QtQuick.Layouts import qs.components import qs.config +import "../popups/launcher" +import ".." Scope { id: root @@ -84,6 +86,10 @@ Scope { ActiveWindow { id: activeWindow width: Math.min(implicitWidth, child.width - Math.max(leftRow.width, rightRow.width) * 2 - Bar.leftMargin - Bar.rightMargin) // we don't do child.width - leftRow.width - rightRow.width because left and right width isn't symetric, and we're centered meaning we will colide into the larger width side + // i could do implicitWidth but that wouldnt be the immediate width + onWidthChanged: { + SharedState.centerBarWidth = width; + } } } diff --git a/popups/launcher/Launcher.qml b/popups/launcher/Launcher.qml index 93aa0e0..c6673b7 100644 --- a/popups/launcher/Launcher.qml +++ b/popups/launcher/Launcher.qml @@ -5,8 +5,8 @@ import QtQuick.Layouts import "components" import qs.components import qs.config +import "../.." -// TODO: currently, we're relying on the compositor to provide the animation which ig is fine, but we should use our own in the future, however it might look weird combined with the compositors's ILauncher { id: launcher @@ -23,6 +23,7 @@ ILauncher { id: container property var selection: launcher.state?.selected property var mappedSelection: selection?.mapToItem(null, 0, 0) + property real openProgress: 0 onMappedSelectionChanged: { // launcher.state?.selected may be slow.. smh qt @@ -88,9 +89,15 @@ ILauncher { color: Qt.rgba(Colors.background3.r, Colors.background3.g, Colors.background3.b, Launcher.bgTransparency) radius: Launcher.borderRadius - width: Math.max(root.width, Launcher.defaultWidth) + Launcher.innerMargin + width: SharedState.centerBarWidth + (Math.max(root.width, Launcher.defaultWidth) + Launcher.innerMargin - SharedState.centerBarWidth) * openProgress height: root.height + ISpringAnimation on openProgress { + from: 0 + to: 1 + running: true + } + IRect { id: root property alias input: textInput.text @@ -131,11 +138,11 @@ ILauncher { property bool pendingUpdate: false Keys.onPressed: event => { if (event.key === Qt.Key_End || event.key === Qt.Key_Home) { - if (event.key === Qt.Key_End) { + if (event.key === Qt.Key_End) endShortcut.activated(); - } else if (event.key === Qt.Key_Home) { + else if (event.key === Qt.Key_Home) homeShortcut.activated(); - } + event.accepted = true; } } -- cgit v1.2.3