45 lines
1.4 KiB
QML
45 lines
1.4 KiB
QML
import QtQuick
|
|
import QtQuick.Effects
|
|
import Quickshell
|
|
import Quickshell.Widgets
|
|
import "." as M
|
|
|
|
M.BarSection {
|
|
id: root
|
|
spacing: M.Theme.moduleSpacing
|
|
tooltip: M.NiriIpc.focusedAppId ? M.NiriIpc.focusedAppId + "\n" + M.NiriIpc.focusedTitle : M.NiriIpc.focusedTitle
|
|
|
|
readonly property string _iconSource: {
|
|
if (!M.NiriIpc.focusedAppId)
|
|
return "";
|
|
const entry = DesktopEntries.heuristicLookup(M.NiriIpc.focusedAppId);
|
|
return entry ? Quickshell.iconPath(entry.icon) : "";
|
|
}
|
|
|
|
readonly property real _iconOffset: _icon.visible ? _icon.width + root.spacing : 0
|
|
|
|
// Natural content width — Bar.qml uses this to cap the group width
|
|
readonly property real naturalWidth: _iconOffset + _label.implicitWidth
|
|
|
|
IconImage {
|
|
id: _icon
|
|
visible: root._iconSource !== ""
|
|
source: root._iconSource
|
|
implicitSize: M.Theme.fontSize + 2
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
layer.enabled: true
|
|
layer.effect: MultiEffect {
|
|
colorization: 1.0
|
|
colorizationColor: root.accentColor
|
|
}
|
|
}
|
|
|
|
M.BarLabel {
|
|
id: _label
|
|
label: M.NiriIpc.focusedTitle
|
|
color: root.accentColor
|
|
elide: Text.ElideRight
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
width: Math.min(implicitWidth, Math.max(0, root.width - root._iconOffset))
|
|
}
|
|
}
|