66 lines
1.6 KiB
QML
66 lines
1.6 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Hyprland
|
|
import "../../../config"
|
|
import "../states/Apps"
|
|
|
|
Item {
|
|
id: root
|
|
|
|
property real pad: Config.spacing_fun(bar.height) * 1.5
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
implicitWidth: contentRow.implicitWidth + pad * 2
|
|
implicitHeight: contentRow.implicitHeight
|
|
|
|
readonly property string windowClass: Hyprland.activeToplevel?.wayland?.appId ?? ""
|
|
|
|
readonly property string windowTitle: {
|
|
const title = Hyprland.activeToplevel?.title;
|
|
if (!title)
|
|
return qsTr("Desktop");
|
|
return title.split(/\s+[\-\u2013\u2014\|]\s+/).pop();q
|
|
}
|
|
|
|
readonly property string appIcon: {
|
|
if (!root.windowClass) return AppsState.matchIcon(root.windowTitle);
|
|
|
|
let icon = AppsState.matchIcon(root.windowClass);
|
|
|
|
if (!icon) {
|
|
icon = AppsState.matchIcon(root.windowTitle);
|
|
}
|
|
|
|
return icon;
|
|
}
|
|
|
|
Row {
|
|
|
|
id: contentRow
|
|
spacing: Config.spacing_fun(bar.height) * 1.25
|
|
anchors.centerIn: parent
|
|
|
|
Text {
|
|
text: root.windowTitle
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
elide: Text.ElideRight
|
|
maximumLineCount: 1
|
|
width: Math.min(implicitWidth, 250)
|
|
|
|
font.pixelSize: Config.iconSize(bar.height) * 0.8
|
|
color: Colors.primary
|
|
}
|
|
|
|
Text {
|
|
text: root.appIcon
|
|
visible: text !== ""
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
font.pixelSize: Math.round(Config.iconSize(bar.height) * 0.85)
|
|
color: Colors.primary
|
|
}
|
|
|
|
}
|
|
} |