quickshell: snap right-side dropdowns flush to screen edge
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a806fa9b80
commit
de3aa43cf9
1 changed files with 14 additions and 5 deletions
|
|
@ -1162,6 +1162,7 @@ in
|
||||||
property real fullWidth: 200
|
property real fullWidth: 200
|
||||||
property real fullHeight: 200
|
property real fullHeight: 200
|
||||||
property int autoCloseMs: 1500
|
property int autoCloseMs: 1500
|
||||||
|
property bool alignRight: false
|
||||||
default property alias content: dropdownContent.data
|
default property alias content: dropdownContent.data
|
||||||
|
|
||||||
function animateClose() {
|
function animateClose() {
|
||||||
|
|
@ -1177,14 +1178,14 @@ in
|
||||||
}
|
}
|
||||||
|
|
||||||
anchor.window: bar
|
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.rect.y: bar.height
|
||||||
anchor.edges: Edges.Top | Edges.Left
|
anchor.edges: Edges.Top | Edges.Left
|
||||||
anchor.gravity: Edges.Bottom | Edges.Right
|
anchor.gravity: Edges.Bottom | Edges.Right
|
||||||
anchor.adjustment: PopupAdjustment.Slide
|
anchor.adjustment: PopupAdjustment.Slide
|
||||||
visible: false
|
visible: false
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
implicitWidth: fullWidth + 16
|
implicitWidth: alignRight ? fullWidth + 8 : fullWidth + 16
|
||||||
implicitHeight: fullHeight + 4
|
implicitHeight: fullHeight + 4
|
||||||
|
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
|
|
@ -1218,6 +1219,7 @@ in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Left ear
|
||||||
Item {
|
Item {
|
||||||
anchors.right: _dropdownRect.left
|
anchors.right: _dropdownRect.left
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
|
@ -1240,13 +1242,14 @@ in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Right ear (hidden when aligned right — edge takes over)
|
||||||
Item {
|
Item {
|
||||||
anchors.left: _dropdownRect.right
|
anchors.left: _dropdownRect.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
width: 8
|
width: 8
|
||||||
height: Math.min(8, _dropdownRect.height)
|
height: Math.min(8, _dropdownRect.height)
|
||||||
clip: true
|
clip: true
|
||||||
visible: _dropdownRect.height > 0
|
visible: _dropdownRect.height > 0 && !dropdown.alignRight
|
||||||
Canvas {
|
Canvas {
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
width: 8; height: 8
|
width: 8; height: 8
|
||||||
|
|
@ -1264,14 +1267,16 @@ in
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: _dropdownRect
|
id: _dropdownRect
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.right: dropdown.alignRight ? parent.right : undefined
|
||||||
|
anchors.horizontalCenter: dropdown.alignRight ? undefined : parent.horizontalCenter
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
width: dropdown.fullWidth
|
width: dropdown.fullWidth
|
||||||
height: dropdown.open ? dropdown.fullHeight : 0
|
height: dropdown.open ? dropdown.fullHeight : 0
|
||||||
color: Theme.barBg
|
color: Theme.barBg
|
||||||
radius: 8
|
radius: 8
|
||||||
topLeftRadius: 0
|
topLeftRadius: 0
|
||||||
topRightRadius: 0
|
topRightRadius: dropdown.alignRight ? 0 : 0
|
||||||
|
bottomRightRadius: dropdown.alignRight ? 0 : 8
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
Behavior on height {
|
Behavior on height {
|
||||||
|
|
@ -1288,6 +1293,7 @@ in
|
||||||
// Context menu
|
// Context menu
|
||||||
BarDropdown {
|
BarDropdown {
|
||||||
id: contextMenu
|
id: contextMenu
|
||||||
|
alignRight: true
|
||||||
property var trayItem: null
|
property var trayItem: null
|
||||||
fullWidth: menuItems.width + 16
|
fullWidth: menuItems.width + 16
|
||||||
fullHeight: menuItems.height + 12
|
fullHeight: menuItems.height + 12
|
||||||
|
|
@ -1369,6 +1375,7 @@ in
|
||||||
// Volume dropdown
|
// Volume dropdown
|
||||||
BarDropdown {
|
BarDropdown {
|
||||||
id: volDropdown
|
id: volDropdown
|
||||||
|
alignRight: true
|
||||||
fullWidth: volDropdownCol.width + 24
|
fullWidth: volDropdownCol.width + 24
|
||||||
fullHeight: volDropdownCol.height + 16
|
fullHeight: volDropdownCol.height + 16
|
||||||
autoCloseMs: 3000
|
autoCloseMs: 3000
|
||||||
|
|
@ -1562,6 +1569,7 @@ in
|
||||||
// Network dropdown
|
// Network dropdown
|
||||||
BarDropdown {
|
BarDropdown {
|
||||||
id: netDropdown
|
id: netDropdown
|
||||||
|
alignRight: true
|
||||||
fullWidth: netDropdownCol.width + 24
|
fullWidth: netDropdownCol.width + 24
|
||||||
fullHeight: netDropdownCol.height + 16
|
fullHeight: netDropdownCol.height + 16
|
||||||
|
|
||||||
|
|
@ -1705,6 +1713,7 @@ in
|
||||||
// Battery dropdown
|
// Battery dropdown
|
||||||
BarDropdown {
|
BarDropdown {
|
||||||
id: batteryDropdown
|
id: batteryDropdown
|
||||||
|
alignRight: true
|
||||||
fullWidth: batteryDropdownCol.width + 24
|
fullWidth: batteryDropdownCol.width + 24
|
||||||
fullHeight: batteryDropdownCol.height + 16
|
fullHeight: batteryDropdownCol.height + 16
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue