update bar
This commit is contained in:
@ -11,6 +11,10 @@ Item {
|
||||
property string connType: "none" // "wifi", "ethernet", "none"
|
||||
property string connName: ""
|
||||
|
||||
// accumulate results here, flush to displayed props on exit
|
||||
property string _pendingType: "none"
|
||||
property string _pendingName: ""
|
||||
|
||||
// \uf1eb = FA wifi, \uf0e8 = FA sitemap (wired proxy), \uf127 = FA chain-broken
|
||||
readonly property string netIcon:
|
||||
connType === "wifi" ? "\uf1eb" :
|
||||
@ -25,9 +29,9 @@ Item {
|
||||
const state = line.substring(idx1 + 1, idx2)
|
||||
const conn = line.substring(idx2 + 1).trim()
|
||||
if (state === "connected" && (type === "wifi" || type === "ethernet")) {
|
||||
if (root.connType === "none" || type === "wifi") {
|
||||
root.connType = type
|
||||
root.connName = conn
|
||||
if (root._pendingType === "none" || type === "wifi") {
|
||||
root._pendingType = type
|
||||
root._pendingName = conn
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,8 +42,8 @@ Item {
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
root.connType = "none"
|
||||
root.connName = ""
|
||||
root._pendingType = "none"
|
||||
root._pendingName = ""
|
||||
netProc.running = true
|
||||
}
|
||||
}
|
||||
@ -51,7 +55,11 @@ Item {
|
||||
splitMarker: "\n"
|
||||
onRead: data => root.parseLine(data)
|
||||
}
|
||||
onExited: running = false
|
||||
onExited: {
|
||||
root.connType = root._pendingType
|
||||
root.connName = root._pendingName
|
||||
running = false
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
|
||||
@ -33,31 +33,11 @@ Item {
|
||||
Behavior on color { ColorAnimation { duration: 80 } }
|
||||
}
|
||||
|
||||
IconImage {
|
||||
id: iconImg
|
||||
anchors.centerIn: parent
|
||||
implicitSize: 16
|
||||
visible: status === Image.Ready
|
||||
source: {
|
||||
const icon = trayDelegate.modelData.icon
|
||||
if (!icon || icon === "") return ""
|
||||
if (icon.startsWith("/") || icon.startsWith("file://") || icon.startsWith("image://")) return icon
|
||||
const path = Quickshell.iconPath(icon, "")
|
||||
if (path !== "") return "file://" + path
|
||||
return "image://icon/" + icon
|
||||
}
|
||||
mipmap: true
|
||||
}
|
||||
|
||||
// Letter fallback when icon fails to load
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: iconImg.status !== Image.Ready
|
||||
text: (trayDelegate.modelData.title ?? trayDelegate.modelData.id ?? "?").charAt(0).toUpperCase()
|
||||
color: Theme.textDim
|
||||
font.pixelSize: 11
|
||||
font.bold: true
|
||||
}
|
||||
TrayIcon {
|
||||
anchors.centerIn: parent
|
||||
icon: trayDelegate.modelData.icon
|
||||
size: 16
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: hoverArea
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Widgets
|
||||
// import Quickshell.Widgets
|
||||
import QtQuick
|
||||
import "../components"
|
||||
|
||||
@ -27,17 +27,29 @@ Rectangle {
|
||||
delegate: Item {
|
||||
id: iconItem
|
||||
required property var modelData
|
||||
property string appClass: modelData.lastIpcObject["class"] ?? ""
|
||||
property var entry: appClass !== "" ? DesktopEntries.heuristicLookup(appClass) : null
|
||||
|
||||
width: 16
|
||||
height: 16
|
||||
implicitWidth: 16
|
||||
implicitHeight: 16
|
||||
|
||||
IconImage {
|
||||
property string appClass: ""
|
||||
|
||||
Component.onCompleted: {
|
||||
var cls = modelData?.lastIpcObject?.["class"] ?? ""
|
||||
if (cls !== "") {
|
||||
appClass = cls
|
||||
} else if (modelData) {
|
||||
modelData.lastIpcObjectChanged.connect(function() {
|
||||
var c = iconItem.modelData?.lastIpcObject?.["class"] ?? ""
|
||||
if (c !== "") iconItem.appClass = c
|
||||
})
|
||||
Qt.callLater(Hyprland.refreshToplevels)
|
||||
}
|
||||
}
|
||||
|
||||
TrayIcon {
|
||||
anchors.fill: parent
|
||||
source: iconItem.entry && iconItem.entry.icon !== ""
|
||||
? "image://icon/" + iconItem.entry.icon
|
||||
: ""
|
||||
icon: iconItem.appClass
|
||||
size: 16
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import Quickshell.Hyprland
|
||||
import QtQuick
|
||||
|
||||
|
||||
Reference in New Issue
Block a user