1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-12 16:52:10 -04:00

dankbar: fix centering of numerous bar widgets

This commit is contained in:
bbedward
2026-02-03 13:44:57 -05:00
parent 24ce41935e
commit f59aeb2782
12 changed files with 52 additions and 46 deletions

View File

@@ -237,8 +237,8 @@ PanelWindow {
} }
readonly property int notificationCount: NotificationService.notifications.length 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 effectiveBarThickness: Theme.snap(Math.max(barWindow.widgetThickness + (barConfig?.innerPadding ?? 4) + 4, Theme.barHeight - 4 - (8 - (barConfig?.innerPadding ?? 4))), _dpr)
readonly property real widgetThickness: Math.max(20, 26 + (barConfig?.innerPadding ?? 4) * 0.6) readonly property real widgetThickness: Theme.snap(Math.max(20, 26 + (barConfig?.innerPadding ?? 4) * 0.6), _dpr)
readonly property bool hasAdjacentTopBar: { readonly property bool hasAdjacentTopBar: {
if (barConfig?.autoHide ?? false) if (barConfig?.autoHide ?? false)

View File

@@ -1,6 +1,4 @@
import QtQuick import QtQuick
import QtQuick.Controls
import Quickshell
import qs.Common import qs.Common
import qs.Modules.Plugins import qs.Modules.Plugins
import qs.Services import qs.Services
@@ -15,18 +13,28 @@ BasePill {
State { State {
name: "hidden_horizontal" name: "hidden_horizontal"
when: !DMSService.capsLockState && !isVerticalOrientation when: !DMSService.capsLockState && !isVerticalOrientation
PropertyChanges { target: root; width: 0 } PropertyChanges {
target: root
width: 0
}
}, },
State { State {
name: "hidden_vertical" name: "hidden_vertical"
when: !DMSService.capsLockState && isVerticalOrientation when: !DMSService.capsLockState && isVerticalOrientation
PropertyChanges { target: root; height: 0 } PropertyChanges {
target: root
height: 0
}
} }
] ]
transitions: [ transitions: [
Transition { 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 { content: Component {
Item { Item {
implicitWidth: root.widgetThickness - root.horizontalPadding * 2 implicitWidth: icon.width
implicitHeight: root.widgetThickness - root.horizontalPadding * 2 implicitHeight: root.widgetThickness - root.horizontalPadding * 2
DankIcon { DankIcon {
id: icon
anchors.centerIn: parent anchors.centerIn: parent
name: "shift_lock" name: "shift_lock"
size: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.noBackground) size: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.noBackground)

View File

@@ -79,10 +79,11 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.widgetThickness - root.horizontalPadding * 2 implicitWidth: icon.width
implicitHeight: root.widgetThickness - root.horizontalPadding * 2 implicitHeight: root.widgetThickness - root.horizontalPadding * 2
DankIcon { DankIcon {
id: icon
anchors.centerIn: parent anchors.centerIn: parent
name: "content_paste" name: "content_paste"
size: Theme.barIconSize(root.barThickness, -4, root.barConfig?.noBackground) size: Theme.barIconSize(root.barThickness, -4, root.barConfig?.noBackground)

View File

@@ -8,14 +8,15 @@ BasePill {
property bool isActive: false property bool isActive: false
signal colorPickerRequested() signal colorPickerRequested
content: Component { content: Component {
Item { Item {
implicitWidth: root.widgetThickness - root.horizontalPadding * 2 implicitWidth: icon.width
implicitHeight: root.widgetThickness - root.horizontalPadding * 2 implicitHeight: root.widgetThickness - root.horizontalPadding * 2
DankIcon { DankIcon {
id: icon
anchors.centerIn: parent anchors.centerIn: parent
name: "palette" name: "palette"
size: Theme.barIconSize(root.barThickness, -4, root.barConfig?.noBackground) size: Theme.barIconSize(root.barThickness, -4, root.barConfig?.noBackground)
@@ -29,7 +30,7 @@ BasePill {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onPressed: { onPressed: {
root.colorPickerRequested() root.colorPickerRequested();
} }
} }
} }

View File

@@ -1,6 +1,4 @@
import QtQuick import QtQuick
import QtQuick.Controls
import Quickshell
import qs.Common import qs.Common
import qs.Modules.Plugins import qs.Modules.Plugins
import qs.Services import qs.Services
@@ -11,10 +9,11 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.widgetThickness - root.horizontalPadding * 2 implicitWidth: icon.width
implicitHeight: root.widgetThickness - root.horizontalPadding * 2 implicitHeight: root.widgetThickness - root.horizontalPadding * 2
DankIcon { DankIcon {
id: icon
anchors.centerIn: parent anchors.centerIn: parent
name: SessionService.idleInhibited ? "motion_sensor_active" : "motion_sensor_idle" name: SessionService.idleInhibited ? "motion_sensor_active" : "motion_sensor_idle"
size: Theme.barIconSize(root.barThickness, -4, root.barConfig?.noBackground) size: Theme.barIconSize(root.barThickness, -4, root.barConfig?.noBackground)
@@ -28,7 +27,7 @@ BasePill {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
SessionService.toggleIdleInhibit() SessionService.toggleIdleInhibit();
} }
} }
} }

View File

@@ -10,27 +10,24 @@ import qs.Widgets
BasePill { BasePill {
id: root id: root
readonly property string focusedScreenName: ( 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 : "")
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() { function resolveNotepadInstance() {
if (typeof notepadSlideoutVariants === "undefined" || !notepadSlideoutVariants || !notepadSlideoutVariants.instances) { if (typeof notepadSlideoutVariants === "undefined" || !notepadSlideoutVariants || !notepadSlideoutVariants.instances) {
return null return null;
} }
const targetScreen = focusedScreenName const targetScreen = focusedScreenName;
if (targetScreen) { if (targetScreen) {
for (var i = 0; i < notepadSlideoutVariants.instances.length; i++) { 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) { 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() readonly property var notepadInstance: resolveNotepadInstance()
@@ -104,15 +101,11 @@ BasePill {
let anchorY = relativeY; let anchorY = relativeY;
if (isVertical) { if (isVertical) {
anchorX = edge === "left" anchorX = edge === "left" ? (root.barThickness + root.barSpacing + gap) : (screen.width - (root.barThickness + root.barSpacing + gap));
? (root.barThickness + root.barSpacing + gap)
: (screen.width - (root.barThickness + root.barSpacing + gap));
anchorY = relativeY + root.minTooltipY; anchorY = relativeY + root.minTooltipY;
} else { } else {
anchorX = relativeX; anchorX = relativeX;
anchorY = edge === "bottom" anchorY = edge === "bottom" ? (screen.height - (root.barThickness + root.barSpacing + gap)) : (root.barThickness + root.barSpacing + gap);
? (screen.height - (root.barThickness + root.barSpacing + gap))
: (root.barThickness + root.barSpacing + gap);
} }
contextMenuWindow.showAt(anchorX, anchorY, isVertical, edge, screen); contextMenuWindow.showAt(anchorX, anchorY, isVertical, edge, screen);
@@ -120,7 +113,7 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.widgetThickness - root.horizontalPadding * 2 implicitWidth: notepadIcon.width
implicitHeight: root.widgetThickness - root.horizontalPadding * 2 implicitHeight: root.widgetThickness - root.horizontalPadding * 2
DankIcon { DankIcon {
@@ -137,14 +130,14 @@ BasePill {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: function(mouse) { onClicked: function (mouse) {
if (mouse.button === Qt.RightButton) { if (mouse.button === Qt.RightButton) {
openContextMenu(); openContextMenu();
return; return;
} }
const inst = root.notepadInstance const inst = root.notepadInstance;
if (inst) { if (inst) {
inst.toggle() inst.toggle();
} }
} }
} }

View File

@@ -11,7 +11,7 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.widgetThickness - root.horizontalPadding * 2 implicitWidth: notifIcon.width
implicitHeight: root.widgetThickness - root.horizontalPadding * 2 implicitHeight: root.widgetThickness - root.horizontalPadding * 2
DankIcon { DankIcon {

View File

@@ -10,10 +10,11 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.widgetThickness - root.horizontalPadding * 2 implicitWidth: icon.width
implicitHeight: root.widgetThickness - root.horizontalPadding * 2 implicitHeight: root.widgetThickness - root.horizontalPadding * 2
DankIcon { DankIcon {
id: icon
anchors.centerIn: parent anchors.centerIn: parent
name: "power_settings_new" name: "power_settings_new"
size: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.noBackground) size: Theme.barIconSize(root.barThickness, undefined, root.barConfig?.noBackground)

View File

@@ -34,7 +34,7 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.widgetThickness - root.horizontalPadding * 2 implicitWidth: icon.width
implicitHeight: root.widgetThickness - root.horizontalPadding * 2 implicitHeight: root.widgetThickness - root.horizontalPadding * 2
DankIcon { DankIcon {

View File

@@ -1,5 +1,6 @@
import QtQuick import QtQuick
import qs.Common import qs.Common
import qs.Services
Item { Item {
id: root id: root
@@ -21,9 +22,10 @@ Item {
property bool isRightBarEdge: false property bool isRightBarEdge: false
property bool isTopBarEdge: false property bool isTopBarEdge: false
property bool isBottomBarEdge: false property bool isBottomBarEdge: false
readonly property real horizontalPadding: (barConfig?.noBackground ?? false) ? 0 : Math.max(Theme.spacingXS, Theme.spacingS * (widgetThickness / 30)) readonly property real dpr: parentScreen ? CompositorService.getScreenScale(parentScreen) : 1
readonly property real visualWidth: isVerticalOrientation ? widgetThickness : (contentLoader.item ? (contentLoader.item.implicitWidth + horizontalPadding * 2) : 0) readonly property real horizontalPadding: (barConfig?.noBackground ?? false) ? 0 : Theme.snap(Math.max(Theme.spacingXS, Theme.spacingS * (widgetThickness / 30)), dpr)
readonly property real visualHeight: isVerticalOrientation ? (contentLoader.item ? (contentLoader.item.implicitHeight + horizontalPadding * 2) : 0) : widgetThickness 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 alias visualContent: visualContent
readonly property real barEdgeExtension: 1000 readonly property real barEdgeExtension: 1000
readonly property real gapExtension: sectionSpacing readonly property real gapExtension: sectionSpacing

View File

@@ -73,7 +73,7 @@ Rectangle {
AppIconRenderer { AppIconRenderer {
anchors.centerIn: parent anchors.centerIn: parent
width: parent.width * 0.75 width: Math.round(parent.width * 0.75)
height: width height: width
visible: (internalImage.status !== Image.Ready || root.imageSource === "") && root.fallbackIcon !== "" visible: (internalImage.status !== Image.Ready || root.imageSource === "") && root.fallbackIcon !== ""
iconValue: root.fallbackIcon iconValue: root.fallbackIcon

View File

@@ -12,10 +12,10 @@ Item {
property int grade: Theme.isLightMode ? 0 : -25 property int grade: Theme.isLightMode ? 0 : -25
property int weight: filled ? 500 : 400 property int weight: filled ? 500 : 400
implicitWidth: icon.implicitWidth implicitWidth: Math.round(size)
implicitHeight: icon.implicitHeight implicitHeight: Math.round(size)
signal rotationCompleted() signal rotationCompleted
FontLoader { FontLoader {
id: materialSymbolsFont id: materialSymbolsFont
@@ -64,6 +64,6 @@ Item {
} }
onRotationChanged: { onRotationChanged: {
rotationTimer.restart() rotationTimer.restart();
} }
} }