trayicon rendering
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Services.Notifications
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
function getTrayIcon(id: string, icon: string): string {
|
||||||
|
if (icon.includes("?path=")) {
|
||||||
|
const [name, path] = icon.split("?path=");
|
||||||
|
icon = Qt.resolvedUrl(`${path}/${name.slice(name.lastIndexOf("/") + 1)}`);
|
||||||
|
}
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
-8
@@ -3,21 +3,19 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Effects
|
import QtQuick.Effects
|
||||||
|
import Caelestia
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import Quickshell.Services.SystemTray
|
import Quickshell.Services.SystemTray
|
||||||
|
|
||||||
IconImage {
|
MouseArea {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property SystemTrayItem item
|
required property SystemTrayItem item
|
||||||
|
|
||||||
source: root.item.icon
|
implicitWidth: 22
|
||||||
implicitWidth: 18
|
implicitHeight: 22
|
||||||
implicitHeight: 18
|
|
||||||
mipmap: false
|
|
||||||
asynchronous: true
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
onClicked: event => {
|
onClicked: event => {
|
||||||
switch (event.button) {
|
switch (event.button) {
|
||||||
@@ -29,6 +27,30 @@ IconImage {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
IconImage {
|
||||||
|
id: icon
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
layer.enabled: true
|
||||||
|
|
||||||
|
layer.onEnabledChanged: {
|
||||||
|
if (layer.enabled && status === Image.Ready)
|
||||||
|
analyser.requestUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
onStatusChanged: {
|
||||||
|
if (layer.enabled && status === Image.Ready)
|
||||||
|
analyser.requestUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
source: GetIcons.getTrayIcon(root.item.id, root.item.icon)
|
||||||
|
|
||||||
|
mipmap: false
|
||||||
|
asynchronous: true
|
||||||
|
ImageAnalyser {
|
||||||
|
id: analyser
|
||||||
|
sourceItem: icon
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QsMenuAnchor {
|
QsMenuAnchor {
|
||||||
id: menuAnchor
|
id: menuAnchor
|
||||||
|
|||||||
Reference in New Issue
Block a user