1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-04 04:42:05 -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 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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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();
}
}
}

View File

@@ -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();
}
}
}

View File

@@ -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();
}
}
}

View File

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

View File

@@ -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)

View File

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