quickshell: inline monochrome tray icons on bar
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fbb7c2d494
commit
a3e83fa6f0
1 changed files with 39 additions and 70 deletions
|
|
@ -62,6 +62,7 @@ in
|
|||
polkit_gnome
|
||||
] ++ lib.optionals isGaming [
|
||||
quickshell
|
||||
qt6.qt5compat
|
||||
];
|
||||
|
||||
# Use upstream anyrun flake's HM module instead of the built-in one
|
||||
|
|
@ -569,6 +570,7 @@ in
|
|||
import Quickshell.Widgets
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Qt5Compat.GraphicalEffects
|
||||
|
||||
ShellRoot {
|
||||
Variants {
|
||||
|
|
@ -634,80 +636,47 @@ in
|
|||
// Spacer
|
||||
Item { Layout.fillWidth: true }
|
||||
|
||||
// Tray toggle button
|
||||
Item {
|
||||
id: trayToggle
|
||||
Layout.preferredWidth: 28
|
||||
Layout.preferredHeight: 30
|
||||
Layout.rightMargin: 6
|
||||
// Tray icons inline
|
||||
RowLayout {
|
||||
id: trayArea
|
||||
spacing: 8
|
||||
Layout.rightMargin: 8
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: trayPopup.visible ? "\u25b6" : "\u25c0"
|
||||
color: "#${c.base05}"
|
||||
font.family: "FiraMono Nerd Font"
|
||||
font.pixelSize: 10
|
||||
}
|
||||
Repeater {
|
||||
model: SystemTray.items
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: trayPopup.visible = !trayPopup.visible
|
||||
}
|
||||
}
|
||||
}
|
||||
Item {
|
||||
required property var modelData
|
||||
Layout.preferredWidth: 16
|
||||
Layout.preferredHeight: 16
|
||||
|
||||
// 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
|
||||
Image {
|
||||
id: trayIcon
|
||||
anchors.fill: parent
|
||||
source: modelData.icon
|
||||
sourceSize.width: 16
|
||||
sourceSize.height: 16
|
||||
smooth: true
|
||||
mipmap: true
|
||||
visible: false
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#${c.base00}"
|
||||
border.color: "#${c.base03}"
|
||||
border.width: 1
|
||||
radius: 6
|
||||
ColorOverlay {
|
||||
anchors.fill: trayIcon
|
||||
source: trayIcon
|
||||
color: "#${c.base05}"
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: trayRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 8
|
||||
|
||||
Repeater {
|
||||
model: SystemTray.items
|
||||
|
||||
Item {
|
||||
required property var modelData
|
||||
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();
|
||||
}
|
||||
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 {
|
||||
id: contextMenu
|
||||
property var trayItem: null
|
||||
anchor.item: trayToggle
|
||||
anchor.item: trayArea
|
||||
anchor.edges: Edges.Bottom | Edges.Right
|
||||
anchor.gravity: Edges.Bottom | Edges.Left
|
||||
anchor.adjustment: PopupAdjustment.Slide
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue