1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -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 {

View File

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

View File

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

View File

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