quickshell: inline monochrome tray icons on bar

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
rope 2026-05-26 10:55:21 +01:00
parent fbb7c2d494
commit a3e83fa6f0

View file

@ -62,6 +62,7 @@ in
polkit_gnome polkit_gnome
] ++ lib.optionals isGaming [ ] ++ lib.optionals isGaming [
quickshell quickshell
qt6.qt5compat
]; ];
# Use upstream anyrun flake's HM module instead of the built-in one # Use upstream anyrun flake's HM module instead of the built-in one
@ -569,6 +570,7 @@ in
import Quickshell.Widgets import Quickshell.Widgets
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
ShellRoot { ShellRoot {
Variants { Variants {
@ -634,80 +636,47 @@ in
// Spacer // Spacer
Item { Layout.fillWidth: true } Item { Layout.fillWidth: true }
// Tray toggle button // Tray icons inline
Item { RowLayout {
id: trayToggle id: trayArea
Layout.preferredWidth: 28 spacing: 8
Layout.preferredHeight: 30 Layout.rightMargin: 8
Layout.rightMargin: 6
Text { Repeater {
anchors.centerIn: parent model: SystemTray.items
text: trayPopup.visible ? "\u25b6" : "\u25c0"
color: "#${c.base05}"
font.family: "FiraMono Nerd Font"
font.pixelSize: 10
}
MouseArea { Item {
anchors.fill: parent required property var modelData
onClicked: trayPopup.visible = !trayPopup.visible Layout.preferredWidth: 16
} Layout.preferredHeight: 16
}
}
// Tray icon popup Image {
PopupWindow { id: trayIcon
id: trayPopup anchors.fill: parent
anchor.item: trayToggle source: modelData.icon
anchor.edges: Edges.Bottom | Edges.Right sourceSize.width: 16
anchor.gravity: Edges.Bottom | Edges.Left sourceSize.height: 16
anchor.adjustment: PopupAdjustment.Slide smooth: true
visible: false mipmap: true
color: "transparent" visible: false
implicitWidth: trayRow.width + 24 }
implicitHeight: 36
Rectangle { ColorOverlay {
anchors.fill: parent anchors.fill: trayIcon
color: "#${c.base00}" source: trayIcon
border.color: "#${c.base03}" color: "#${c.base05}"
border.width: 1 }
radius: 6
RowLayout { MouseArea {
id: trayRow anchors.fill: parent
anchors.centerIn: parent acceptedButtons: Qt.LeftButton | Qt.RightButton
spacing: 8 onClicked: (event) => {
if (event.button === Qt.RightButton && modelData.hasMenu) {
Repeater { contextMenu.trayItem = modelData;
model: SystemTray.items menuOpener.menu = modelData.menu;
contextMenu.visible = true;
Item { } else {
required property var modelData modelData.activate();
Layout.preferredWidth: 20
Layout.preferredHeight: 20
Image {
anchors.fill: parent
source: modelData.icon
sourceSize.width: 20
sourceSize.height: 20
smooth: true
mipmap: true
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: (event) => {
if (event.button === Qt.RightButton && modelData.hasMenu) {
contextMenu.trayItem = modelData;
menuOpener.menu = modelData.menu;
contextMenu.visible = true;
} else {
modelData.activate();
}
} }
} }
} }
@ -720,7 +689,7 @@ in
PopupWindow { PopupWindow {
id: contextMenu id: contextMenu
property var trayItem: null property var trayItem: null
anchor.item: trayToggle anchor.item: trayArea
anchor.edges: Edges.Bottom | Edges.Right anchor.edges: Edges.Bottom | Edges.Right
anchor.gravity: Edges.Bottom | Edges.Left anchor.gravity: Edges.Bottom | Edges.Left
anchor.adjustment: PopupAdjustment.Slide anchor.adjustment: PopupAdjustment.Slide