bar/tray: add icon subs
Usage: array of { id, image | icon }
This commit is contained in:
parent
2563430e3b
commit
5b81104ffa
4 changed files with 17 additions and 8 deletions
|
|
@ -331,6 +331,7 @@ default, you must create it manually.
|
||||||
},
|
},
|
||||||
"tray": {
|
"tray": {
|
||||||
"background": false,
|
"background": false,
|
||||||
|
"iconSubs": [],
|
||||||
"recolour": false
|
"recolour": false
|
||||||
},
|
},
|
||||||
"workspaces": {
|
"workspaces": {
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ JsonObject {
|
||||||
component Tray: JsonObject {
|
component Tray: JsonObject {
|
||||||
property bool background: false
|
property bool background: false
|
||||||
property bool recolour: false
|
property bool recolour: false
|
||||||
|
property list<var> iconSubs: []
|
||||||
}
|
}
|
||||||
|
|
||||||
component Status: JsonObject {
|
component Status: JsonObject {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ pragma ComponentBehavior: Bound
|
||||||
import qs.components.effects
|
import qs.components.effects
|
||||||
import qs.services
|
import qs.services
|
||||||
import qs.config
|
import qs.config
|
||||||
|
import qs.utils
|
||||||
import Quickshell.Services.SystemTray
|
import Quickshell.Services.SystemTray
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
|
|
@ -26,14 +27,7 @@ MouseArea {
|
||||||
id: icon
|
id: icon
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: {
|
source: Icons.getTrayIcon(root.modelData.id, root.modelData.icon)
|
||||||
let icon = root.modelData.icon;
|
|
||||||
if (icon.includes("?path=")) {
|
|
||||||
const [name, path] = icon.split("?path=");
|
|
||||||
icon = Qt.resolvedUrl(`${path}/${name.slice(name.lastIndexOf("/") + 1)}`);
|
|
||||||
}
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
colour: Colours.palette.m3secondary
|
colour: Colours.palette.m3secondary
|
||||||
layer.enabled: Config.bar.tray.recolour
|
layer.enabled: Config.bar.tray.recolour
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
|
import qs.config
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Services.Notifications
|
import Quickshell.Services.Notifications
|
||||||
|
|
||||||
|
|
@ -205,4 +206,16 @@ Singleton {
|
||||||
return "monitor_heart";
|
return "monitor_heart";
|
||||||
return name[0].toUpperCase();
|
return name[0].toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTrayIcon(id: string, icon: string): string {
|
||||||
|
for (const sub of Config.bar.tray.iconSubs)
|
||||||
|
if (sub.id === id)
|
||||||
|
return sub.image ? Qt.resolvedUrl(sub.image) : Quickshell.iconPath(sub.icon);
|
||||||
|
|
||||||
|
if (icon.includes("?path=")) {
|
||||||
|
const [name, path] = icon.split("?path=");
|
||||||
|
icon = Qt.resolvedUrl(`${path}/${name.slice(name.lastIndexOf("/") + 1)}`);
|
||||||
|
}
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue