From b3a3975461e3ab4f3555a210595f3e98f173c566 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Mon, 9 Jun 2025 23:29:52 +0200 Subject: [PATCH] dock: fix alignment --- .config/quickshell/modules/dock/Dock.qml | 8 +- .config/quickshell/modules/dock/DockApps.qml | 99 ++++++++++--------- .../quickshell/modules/dock/DockButton.qml | 5 +- .../quickshell/modules/dock/DockSeparator.qml | 4 +- 4 files changed, 63 insertions(+), 53 deletions(-) diff --git a/.config/quickshell/modules/dock/Dock.qml b/.config/quickshell/modules/dock/Dock.qml index 25846ac5f..a03a3f562 100644 --- a/.config/quickshell/modules/dock/Dock.qml +++ b/.config/quickshell/modules/dock/Dock.qml @@ -88,7 +88,7 @@ Scope { // Scope id: dockVisualBackground property real margin: Appearance.sizes.elevationMargin anchors.fill: parent - anchors.topMargin: margin + anchors.topMargin: Appearance.sizes.elevationMargin anchors.bottomMargin: Appearance.sizes.hyprlandGapsOut color: Appearance.colors.colLayer0 radius: Appearance.rounding.large @@ -103,6 +103,7 @@ Scope { // Scope property real padding: 5 VerticalButtonGroup { + Layout.topMargin: Appearance.sizes.hyprlandGapsOut // why does this work GroupButton { // Pin button baseWidth: 35 baseHeight: 35 @@ -120,12 +121,13 @@ Scope { // Scope } } DockSeparator {} - DockApps { id: dockApps } + DockApps { id: dockApps; } DockSeparator {} DockButton { + Layout.fillHeight: true onClicked: Hyprland.dispatch("global quickshell:overviewToggle") contentItem: MaterialSymbol { - anchors.centerIn: parent + anchors.fill: parent horizontalAlignment: Text.AlignHCenter font.pixelSize: parent.width / 2 text: "apps" diff --git a/.config/quickshell/modules/dock/DockApps.qml b/.config/quickshell/modules/dock/DockApps.qml index 900db0ca0..8b680c51a 100644 --- a/.config/quickshell/modules/dock/DockApps.qml +++ b/.config/quickshell/modules/dock/DockApps.qml @@ -23,59 +23,66 @@ Item { property Item lastHoveredButton property bool buttonHovered: false property bool requestDockShow: previewPopup.show - property var parentWindow: root.QsWindow - property real popupX: parentWindow?.mapFromItem(root.lastHoveredButton, root.lastHoveredButton?.width / 2, root.lastHoveredButton?.height / 2).x - implicitWidth / 2 - ?? 0 - implicitWidth: rowLayout.implicitWidth - implicitHeight: rowLayout.implicitHeight - RowLayout { - id: rowLayout + Layout.fillHeight: true + Layout.topMargin: Appearance.sizes.hyprlandGapsOut // why does this work + implicitWidth: listView.implicitWidth + + StyledListView { + id: listView spacing: 2 + orientation: ListView.Horizontal + anchors { + top: parent.top + bottom: parent.bottom + } + implicitWidth: contentWidth - Repeater { - model: ScriptModel { - objectProp: "appId" - values: { - var map = new Map(); + Behavior on implicitWidth { + animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) + } - // Pinned apps - const pinnedApps = ConfigOptions?.dock.pinnedApps ?? []; - for (const appId of pinnedApps) { - if (!map.has(appId.toLowerCase())) map.set(appId.toLowerCase(), ({ - pinned: true, - toplevels: [] - })); - } + model: ScriptModel { + objectProp: "appId" + values: { + var map = new Map(); - // Separator - if (pinnedApps.length > 0) { - map.set("SEPARATOR", { pinned: false, toplevels: [] }); - } - - // Open windows - for (const toplevel of ToplevelManager.toplevels.values) { - if (!map.has(toplevel.appId.toLowerCase())) map.set(toplevel.appId.toLowerCase(), ({ - pinned: false, - toplevels: [] - })); - map.get(toplevel.appId.toLowerCase()).toplevels.push(toplevel); - } - - var values = []; - - for (const [key, value] of map) { - values.push({ appId: key, toplevels: value.toplevels, pinned: value.pinned }); - } - - return values; + // Pinned apps + const pinnedApps = ConfigOptions?.dock.pinnedApps ?? []; + for (const appId of pinnedApps) { + if (!map.has(appId.toLowerCase())) map.set(appId.toLowerCase(), ({ + pinned: true, + toplevels: [] + })); } + + // Separator + if (pinnedApps.length > 0) { + map.set("SEPARATOR", { pinned: false, toplevels: [] }); + } + + // Open windows + for (const toplevel of ToplevelManager.toplevels.values) { + if (!map.has(toplevel.appId.toLowerCase())) map.set(toplevel.appId.toLowerCase(), ({ + pinned: false, + toplevels: [] + })); + map.get(toplevel.appId.toLowerCase()).toplevels.push(toplevel); + } + + var values = []; + + for (const [key, value] of map) { + values.push({ appId: key, toplevels: value.toplevels, pinned: value.pinned }); + } + + return values; } - delegate: DockAppButton { - required property var modelData - appToplevel: modelData - appListRoot: root - } + } + delegate: DockAppButton { + required property var modelData + appToplevel: modelData + appListRoot: root } } diff --git a/.config/quickshell/modules/dock/DockButton.qml b/.config/quickshell/modules/dock/DockButton.qml index 6c3010bf6..577cbcdc7 100644 --- a/.config/quickshell/modules/dock/DockButton.qml +++ b/.config/quickshell/modules/dock/DockButton.qml @@ -7,9 +7,10 @@ import QtQuick.Layouts RippleButton { Layout.fillHeight: true + Layout.topMargin: Appearance.sizes.elevationMargin - Appearance.sizes.hyprlandGapsOut implicitWidth: implicitHeight - topInset - bottomInset buttonRadius: Appearance.rounding.normal - topInset: dockVisualBackground.margin + dockRow.padding - bottomInset: dockVisualBackground.margin + dockRow.padding + topInset: Appearance.sizes.hyprlandGapsOut + dockRow.padding + bottomInset: Appearance.sizes.hyprlandGapsOut + dockRow.padding } diff --git a/.config/quickshell/modules/dock/DockSeparator.qml b/.config/quickshell/modules/dock/DockSeparator.qml index 2b27b0daf..29b77d492 100644 --- a/.config/quickshell/modules/dock/DockSeparator.qml +++ b/.config/quickshell/modules/dock/DockSeparator.qml @@ -5,8 +5,8 @@ import QtQuick.Controls import QtQuick.Layouts Rectangle { - Layout.topMargin: dockVisualBackground.margin + dockRow.padding + Appearance.rounding.normal - Layout.bottomMargin: dockVisualBackground.margin + dockRow.padding + Appearance.rounding.normal + Layout.topMargin: Appearance.sizes.elevationMargin + dockRow.padding + Appearance.rounding.normal + Layout.bottomMargin: Appearance.sizes.hyprlandGapsOut + dockRow.padding + Appearance.rounding.normal Layout.fillHeight: true implicitWidth: 1 color: Appearance.m3colors.m3outlineVariant