add workspace window icons, right click menus on systrays
This commit is contained in:
+99
-4
@@ -12,7 +12,6 @@ import Quickshell.Widgets
|
|||||||
Scope {
|
Scope {
|
||||||
id: root
|
id: root
|
||||||
property string time
|
property string time
|
||||||
|
|
||||||
property int cpuUsage: 0
|
property int cpuUsage: 0
|
||||||
property string memUsage: "0"
|
property string memUsage: "0"
|
||||||
property var lastCpuIdle: 0
|
property var lastCpuIdle: 0
|
||||||
@@ -130,6 +129,51 @@ Scope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
spacing: 4
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: barRoot.monitor?.activeWorkspace?.toplevels ?? null
|
||||||
|
|
||||||
|
delegate: Item {
|
||||||
|
id: appIconRoot
|
||||||
|
width: 18
|
||||||
|
height: 18
|
||||||
|
|
||||||
|
property var desktopEntry: DesktopEntries.byId(modelData.wayland.appId)
|
||||||
|
|
||||||
|
IconImage {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: Quickshell.iconPath(desktopEntry.icon ?? modelData.appId, "image-missing")
|
||||||
|
opacity: modelData.activated ? 1.0 : 0.35
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||||
|
|
||||||
|
onClicked: mouse => {
|
||||||
|
if (mouse.button === Qt.LeftButton) {
|
||||||
|
modelData.wayland.activate();
|
||||||
|
} else if (mouse.button === Qt.RightButton) {
|
||||||
|
modelData.wayland.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: barRoot.monitor?.activeWorkspace?.toplevels ?? null
|
||||||
|
function onObjectInsertedPost() {
|
||||||
|
Hyprland.refreshToplevels();
|
||||||
|
}
|
||||||
|
function onObjectRemovedPost() {
|
||||||
|
Hyprland.refreshToplevels();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: clock
|
id: clock
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
@@ -175,7 +219,7 @@ Scope {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
width: 1
|
width: 1
|
||||||
height: 16
|
height: 16
|
||||||
color: root.colMuted
|
color: barRoot.colMuted
|
||||||
}
|
}
|
||||||
|
|
||||||
IconImage {
|
IconImage {
|
||||||
@@ -199,13 +243,64 @@ Scope {
|
|||||||
Repeater {
|
Repeater {
|
||||||
model: SystemTray.items
|
model: SystemTray.items
|
||||||
delegate: Image {
|
delegate: Image {
|
||||||
|
id: trayIcon
|
||||||
source: modelData.icon
|
source: modelData.icon
|
||||||
|
|
||||||
width: 16
|
width: 16
|
||||||
height: 16
|
height: 16
|
||||||
|
|
||||||
MouseArea {
|
QsMenuOpener {
|
||||||
|
id: menuOpener
|
||||||
|
menu: modelData.menu
|
||||||
|
}
|
||||||
|
|
||||||
|
PopupWindow {
|
||||||
|
id: tooltip
|
||||||
|
visible: trayDelegate.containsMouse
|
||||||
|
color: "transparent"
|
||||||
|
implicitWidth: tooltipText.implicitWidth + 16
|
||||||
|
implicitHeight: tooltipText.implicitHeight + 10
|
||||||
|
|
||||||
|
anchor.item: trayIcon
|
||||||
|
anchor.edges: Edges.Top | Edges.Left
|
||||||
|
anchor.gravity: Edges.Top | Edges.Right
|
||||||
|
anchor.adjustment: PopupAdjustment.SlideX | PopupAdjustment.FlipY
|
||||||
|
anchor.margins.bottom: 6
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: modelData.activate()
|
color: barRoot.colBg
|
||||||
|
radius: 4
|
||||||
|
border.color: barRoot.colMuted
|
||||||
|
border.width: 1
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: tooltipText
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: modelData.tooltipTitle || modelData.id
|
||||||
|
color: barRoot.colFg
|
||||||
|
font {
|
||||||
|
family: barRoot.fontFamily
|
||||||
|
pixelSize: barRoot.fontSize - 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: trayDelegate
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||||
|
onClicked: mouse => {
|
||||||
|
if (mouse.button === Qt.LeftButton) {
|
||||||
|
modelData.activate();
|
||||||
|
} else if (mouse.button === Qt.RightButton && modelData.hasMenu) {
|
||||||
|
let pos = trayIcon.mapToItem(null, 0, trayIcon.height);
|
||||||
|
modelData.display(barRoot, pos.x, pos.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//@ pragma UseQApplication
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
|
|||||||
Reference in New Issue
Block a user