From aebd3235d755cb1ff95995b461e497fea2d52e8b Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 11 Sep 2025 14:43:11 +0200 Subject: ... --- .../shell/quickshell/ActiveWindowDisplay.qml | 182 ++++++++++++++------- 1 file changed, 127 insertions(+), 55 deletions(-) (limited to 'accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml') diff --git a/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml index 57ade488..883f9001 100644 --- a/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml +++ b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml @@ -22,72 +22,144 @@ Item { width: activeWindowDisplayContent.width height: parent.height - Row { - id: activeWindowDisplayContent + WrapperMouseArea { + id: widgetMouseArea - width: childrenRect.width - height: parent.height - anchors.verticalCenter: parent.verticalCenter - spacing: 8 + anchors.fill: parent - IconImage { - id: activeWindowIcon + hoverEnabled: true - height: 14 - width: 14 + Item { + anchors.fill: parent - anchors.verticalCenter: parent.verticalCenter + Row { + id: activeWindowDisplayContent - source: { - let icon = activeWindowDisplay.windowEntry?.icon - if (typeof icon === 'string' || icon instanceof String) { - if (icon.includes("?path=")) { - const split = icon.split("?path=") - if (split.length !== 2) + width: childrenRect.width + height: parent.height + anchors.verticalCenter: parent.verticalCenter + spacing: 8 + + IconImage { + id: activeWindowIcon + + implicitSize: 14 + + anchors.verticalCenter: parent.verticalCenter + + source: { + let icon = activeWindowDisplay.windowEntry?.icon + if (typeof icon === 'string' || icon instanceof String) { + if (icon.includes("?path=")) { + const split = icon.split("?path=") + if (split.length !== 2) + return icon + const name = split[0] + const path = split[1] + const fileName = name.substring( + name.lastIndexOf("/") + 1) + return `file://${path}/${fileName}` + } else + icon = Quickshell.iconPath(icon); return icon - const name = split[0] - const path = split[1] - const fileName = name.substring( - name.lastIndexOf("/") + 1) - return `file://${path}/${fileName}` - } else - icon = Quickshell.iconPath(icon); - return icon + } + return "" + } + asynchronous: true + smooth: true + mipmap: true + } + + Text { + id: windowTitle + + width: Math.min(implicitWidth, activeWindowDisplay.maxWidth - activeWindowIcon.width - activeWindowDisplayContent.spacing) + + property var appAliases: { "Firefox": "Mozilla Firefox", "mpv Media Player": "mpv", "Thunderbird": "Mozilla Thunderbird", "Thunderbird (LMU)": "Mozilla Thunderbird" } + + elide: Text.ElideRight + maximumLineCount: 1 + color: "white" + anchors.verticalCenter: parent.verticalCenter + text: { + if (!activeWindowDisplay.activeWindow) + return ""; + + var title = activeWindowDisplay.activeWindow.title; + var appName = activeWindowDisplay.windowEntry?.name; + if (appAliases[appName]) + appName = appAliases[appName]; + if (appName && title.endsWith(appName)) { + const oldTitle = title; + title = title.substring(0, title.length - appName.length); + title = title.replace(/\s*(—|-)\s*$/, ""); + if (!title) + title = oldTitle; + } + return title; + } } - return "" } - asynchronous: true - smooth: true - mipmap: true } + } + + Loader { + id: tooltipLoader + + active: false + + Connections { + target: widgetMouseArea + function onContainsMouseChanged() { + if (widgetMouseArea.containsMouse) + tooltipLoader.active = true; + } + } + + PopupWindow { + id: tooltip + + property bool nextVisible: widgetMouseArea.containsMouse || tooltipMouseArea.containsMouse + + anchor { + item: widgetMouseArea + edges: Edges.Bottom | Edges.Left + } + visible: false + + onNextVisibleChanged: hangTimer.restart() + + Timer { + id: hangTimer + interval: tooltip.visible ? 100 : 500 + onTriggered: { + tooltip.visible = tooltip.nextVisible; + if (!tooltip.visible) + tooltipLoader.active = false; + } + } + + implicitWidth: widgetTooltipText.contentWidth + 16 + implicitHeight: widgetTooltipText.contentHeight + 16 + color: "black" + + WrapperMouseArea { + id: tooltipMouseArea + + hoverEnabled: true + enabled: true + + anchors.centerIn: parent + + Text { + id: widgetTooltipText + + font.pointSize: 10 + font.family: "Fira Mono" + color: "white" - Text { - id: windowTitle - - width: Math.min(implicitWidth, activeWindowDisplay.maxWidth - activeWindowIcon.width - activeWindowDisplayContent.spacing) - - property var appAliases: { "Firefox": "Mozilla Firefox", "mpv Media Player": "mpv", "Thunderbird": "Mozilla Thunderbird", "Thunderbird (LMU)": "Mozilla Thunderbird" } - - elide: Text.ElideRight - maximumLineCount: 1 - color: "white" - anchors.verticalCenter: parent.verticalCenter - text: { - if (!activeWindowDisplay.activeWindow) - return ""; - - var title = activeWindowDisplay.activeWindow.title; - var appName = activeWindowDisplay.windowEntry?.name; - if (appAliases[appName]) - appName = appAliases[appName]; - if (appName && title.endsWith(appName)) { - const oldTitle = title; - title = title.substring(0, title.length - appName.length); - title = title.replace(/\s*(—|-)\s*$/, ""); - if (!title) - title = oldTitle; + text: JSON.stringify(Object.assign({}, activeWindowDisplay.activeWindow), null, 2) } - return title; } } } -- cgit v1.2.3