Skip to content

Commit

Permalink
Bugfix: disable buttons with last active filter
Browse files Browse the repository at this point in the history
  • Loading branch information
antroids committed Mar 20, 2024
1 parent b90494c commit 3238abf
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions package/contents/ui/ActiveTasksModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 3238abf

Please sign in to comment.