Create Alt+tab window, refactor sortedDesktopApplications so they are inside a ListModel instead of a Map()

This commit is contained in:
2025-10-13 16:51:26 -03:00
parent f80abc48ae
commit 22c6bbf8ba
5 changed files with 189 additions and 25 deletions

View File

@@ -1,5 +1,6 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Wayland
@@ -70,6 +71,34 @@ Singleton {
return sortedTopLevels.map(topLevel => topLevel.workspace);
}
property ListModel sortedDesktopApplicationsModel: ListModel {}
onSortedTopLevelsChanged: updateSortedDesktopApplications()
function updateSortedDesktopApplications() {
sortedDesktopApplicationsModel.clear();
for (const topLevel of sortedTopLevels) {
const entry = DesktopEntries.heuristicLookup(topLevel.wayland.appId);
sortedDesktopApplicationsModel.append({
topLevel: topLevel,
desktopEntry: entry
});
}
}
function workspaceApps(workspaceIndexAlign) {
const list = []
const model = sortedDesktopApplicationsModel
for (let i = 0; i < model.count; i++) {
const item = model.get(i)
if (item.topLevel.workspace.id === workspaceIndexAlign)
list.push(item.desktopEntry)
}
return list
}
property var sortedDesktopApplications: {
const sortedWayland = sortedTopLevels.map(topLevel => topLevel.wayland).filter(wayland => wayland !== null);

View File

@@ -62,13 +62,13 @@ Singleton {
StyledText {
text: {
if (!HoverMediator.component?.model)
return "";
return "";
if (HoverMediator.component.model.tooltipTitle)
return HoverMediator.component.model.tooltipTitle;
return HoverMediator.component.model.tooltipTitle;
if (HoverMediator.component.model.title)
return HoverMediator.component.model.title;
return HoverMediator.component.model.title;
else
return "";
return "";
}
}
}
@@ -76,7 +76,7 @@ Singleton {
Component {
id: time
RowLayout{
RowLayout {
id: rowlayoutCalendar
readonly property date now: new Date()
@@ -132,9 +132,7 @@ Singleton {
Repeater {
property var modelo: HyprlandService.sortedDesktopApplications.get(parent.workspaceIndexAlign)
model: modelo
model: HyprlandService.workspaceApps(parent.workspaceIndexAlign)
delegate: IconImage {
required property var modelData
@@ -172,15 +170,15 @@ Singleton {
id: hoverLoader
sourceComponent: {
if (!HoverMediator.type)
return stub;
return stub;
if (HoverMediator.type === "workspace")
return workspaceComponent;
return workspaceComponent;
if (HoverMediator.type === "audio")
return audio;
return audio;
if (HoverMediator.type === "time")
return time;
return time;
if (HoverMediator.type === "systray")
return systray;
return systray;
}
}
}