summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml182
1 files changed, 127 insertions, 55 deletions
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 {
22 width: activeWindowDisplayContent.width 22 width: activeWindowDisplayContent.width
23 height: parent.height 23 height: parent.height
24 24
25 Row { 25 WrapperMouseArea {
26 id: activeWindowDisplayContent 26 id: widgetMouseArea
27 27
28 width: childrenRect.width 28 anchors.fill: parent
29 height: parent.height
30 anchors.verticalCenter: parent.verticalCenter
31 spacing: 8
32 29
33 IconImage { 30 hoverEnabled: true
34 id: activeWindowIcon
35 31
36 height: 14 32 Item {
37 width: 14 33 anchors.fill: parent
38 34
39 anchors.verticalCenter: parent.verticalCenter 35 Row {
36 id: activeWindowDisplayContent
40 37
41 source: { 38 width: childrenRect.width
42 let icon = activeWindowDisplay.windowEntry?.icon 39 height: parent.height
43 if (typeof icon === 'string' || icon instanceof String) { 40 anchors.verticalCenter: parent.verticalCenter
44 if (icon.includes("?path=")) { 41 spacing: 8
45 const split = icon.split("?path=") 42
46 if (split.length !== 2) 43 IconImage {
44 id: activeWindowIcon
45
46 implicitSize: 14
47
48 anchors.verticalCenter: parent.verticalCenter
49
50 source: {
51 let icon = activeWindowDisplay.windowEntry?.icon
52 if (typeof icon === 'string' || icon instanceof String) {
53 if (icon.includes("?path=")) {
54 const split = icon.split("?path=")
55 if (split.length !== 2)
56 return icon
57 const name = split[0]
58 const path = split[1]
59 const fileName = name.substring(
60 name.lastIndexOf("/") + 1)
61 return `file://${path}/${fileName}`
62 } else
63 icon = Quickshell.iconPath(icon);
47 return icon 64 return icon
48 const name = split[0] 65 }
49 const path = split[1] 66 return ""
50 const fileName = name.substring( 67 }
51 name.lastIndexOf("/") + 1) 68 asynchronous: true
52 return `file://${path}/${fileName}` 69 smooth: true
53 } else 70 mipmap: true
54 icon = Quickshell.iconPath(icon); 71 }
55 return icon 72
73 Text {
74 id: windowTitle
75
76 width: Math.min(implicitWidth, activeWindowDisplay.maxWidth - activeWindowIcon.width - activeWindowDisplayContent.spacing)
77
78 property var appAliases: { "Firefox": "Mozilla Firefox", "mpv Media Player": "mpv", "Thunderbird": "Mozilla Thunderbird", "Thunderbird (LMU)": "Mozilla Thunderbird" }
79
80 elide: Text.ElideRight
81 maximumLineCount: 1
82 color: "white"
83 anchors.verticalCenter: parent.verticalCenter
84 text: {
85 if (!activeWindowDisplay.activeWindow)
86 return "";
87
88 var title = activeWindowDisplay.activeWindow.title;
89 var appName = activeWindowDisplay.windowEntry?.name;
90 if (appAliases[appName])
91 appName = appAliases[appName];
92 if (appName && title.endsWith(appName)) {
93 const oldTitle = title;
94 title = title.substring(0, title.length - appName.length);
95 title = title.replace(/\s*(—|-)\s*$/, "");
96 if (!title)
97 title = oldTitle;
98 }
99 return title;
100 }
56 } 101 }
57 return ""
58 } 102 }
59 asynchronous: true
60 smooth: true
61 mipmap: true
62 } 103 }
104 }
105
106 Loader {
107 id: tooltipLoader
108
109 active: false
110
111 Connections {
112 target: widgetMouseArea
113 function onContainsMouseChanged() {
114 if (widgetMouseArea.containsMouse)
115 tooltipLoader.active = true;
116 }
117 }
118
119 PopupWindow {
120 id: tooltip
121
122 property bool nextVisible: widgetMouseArea.containsMouse || tooltipMouseArea.containsMouse
123
124 anchor {
125 item: widgetMouseArea
126 edges: Edges.Bottom | Edges.Left
127 }
128 visible: false
129
130 onNextVisibleChanged: hangTimer.restart()
131
132 Timer {
133 id: hangTimer
134 interval: tooltip.visible ? 100 : 500
135 onTriggered: {
136 tooltip.visible = tooltip.nextVisible;
137 if (!tooltip.visible)
138 tooltipLoader.active = false;
139 }
140 }
141
142 implicitWidth: widgetTooltipText.contentWidth + 16
143 implicitHeight: widgetTooltipText.contentHeight + 16
144 color: "black"
145
146 WrapperMouseArea {
147 id: tooltipMouseArea
148
149 hoverEnabled: true
150 enabled: true
151
152 anchors.centerIn: parent
153
154 Text {
155 id: widgetTooltipText
156
157 font.pointSize: 10
158 font.family: "Fira Mono"
159 color: "white"
63 160
64 Text { 161 text: JSON.stringify(Object.assign({}, activeWindowDisplay.activeWindow), null, 2)
65 id: windowTitle
66
67 width: Math.min(implicitWidth, activeWindowDisplay.maxWidth - activeWindowIcon.width - activeWindowDisplayContent.spacing)
68
69 property var appAliases: { "Firefox": "Mozilla Firefox", "mpv Media Player": "mpv", "Thunderbird": "Mozilla Thunderbird", "Thunderbird (LMU)": "Mozilla Thunderbird" }
70
71 elide: Text.ElideRight
72 maximumLineCount: 1
73 color: "white"
74 anchors.verticalCenter: parent.verticalCenter
75 text: {
76 if (!activeWindowDisplay.activeWindow)
77 return "";
78
79 var title = activeWindowDisplay.activeWindow.title;
80 var appName = activeWindowDisplay.windowEntry?.name;
81 if (appAliases[appName])
82 appName = appAliases[appName];
83 if (appName && title.endsWith(appName)) {
84 const oldTitle = title;
85 title = title.substring(0, title.length - appName.length);
86 title = title.replace(/\s*(—|-)\s*$/, "");
87 if (!title)
88 title = oldTitle;
89 } 162 }
90 return title;
91 } 163 }
92 } 164 }
93 } 165 }