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,67 +636,35 @@ in
// Spacer // Spacer
Item { Layout.fillWidth: true } Item { Layout.fillWidth: true }
// Tray toggle button // Tray icons inline
Item {
id: trayToggle
Layout.preferredWidth: 28
Layout.preferredHeight: 30
Layout.rightMargin: 6
Text {
anchors.centerIn: parent
text: trayPopup.visible ? "\u25b6" : "\u25c0"
color: "#${c.base05}"
font.family: "FiraMono Nerd Font"
font.pixelSize: 10
}
MouseArea {
anchors.fill: parent
onClicked: trayPopup.visible = !trayPopup.visible
}
}
}
// Tray icon popup
PopupWindow {
id: trayPopup
anchor.item: trayToggle
anchor.edges: Edges.Bottom | Edges.Right
anchor.gravity: Edges.Bottom | Edges.Left
anchor.adjustment: PopupAdjustment.Slide
visible: false
color: "transparent"
implicitWidth: trayRow.width + 24
implicitHeight: 36
Rectangle {
anchors.fill: parent
color: "#${c.base00}"
border.color: "#${c.base03}"
border.width: 1
radius: 6
RowLayout { RowLayout {
id: trayRow id: trayArea
anchors.centerIn: parent
spacing: 8 spacing: 8
Layout.rightMargin: 8
Repeater { Repeater {
model: SystemTray.items model: SystemTray.items
Item { Item {
required property var modelData required property var modelData
Layout.preferredWidth: 20 Layout.preferredWidth: 16
Layout.preferredHeight: 20 Layout.preferredHeight: 16
Image { Image {
id: trayIcon
anchors.fill: parent anchors.fill: parent
source: modelData.icon source: modelData.icon
sourceSize.width: 20 sourceSize.width: 16
sourceSize.height: 20 sourceSize.height: 16
smooth: true smooth: true
mipmap: true mipmap: true
visible: false
}
ColorOverlay {
anchors.fill: trayIcon
source: trayIcon
color: "#${c.base05}"
} }
MouseArea { MouseArea {
@ -714,13 +684,12 @@ in
} }
} }
} }
}
// Custom-rendered context menu // Custom-rendered context menu
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