update bar

This commit is contained in:
Johannes Knopp
2026-04-08 02:21:01 +02:00
parent 586e4b6320
commit 63f99ff01a
6 changed files with 146 additions and 40 deletions

View File

@ -0,0 +1,103 @@
// import QtQuick
// import Quickshell.Widgets
//
// Item {
// id: root
//
// property string icon: ""
// property int size: 16
//
// implicitWidth: size
// implicitHeight: size
//
// readonly property url resolvedSource: {
// if (!icon) return ""
// if (icon.startsWith("/") || icon.startsWith("file://") || icon.startsWith("image://"))
// return icon
// if (icon.includes("?path=")) {
// const [name, path] = icon.split("?path=")
// const baseName = name.slice(name.lastIndexOf("/") + 1)
// return `file://${path}/${baseName}`
// }
// return `image://icon/${icon}`
// }
//
// readonly property bool isIconTheme: resolvedSource.toString().startsWith("image://icon/")
// readonly property bool hasSource: resolvedSource.toString() !== ""
//
// IconImage {
// anchors.fill: parent
// source: root.resolvedSource
// visible: root.hasSource && root.isIconTheme
// asynchronous: true
// }
//
// Image {
// anchors.fill: parent
// source: root.hasSource && !root.isIconTheme ? root.resolvedSource : ""
// visible: root.hasSource && !root.isIconTheme
// asynchronous: true
// fillMode: Image.PreserveAspectFit
// }
// }
// pragma ComponentBehavior: Bound
import QtQuick
// import Quickshell
import Quickshell.Widgets
Item {
id: root
property string icon: ""
property int size: 16
implicitWidth: size
implicitHeight: size
readonly property url resolvedSource: {
if (!icon) return ""
if (icon.startsWith("/") || icon.startsWith("file://") || icon.startsWith("image://"))
return icon
if (icon.includes("?path=")) {
const [name, path] = icon.split("?path=")
const baseName = name.slice(name.lastIndexOf("/") + 1)
return `file://${path}/${baseName}`
}
// Use Quickshell's icon image provider instead of iconPath()
return `image://icon/${icon}`
}
Loader {
anchors.fill: parent
// asynchronous: true
sourceComponent: root.resolvedSource && root.resolvedSource.toString() !== ""
? root.resolvedSource.toString().startsWith("image://icon/")
? iconComponent
: imageComponent
: null
}
Component {
id: iconComponent
IconImage {
source: root.resolvedSource
asynchronous: true
// mipmap: true
}
}
Component {
id: imageComponent
Image {
source: root.resolvedSource
asynchronous: true
// mipmap: true
fillMode: Image.PreserveAspectFit
}
}
}