update bar
This commit is contained in:
103
roles/quickshell/files/components/TrayIcon.qml
Normal file
103
roles/quickshell/files/components/TrayIcon.qml
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user