From 3238abfe54b98c8fd8332814bcbf430c8b79c7ac Mon Sep 17 00:00:00 2001 From: Anton Kharuzhy Date: Wed, 20 Mar 2024 14:25:37 +0100 Subject: [PATCH] Bugfix: disable buttons with last active filter --- package/contents/ui/ActiveTasksModel.qml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/package/contents/ui/ActiveTasksModel.qml b/package/contents/ui/ActiveTasksModel.qml index 3321386..b556408 100644 --- a/package/contents/ui/ActiveTasksModel.qml +++ b/package/contents/ui/ActiveTasksModel.qml @@ -25,31 +25,45 @@ TaskManager.TasksModel { return index(-1, -1); } + function getFirstRowIndex() { + return index(0, 0); + } + function updateActiveTaskIndex() { switch (plasmoid.configuration.widgetActiveTaskSource) { case ActiveTasksModel.ActiveTaskSource.ActiveTask: - activeTaskIndex = activeTask; + activeTaskIndex = filterTask(activeTask) ? activeTask : getInvalidIndex(); break; case ActiveTasksModel.ActiveTaskSource.LastActiveTask: - activeTaskIndex = hasIndex(0, 0) ? index(0, 0) : getInvalidIndex(); + activeTaskIndex = hasIndex(0, 0) && filterTask(getFirstRowIndex()) ? getFirstRowIndex() : getInvalidIndex(); break; } activeWindow.update(); } + function filterTask(index) { + if (!index || !index.valid) + return false; + + if (plasmoid.configuration.widgetActiveTaskFilterNotMaximized) + return tasksModel.data(index, TaskManager.AbstractTasksModel.IsMaximized) || false; + + return true; + } + screenGeometry: plasmoid.containment.screenGeometry activity: activityInfo.currentActivity virtualDesktop: virtualDesktopInfo.currentDesktop filterByActivity: plasmoid.configuration.widgetActiveTaskFilterByActivity filterByScreen: plasmoid.configuration.widgetActiveTaskFilterByScreen filterByVirtualDesktop: plasmoid.configuration.widgetActiveTaskFilterByVirtualDesktop - filterNotMaximized: plasmoid.configuration.widgetActiveTaskFilterNotMaximized filterHidden: true filterMinimized: true onDataChanged: function(from, to, roles) { if (hasActiveWindow && activeTaskIndex >= from && activeTaskIndex <= to) - activeWindow.update(); - + updateActiveTaskIndex(); + else if (!hasActiveWindow && getFirstRowIndex() >= from && getFirstRowIndex() <= to) + updateActiveTaskIndex(); } onActiveTaskChanged: updateActiveTaskIndex() onCountChanged: updateActiveTaskIndex()