quickshell: snap right-side dropdowns flush to screen edge

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
rope 2026-05-27 09:50:35 +01:00
parent a806fa9b80
commit de3aa43cf9

View file

@ -1162,6 +1162,7 @@ in
property real fullWidth: 200
property real fullHeight: 200
property int autoCloseMs: 1500
property bool alignRight: false
default property alias content: dropdownContent.data
function animateClose() {
@ -1177,14 +1178,14 @@ in
}
anchor.window: bar
anchor.rect.x: dropdownX - (fullWidth + 16) / 2
anchor.rect.x: alignRight ? bar.width - fullWidth - 8 : dropdownX - (fullWidth + 16) / 2
anchor.rect.y: bar.height
anchor.edges: Edges.Top | Edges.Left
anchor.gravity: Edges.Bottom | Edges.Right
anchor.adjustment: PopupAdjustment.Slide
visible: false
color: "transparent"
implicitWidth: fullWidth + 16
implicitWidth: alignRight ? fullWidth + 8 : fullWidth + 16
implicitHeight: fullHeight + 4
onVisibleChanged: {
@ -1218,6 +1219,7 @@ in
}
}
// Left ear
Item {
anchors.right: _dropdownRect.left
anchors.top: parent.top
@ -1240,13 +1242,14 @@ in
}
}
// Right ear (hidden when aligned right edge takes over)
Item {
anchors.left: _dropdownRect.right
anchors.top: parent.top
width: 8
height: Math.min(8, _dropdownRect.height)
clip: true
visible: _dropdownRect.height > 0
visible: _dropdownRect.height > 0 && !dropdown.alignRight
Canvas {
anchors.top: parent.top
width: 8; height: 8
@ -1264,14 +1267,16 @@ in
Rectangle {
id: _dropdownRect
anchors.horizontalCenter: parent.horizontalCenter
anchors.right: dropdown.alignRight ? parent.right : undefined
anchors.horizontalCenter: dropdown.alignRight ? undefined : parent.horizontalCenter
anchors.top: parent.top
width: dropdown.fullWidth
height: dropdown.open ? dropdown.fullHeight : 0
color: Theme.barBg
radius: 8
topLeftRadius: 0
topRightRadius: 0
topRightRadius: dropdown.alignRight ? 0 : 0
bottomRightRadius: dropdown.alignRight ? 0 : 8
clip: true
Behavior on height {
@ -1288,6 +1293,7 @@ in
// Context menu
BarDropdown {
id: contextMenu
alignRight: true
property var trayItem: null
fullWidth: menuItems.width + 16
fullHeight: menuItems.height + 12
@ -1369,6 +1375,7 @@ in
// Volume dropdown
BarDropdown {
id: volDropdown
alignRight: true
fullWidth: volDropdownCol.width + 24
fullHeight: volDropdownCol.height + 16
autoCloseMs: 3000
@ -1562,6 +1569,7 @@ in
// Network dropdown
BarDropdown {
id: netDropdown
alignRight: true
fullWidth: netDropdownCol.width + 24
fullHeight: netDropdownCol.height + 16
@ -1705,6 +1713,7 @@ in
// Battery dropdown
BarDropdown {
id: batteryDropdown
alignRight: true
fullWidth: batteryDropdownCol.width + 24
fullHeight: batteryDropdownCol.height + 16