159 lines
4.4 KiB
QML
159 lines
4.4 KiB
QML
import Quickshell
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import Quickshell.Widgets
|
|
import Quickshell.Services.SystemTray
|
|
import Quickshell.Services.Pipewire
|
|
import Quickshell.Io
|
|
|
|
PanelWindow {
|
|
component Pill: Rectangle {
|
|
default property alias data: inner.data
|
|
color: Qt.rgba(0.6,0.6,0.6,0.4)
|
|
radius: height / 2.0 - 2.0
|
|
implicitWidth: inner.implicitWidth + 8.0 * 2
|
|
implicitHeight: inner.implicitHeight + 3.0 * 2
|
|
Item {
|
|
id: inner
|
|
anchors.centerIn: parent
|
|
implicitWidth: inner.childrenRect.width
|
|
implicitHeight: inner.childrenRect.height
|
|
}
|
|
}
|
|
|
|
component Tray: WrapperItem {
|
|
implicitWidth: inner.implicitWidth
|
|
implicitHeight: inner.implicitHeight
|
|
RowLayout {
|
|
id: inner
|
|
Repeater {
|
|
model: SystemTray.items.values
|
|
IconImage {
|
|
id: tray_item
|
|
required property SystemTrayItem modelData
|
|
source: modelData.icon
|
|
visible: !modelData.icon.includes("?path=")
|
|
implicitSize: 22.5
|
|
|
|
PopupWindow {
|
|
id: label
|
|
visible: hover_handler.hovered && hover_text.width
|
|
implicitWidth: hover_text.width
|
|
implicitHeight: hover_text.height + 2.0
|
|
anchor.item: tray_item
|
|
anchor.rect.y: tray_item.height + 2.0
|
|
anchor.rect.x: (tray_item.width - this.width) / 2.0
|
|
color: "black"
|
|
Text {
|
|
id: hover_text
|
|
text: tray_item.modelData.tooltipTitle || tray_item.modelData.title
|
|
color: "white"
|
|
}
|
|
}
|
|
|
|
HoverHandler {
|
|
id: hover_handler
|
|
}
|
|
|
|
TapHandler {
|
|
onTapped: (eventPoint, button) => {
|
|
if (button == 1) {
|
|
tray_item.modelData.activate();
|
|
} else {
|
|
tray_item.modelData.display(label, 0, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
anchors {
|
|
top: true
|
|
left: true
|
|
right: true
|
|
}
|
|
|
|
implicitHeight: 35
|
|
|
|
color: "transparent"
|
|
|
|
Rectangle {
|
|
color: Qt.rgba(0.3,0.3,0.3,0.5)
|
|
anchors.fill: parent
|
|
anchors.leftMargin: 11
|
|
anchors.rightMargin: 11
|
|
radius: 11
|
|
}
|
|
|
|
SystemClock {
|
|
id: clock
|
|
precision: SystemClock.Seconds
|
|
}
|
|
|
|
Pill {
|
|
Text {
|
|
text: Qt.formatDateTime(clock.date, "hh:mm dd-MM")
|
|
color: "white"
|
|
}
|
|
anchors.centerIn: parent
|
|
}
|
|
|
|
Pill {
|
|
anchors.horizontalCenter: parent.left
|
|
anchors.horizontalCenterOffset: (width / 2.0) + 30.0
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
Text {
|
|
text: "left"
|
|
color: "white"
|
|
}
|
|
}
|
|
|
|
Item {
|
|
anchors.horizontalCenter: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.horizontalCenterOffset: -((width / 2.0) + 30.0)
|
|
RowLayout {
|
|
id: right_row
|
|
anchors.centerIn: parent
|
|
anchors.horizontalCenterOffset: -(width / 2.0)
|
|
|
|
PwObjectTracker {objects: [Pipewire.defaultAudioSink]}
|
|
|
|
FileView {
|
|
id: batteryFile
|
|
path: "/sys/class/power_supply/BAT1/capacity"
|
|
watchChanges: true
|
|
onFileChanged: this.reload()
|
|
blockLoading: true
|
|
}
|
|
|
|
Pill {
|
|
Text {
|
|
color: "white"
|
|
text: `bat: ${batteryFile.text().slice(0,2)}%`
|
|
}
|
|
}
|
|
|
|
Pill {
|
|
Text {
|
|
text: `vol: ${Math.round(Pipewire.defaultAudioSink.audio.volume * 100)}%`
|
|
color: "white"
|
|
}
|
|
}
|
|
|
|
Pill {
|
|
Text {
|
|
color: "white"
|
|
text: Pipewire.defaultAudioSink.description.slice(0, 15)
|
|
}
|
|
}
|
|
|
|
Pill {
|
|
Tray {}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|