add systemTray
This commit is contained in:
parent
eac2ed80e3
commit
aa003dfe9a
4 changed files with 55 additions and 4 deletions
|
|
@ -47,6 +47,9 @@ Variants {
|
||||||
Pw {
|
Pw {
|
||||||
barHeight: root.implicitHeight
|
barHeight: root.implicitHeight
|
||||||
}
|
}
|
||||||
|
Tray {
|
||||||
|
barHeight: root.implicitHeight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ WrapperRectangle {
|
||||||
color: Colors.base01
|
color: Colors.base01
|
||||||
required property int barHeight
|
required property int barHeight
|
||||||
property double vertMargin: barHeight / 4 - 4
|
property double vertMargin: barHeight / 4 - 4
|
||||||
property PwNode defaultAudio: Pipewire.ready ? Pipewire.defaultAudioSink : null
|
property PwNode defaultAudio: Pipewire.ready ? Pipewire.preferredDefaultAudioSink : null
|
||||||
property string status: defaultAudio.audio.muted? "mut " : "vol "
|
property string status: defaultAudio?.audio.muted ? "mut " : "vol "
|
||||||
topMargin: vertMargin
|
topMargin: vertMargin
|
||||||
bottomMargin: vertMargin
|
bottomMargin: vertMargin
|
||||||
leftMargin: 8
|
leftMargin: 8
|
||||||
|
|
@ -19,7 +19,7 @@ WrapperRectangle {
|
||||||
objects: [Pipewire.ready ? Pipewire.defaultAudioSink : null]
|
objects: [Pipewire.ready ? Pipewire.defaultAudioSink : null]
|
||||||
}
|
}
|
||||||
child: StyledText {
|
child: StyledText {
|
||||||
text: root.status + Math.floor(root.defaultAudio.audio.volume * 100) + "%"
|
text: root.status + Math.floor(root.defaultAudio?.audio.volume * 100) + "%"
|
||||||
opacity: root.defaultAudio.audio.muted ? 0.6 : 1.0
|
opacity: root.defaultAudio?.audio.muted ? 0.6 : 1.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
47
modules/bar/Tray.qml
Normal file
47
modules/bar/Tray.qml
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Services.SystemTray
|
||||||
|
import Quickshell.DBusMenu
|
||||||
|
import Quickshell.Widgets
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import qs
|
||||||
|
import qs.widgets
|
||||||
|
|
||||||
|
WrapperRectangle {
|
||||||
|
id: root
|
||||||
|
color: Colors.base01
|
||||||
|
required property int barHeight
|
||||||
|
property double vertMargin: barHeight / 4 - 4
|
||||||
|
topMargin: vertMargin
|
||||||
|
bottomMargin: vertMargin
|
||||||
|
leftMargin: 8
|
||||||
|
rightMargin: 8
|
||||||
|
|
||||||
|
child: RowLayout {
|
||||||
|
id: iconlayout
|
||||||
|
Repeater {
|
||||||
|
id: iconRepeater
|
||||||
|
model: SystemTray.items
|
||||||
|
delegate: WrapperMouseArea {
|
||||||
|
id: iconWrapper
|
||||||
|
required property var modelData
|
||||||
|
child: IconImage {
|
||||||
|
source: iconWrapper.modelData.icon
|
||||||
|
implicitSize: 16
|
||||||
|
}
|
||||||
|
QsMenuAnchor {
|
||||||
|
id: menu
|
||||||
|
anchor.item: iconWrapper
|
||||||
|
menu: iconWrapper.modelData.menu
|
||||||
|
}
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
onClicked: mouse => {
|
||||||
|
if (mouse.button == Qt.RightButton) {
|
||||||
|
menu.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//@ pragma UseQApplication
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import qs.modules.bar
|
import qs.modules.bar
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue