feat: add systray context menus
This commit is contained in:
parent
25f7c1ed6c
commit
b0ceb423d9
6 changed files with 21 additions and 12 deletions
|
@ -20,11 +20,8 @@ BRectangle {
|
|||
objects: [audiow.sink]
|
||||
}
|
||||
|
||||
required property var popupAnchor
|
||||
|
||||
AudioManager {
|
||||
id: audioman
|
||||
anchor.window: audiow.popupAnchor
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
|
|
|
@ -11,7 +11,7 @@ Scope {
|
|||
model: Quickshell.screens
|
||||
// the screen from the screens list will be injected into this property
|
||||
PanelWindow {
|
||||
id: root
|
||||
id: lbar
|
||||
property var modelData
|
||||
screen: modelData
|
||||
|
||||
|
@ -33,9 +33,7 @@ Scope {
|
|||
// TODO: on click open a calendar view
|
||||
ClockWidget {}
|
||||
|
||||
AudioOutput {
|
||||
popupAnchor: root
|
||||
}
|
||||
AudioOutput {}
|
||||
|
||||
SysTray {}
|
||||
|
||||
|
|
|
@ -17,16 +17,16 @@ BRectangle {
|
|||
width: parent.width * 4 / 5
|
||||
height: parent.height
|
||||
anchors.right: parent.right
|
||||
percentage: UPower.displayDevice.healthPercentage
|
||||
visible: UPower.displayDevice.healthSupported
|
||||
percentage: UPower.displayDevice?.healthPercentage ?? 0
|
||||
visible: UPower.displayDevice?.healthSupported ?? false
|
||||
}
|
||||
Pill {
|
||||
id: battery
|
||||
width: parent.width * (!UPower.displayDevice.healthSupported || 3 / 5)
|
||||
width: parent.width * (!UPower.displayDevice?.healthSupported || 3 / 5)
|
||||
height: parent.height
|
||||
anchors.left: parent.left
|
||||
|
||||
percentage: UPower.displayDevice.percentage
|
||||
percentage: UPower.displayDevice?.percentage ?? 0
|
||||
color: 100 * percentage / 360
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,36 @@
|
|||
import Quickshell.Services.SystemTray
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
|
||||
MouseArea {
|
||||
id: root
|
||||
required property SystemTrayItem item
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: parent.width
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
|
||||
onClicked: event => {
|
||||
switch (event.button) {
|
||||
case Qt.LeftButton:
|
||||
item.activate();
|
||||
break;
|
||||
case Qt.RightButton:
|
||||
if (!item.hasMenu)
|
||||
return;
|
||||
menu.open();
|
||||
break;
|
||||
default:
|
||||
console.log("Buttonevent unhandled");
|
||||
}
|
||||
}
|
||||
|
||||
QsMenuAnchor {
|
||||
id: menu
|
||||
menu: root.item.menu
|
||||
anchor.window: lbar
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: parent.width
|
||||
|
|
|
@ -65,7 +65,7 @@ RowLayout {
|
|||
}
|
||||
|
||||
Button {
|
||||
property bool isDefault: root.node.id === Pipewire.defaultAudioSink.id
|
||||
property bool isDefault: root.node?.id === Pipewire.defaultAudioSink?.id
|
||||
checked: isDefault
|
||||
checkable: false
|
||||
visible: root.node.isSink
|
||||
|
|
|
@ -8,6 +8,7 @@ PopupWindow {
|
|||
anchor {
|
||||
rect.x: 30
|
||||
rect.y: 20
|
||||
window: lbar
|
||||
}
|
||||
|
||||
color: "transparent"
|
||||
|
|
Loading…
Add table
Reference in a new issue