feat: add system tray with working opening of windows

This commit is contained in:
Nydragon 2024-08-26 20:17:43 +02:00
parent bdae31a055
commit c5838d1d43
Signed by: nydragon
SSH key fingerprint: SHA256:iQnIC12spf4QjWSbarmkD2No1cLMlu6TWoV7K6cYF5g
5 changed files with 119 additions and 3 deletions

View file

@ -2,6 +2,8 @@ import Quickshell // for ShellRoot and PanelWindow
import QtQuick // for Text import QtQuick // for Text
import Quickshell.Io // for process import Quickshell.Io // for process
import "windows" import "windows"
import QtQuick.Layouts
import "systray"
Scope { Scope {
Variants { Variants {
@ -26,13 +28,19 @@ Scope {
// TODO: on click open a calendar view // TODO: on click open a calendar view
ClockWidget { ClockWidget {
id: clock id: clock
anchors.horizontalCenter: parent.horizontalCenter Layout.alignment: Qt.AlignTop
} }
AudioOutput { AudioOutput {
id: audio
popupAnchor: root popupAnchor: root
anchors.top: clock.bottom anchors.top: clock.bottom
anchors.horizontalCenter: parent.horizontalCenter Layout.alignment: Qt.AlignTop
}
SysTray {
anchors.top: audio.bottom
Layout.alignment: Qt.AlignTop
} }
} }
} }

View file

@ -1,3 +1,5 @@
//@ pragma UseQApplication
import Quickshell import Quickshell
// for ShellRoot and PanelWindow // for ShellRoot and PanelWindow

40
src/systray/SysTray.qml Normal file
View file

@ -0,0 +1,40 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Quickshell
import Quickshell.Services.SystemTray
Rectangle {
id: aoutput
width: parent.width
height: 100
anchors.bottomMargin: 5
anchors.topMargin: 5
border.color: "black"
border.width: 2
radius: 5
ScrollView {
anchors.fill: parent
contentWidth: availableWidth
padding: parent.border.width
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
ColumnLayout {
anchors.fill: parent
anchors.margins: 4
Repeater {
// Show all sources, regardless of what sink they are assigned to
model: SystemTray.items
SysTrayItem {
required property SystemTrayItem modelData
item: modelData
}
}
}
}
}

View file

@ -0,0 +1,67 @@
import Quickshell.Services.SystemTray
import QtQuick
import QtQuick.Layouts
import Quickshell
MouseArea {
required property SystemTrayItem item
Layout.fillWidth: true
Layout.preferredHeight: parent.width
onClicked: event => {
switch (event.button) {
case Qt.LeftButton:
item.activate();
break;
default:
console.log("Buttonevent unhandled");
}
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: parent.width
Layout.alignment: Qt.AlignHCenter
color: "black"
radius: 3
Component.onCompleted: () => {
console.log(JSON.stringify(Object.entries(item), null, 2));
console.log(height, width);
}
//height: icon.height
//width: icon.width
height: width
width: parent.width
// Text {
//text: item.id
//}
//
Image {
id: icon
source: item.icon
//fillMode: Image.PreserveAspectFit
//Layout.fillWidth: true
width: parent.width
height: parent.height
//Layout.maximumWidth: parent.width
//Layout.maximumHeight: parent.height
//sourceSize.width: parent.width
//sourceSize.height: parent.height
//
//horizontalAlignment: Image.AlignHCenter
//verticalAlignment: Image.AlignVCenter
fillMode: Image.Stretch
}
}
}

View file

@ -32,7 +32,6 @@ RowLayout {
ColumnLayout { ColumnLayout {
RowLayout { RowLayout {
id: b
spacing: 6 spacing: 6
Layout.preferredHeight: 30 Layout.preferredHeight: 30