From f59aeb27826082cb0331e6f3f29fa5308f12fc4b Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 3 Feb 2026 13:44:57 -0500 Subject: [PATCH] dankbar: fix centering of numerous bar widgets --- quickshell/Modules/DankBar/DankBarWindow.qml | 4 +-- .../DankBar/Widgets/CapsLockIndicator.qml | 21 +++++++++---- .../DankBar/Widgets/ClipboardButton.qml | 3 +- .../Modules/DankBar/Widgets/ColorPicker.qml | 7 +++-- .../Modules/DankBar/Widgets/IdleInhibitor.qml | 7 ++--- .../Modules/DankBar/Widgets/NotepadButton.qml | 31 +++++++------------ .../Widgets/NotificationCenterButton.qml | 2 +- .../DankBar/Widgets/PowerMenuButton.qml | 3 +- quickshell/Modules/DankBar/Widgets/Vpn.qml | 2 +- quickshell/Modules/Plugins/BasePill.qml | 8 +++-- quickshell/Widgets/DankCircularImage.qml | 2 +- quickshell/Widgets/DankIcon.qml | 8 ++--- 12 files changed, 52 insertions(+), 46 deletions(-) diff --git a/quickshell/Modules/DankBar/DankBarWindow.qml b/quickshell/Modules/DankBar/DankBarWindow.qml index 2fb85260..c51f318c 100644 --- a/quickshell/Modules/DankBar/DankBarWindow.qml +++ b/quickshell/Modules/DankBar/DankBarWindow.qml @@ -237,8 +237,8 @@ PanelWindow { } readonly property int notificationCount: NotificationService.notifications.length - readonly property real effectiveBarThickness: Math.max(barWindow.widgetThickness + (barConfig?.innerPadding ?? 4) + 4, Theme.barHeight - 4 - (8 - (barConfig?.innerPadding ?? 4))) - readonly property real widgetThickness: Math.max(20, 26 + (barConfig?.innerPadding ?? 4) * 0.6) + readonly property real effectiveBarThickness: Theme.snap(Math.max(barWindow.widgetThickness + (barConfig?.innerPadding ?? 4) + 4, Theme.barHeight - 4 - (8 - (barConfig?.innerPadding ?? 4))), _dpr) + readonly property real widgetThickness: Theme.snap(Math.max(20, 26 + (barConfig?.innerPadding ?? 4) * 0.6), _dpr) readonly property bool hasAdjacentTopBar: { if (barConfig?.autoHide ?? false) diff --git a/quickshell/Modules/DankBar/Widgets/CapsLockIndicator.qml b/quickshell/Modules/DankBar/Widgets/CapsLockIndicator.qml index c67295c4..e346fcd4 100644 --- a/quickshell/Modules/DankBar/Widgets/CapsLockIndicator.qml +++ b/quickshell/Modules/DankBar/Widgets/CapsLockIndicator.qml @@ -1,6 +1,4 @@ import QtQuick -import QtQuick.Controls -import Quickshell import qs.Common import qs.Modules.Plugins import qs.Services @@ -15,18 +13,28 @@ BasePill { State { name: "hidden_horizontal" when: !DMSService.capsLockState && !isVerticalOrientation - PropertyChanges { target: root; width: 0 } + PropertyChanges { + target: root + width: 0 + } }, State { name: "hidden_vertical" when: !DMSService.capsLockState && isVerticalOrientation - PropertyChanges { target: root; height: 0 } + PropertyChanges { + target: root + height: 0 + } } ] transitions: [ Transition { - NumberAnimation { properties: "width,height"; duration: Theme.shortDuration; easing.type: Theme.standardEasing } + NumberAnimation { + properties: "width,height" + duration: Theme.shortDuration + easing.type: Theme.standardEasing + } } ] @@ -39,10 +47,11 @@ BasePill { content: Component { Item { - implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitWidth: icon.width implicitHeight: root.widgetThickness - root.horizontalPadding * 2 DankIcon { + id: icon anchors.centerIn: parent name: "shift_lock" size: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.noBackground) diff --git a/quickshell/Modules/DankBar/Widgets/ClipboardButton.qml b/quickshell/Modules/DankBar/Widgets/ClipboardButton.qml index 68e83111..0da3f4b2 100644 --- a/quickshell/Modules/DankBar/Widgets/ClipboardButton.qml +++ b/quickshell/Modules/DankBar/Widgets/ClipboardButton.qml @@ -79,10 +79,11 @@ BasePill { content: Component { Item { - implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitWidth: icon.width implicitHeight: root.widgetThickness - root.horizontalPadding * 2 DankIcon { + id: icon anchors.centerIn: parent name: "content_paste" size: Theme.barIconSize(root.barThickness, -4, root.barConfig?.noBackground) diff --git a/quickshell/Modules/DankBar/Widgets/ColorPicker.qml b/quickshell/Modules/DankBar/Widgets/ColorPicker.qml index b24a1948..b3639d31 100644 --- a/quickshell/Modules/DankBar/Widgets/ColorPicker.qml +++ b/quickshell/Modules/DankBar/Widgets/ColorPicker.qml @@ -8,14 +8,15 @@ BasePill { property bool isActive: false - signal colorPickerRequested() + signal colorPickerRequested content: Component { Item { - implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitWidth: icon.width implicitHeight: root.widgetThickness - root.horizontalPadding * 2 DankIcon { + id: icon anchors.centerIn: parent name: "palette" size: Theme.barIconSize(root.barThickness, -4, root.barConfig?.noBackground) @@ -29,7 +30,7 @@ BasePill { anchors.fill: parent cursorShape: Qt.PointingHandCursor onPressed: { - root.colorPickerRequested() + root.colorPickerRequested(); } } } diff --git a/quickshell/Modules/DankBar/Widgets/IdleInhibitor.qml b/quickshell/Modules/DankBar/Widgets/IdleInhibitor.qml index 2e8ea251..b7efe3f3 100644 --- a/quickshell/Modules/DankBar/Widgets/IdleInhibitor.qml +++ b/quickshell/Modules/DankBar/Widgets/IdleInhibitor.qml @@ -1,6 +1,4 @@ import QtQuick -import QtQuick.Controls -import Quickshell import qs.Common import qs.Modules.Plugins import qs.Services @@ -11,10 +9,11 @@ BasePill { content: Component { Item { - implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitWidth: icon.width implicitHeight: root.widgetThickness - root.horizontalPadding * 2 DankIcon { + id: icon anchors.centerIn: parent name: SessionService.idleInhibited ? "motion_sensor_active" : "motion_sensor_idle" size: Theme.barIconSize(root.barThickness, -4, root.barConfig?.noBackground) @@ -28,7 +27,7 @@ BasePill { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - SessionService.toggleIdleInhibit() + SessionService.toggleIdleInhibit(); } } } diff --git a/quickshell/Modules/DankBar/Widgets/NotepadButton.qml b/quickshell/Modules/DankBar/Widgets/NotepadButton.qml index b61b8e4c..06eb961b 100644 --- a/quickshell/Modules/DankBar/Widgets/NotepadButton.qml +++ b/quickshell/Modules/DankBar/Widgets/NotepadButton.qml @@ -10,27 +10,24 @@ import qs.Widgets BasePill { id: root - readonly property string focusedScreenName: ( - CompositorService.isHyprland && typeof Hyprland !== "undefined" && Hyprland.focusedWorkspace && Hyprland.focusedWorkspace.monitor ? (Hyprland.focusedWorkspace.monitor.name || "") : - CompositorService.isNiri && typeof NiriService !== "undefined" && NiriService.currentOutput ? NiriService.currentOutput : "" - ) + readonly property string focusedScreenName: (CompositorService.isHyprland && typeof Hyprland !== "undefined" && Hyprland.focusedWorkspace && Hyprland.focusedWorkspace.monitor ? (Hyprland.focusedWorkspace.monitor.name || "") : CompositorService.isNiri && typeof NiriService !== "undefined" && NiriService.currentOutput ? NiriService.currentOutput : "") function resolveNotepadInstance() { if (typeof notepadSlideoutVariants === "undefined" || !notepadSlideoutVariants || !notepadSlideoutVariants.instances) { - return null + return null; } - const targetScreen = focusedScreenName + const targetScreen = focusedScreenName; if (targetScreen) { for (var i = 0; i < notepadSlideoutVariants.instances.length; i++) { - var slideout = notepadSlideoutVariants.instances[i] + var slideout = notepadSlideoutVariants.instances[i]; if (slideout.modelData && slideout.modelData.name === targetScreen) { - return slideout + return slideout; } } } - return notepadSlideoutVariants.instances.length > 0 ? notepadSlideoutVariants.instances[0] : null + return notepadSlideoutVariants.instances.length > 0 ? notepadSlideoutVariants.instances[0] : null; } readonly property var notepadInstance: resolveNotepadInstance() @@ -104,15 +101,11 @@ BasePill { let anchorY = relativeY; if (isVertical) { - anchorX = edge === "left" - ? (root.barThickness + root.barSpacing + gap) - : (screen.width - (root.barThickness + root.barSpacing + gap)); + anchorX = edge === "left" ? (root.barThickness + root.barSpacing + gap) : (screen.width - (root.barThickness + root.barSpacing + gap)); anchorY = relativeY + root.minTooltipY; } else { anchorX = relativeX; - anchorY = edge === "bottom" - ? (screen.height - (root.barThickness + root.barSpacing + gap)) - : (root.barThickness + root.barSpacing + gap); + anchorY = edge === "bottom" ? (screen.height - (root.barThickness + root.barSpacing + gap)) : (root.barThickness + root.barSpacing + gap); } contextMenuWindow.showAt(anchorX, anchorY, isVertical, edge, screen); @@ -120,7 +113,7 @@ BasePill { content: Component { Item { - implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitWidth: notepadIcon.width implicitHeight: root.widgetThickness - root.horizontalPadding * 2 DankIcon { @@ -137,14 +130,14 @@ BasePill { MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: function(mouse) { + onClicked: function (mouse) { if (mouse.button === Qt.RightButton) { openContextMenu(); return; } - const inst = root.notepadInstance + const inst = root.notepadInstance; if (inst) { - inst.toggle() + inst.toggle(); } } } diff --git a/quickshell/Modules/DankBar/Widgets/NotificationCenterButton.qml b/quickshell/Modules/DankBar/Widgets/NotificationCenterButton.qml index 14699b4f..65c24d39 100644 --- a/quickshell/Modules/DankBar/Widgets/NotificationCenterButton.qml +++ b/quickshell/Modules/DankBar/Widgets/NotificationCenterButton.qml @@ -11,7 +11,7 @@ BasePill { content: Component { Item { - implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitWidth: notifIcon.width implicitHeight: root.widgetThickness - root.horizontalPadding * 2 DankIcon { diff --git a/quickshell/Modules/DankBar/Widgets/PowerMenuButton.qml b/quickshell/Modules/DankBar/Widgets/PowerMenuButton.qml index cf097f72..4ec73a3f 100644 --- a/quickshell/Modules/DankBar/Widgets/PowerMenuButton.qml +++ b/quickshell/Modules/DankBar/Widgets/PowerMenuButton.qml @@ -10,10 +10,11 @@ BasePill { content: Component { Item { - implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitWidth: icon.width implicitHeight: root.widgetThickness - root.horizontalPadding * 2 DankIcon { + id: icon anchors.centerIn: parent name: "power_settings_new" size: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.noBackground) diff --git a/quickshell/Modules/DankBar/Widgets/Vpn.qml b/quickshell/Modules/DankBar/Widgets/Vpn.qml index 5eea4791..543c389e 100644 --- a/quickshell/Modules/DankBar/Widgets/Vpn.qml +++ b/quickshell/Modules/DankBar/Widgets/Vpn.qml @@ -34,7 +34,7 @@ BasePill { content: Component { Item { - implicitWidth: root.widgetThickness - root.horizontalPadding * 2 + implicitWidth: icon.width implicitHeight: root.widgetThickness - root.horizontalPadding * 2 DankIcon { diff --git a/quickshell/Modules/Plugins/BasePill.qml b/quickshell/Modules/Plugins/BasePill.qml index bb3d6c0d..38558361 100644 --- a/quickshell/Modules/Plugins/BasePill.qml +++ b/quickshell/Modules/Plugins/BasePill.qml @@ -1,5 +1,6 @@ import QtQuick import qs.Common +import qs.Services Item { id: root @@ -21,9 +22,10 @@ Item { property bool isRightBarEdge: false property bool isTopBarEdge: false property bool isBottomBarEdge: false - readonly property real horizontalPadding: (barConfig?.noBackground ?? false) ? 0 : Math.max(Theme.spacingXS, Theme.spacingS * (widgetThickness / 30)) - readonly property real visualWidth: isVerticalOrientation ? widgetThickness : (contentLoader.item ? (contentLoader.item.implicitWidth + horizontalPadding * 2) : 0) - readonly property real visualHeight: isVerticalOrientation ? (contentLoader.item ? (contentLoader.item.implicitHeight + horizontalPadding * 2) : 0) : widgetThickness + readonly property real dpr: parentScreen ? CompositorService.getScreenScale(parentScreen) : 1 + readonly property real horizontalPadding: (barConfig?.noBackground ?? false) ? 0 : Theme.snap(Math.max(Theme.spacingXS, Theme.spacingS * (widgetThickness / 30)), dpr) + readonly property real visualWidth: Theme.snap(isVerticalOrientation ? widgetThickness : (contentLoader.item ? (contentLoader.item.implicitWidth + horizontalPadding * 2) : 0), dpr) + readonly property real visualHeight: Theme.snap(isVerticalOrientation ? (contentLoader.item ? (contentLoader.item.implicitHeight + horizontalPadding * 2) : 0) : widgetThickness, dpr) readonly property alias visualContent: visualContent readonly property real barEdgeExtension: 1000 readonly property real gapExtension: sectionSpacing diff --git a/quickshell/Widgets/DankCircularImage.qml b/quickshell/Widgets/DankCircularImage.qml index 5e6fcb11..c82e0c4e 100644 --- a/quickshell/Widgets/DankCircularImage.qml +++ b/quickshell/Widgets/DankCircularImage.qml @@ -73,7 +73,7 @@ Rectangle { AppIconRenderer { anchors.centerIn: parent - width: parent.width * 0.75 + width: Math.round(parent.width * 0.75) height: width visible: (internalImage.status !== Image.Ready || root.imageSource === "") && root.fallbackIcon !== "" iconValue: root.fallbackIcon diff --git a/quickshell/Widgets/DankIcon.qml b/quickshell/Widgets/DankIcon.qml index 66362c8c..0c53cb70 100644 --- a/quickshell/Widgets/DankIcon.qml +++ b/quickshell/Widgets/DankIcon.qml @@ -12,10 +12,10 @@ Item { property int grade: Theme.isLightMode ? 0 : -25 property int weight: filled ? 500 : 400 - implicitWidth: icon.implicitWidth - implicitHeight: icon.implicitHeight + implicitWidth: Math.round(size) + implicitHeight: Math.round(size) - signal rotationCompleted() + signal rotationCompleted FontLoader { id: materialSymbolsFont @@ -64,6 +64,6 @@ Item { } onRotationChanged: { - rotationTimer.restart() + rotationTimer.restart(); } }