Follow reordered taskbar pins in group shortcuts
This commit is contained in:
1 parent
dc2372ef3f
commit
535ac5b480
6 files changed
+180
-2
No files matched your search
@@ -6,12 +6,44 @@
|
||||
#include <QHash>
|
||||
#include <QSet>
|
||||
#include <QUrl>
|
||||
#include <algorithm>
|
||||
|
||||
#include <abstracttasksmodel.h>
|
||||
#include <tasksmodel.h>
|
||||
#include <tasktools.h>
|
||||
|
||||
using TaskManager::AbstractTasksModel;
|
||||
|
||||
QVector<int> logicalTaskRows(const TaskManager::TasksModel &model, bool separateLaunchers)
|
||||
{
|
||||
auto rows = logicalTaskRows(static_cast<const QAbstractItemModel &>(model), separateLaunchers);
|
||||
if (model.sortMode() != TaskManager::TasksModel::SortManual) {
|
||||
return rows;
|
||||
}
|
||||
|
||||
// TasksModel keeps its manual window order when setLauncherList changes.
|
||||
// Reorder only launcher-backed slots; leave unpinned tasks and children alone.
|
||||
QVector<int> pinnedSlots;
|
||||
QVector<int> pinnedRows;
|
||||
const auto launcherPosition = [&](int row) {
|
||||
return model.launcherPosition(model.index(row, 0).data(AbstractTasksModel::LauncherUrlWithoutIcon).toUrl());
|
||||
};
|
||||
for (int i = 0; i < rows.size(); ++i) {
|
||||
if ((!separateLaunchers || model.index(rows.at(i), 0).data(AbstractTasksModel::IsLauncher).toBool())
|
||||
&& launcherPosition(rows.at(i)) >= 0) {
|
||||
pinnedSlots.append(i);
|
||||
pinnedRows.append(rows.at(i));
|
||||
}
|
||||
}
|
||||
std::stable_sort(pinnedRows.begin(), pinnedRows.end(), [&](int left, int right) {
|
||||
return launcherPosition(left) < launcherPosition(right);
|
||||
});
|
||||
for (int i = 0; i < pinnedSlots.size(); ++i) {
|
||||
rows[pinnedSlots.at(i)] = pinnedRows.at(i);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
QModelIndex taskToActivate(const QAbstractItemModel &model, int row, int cyclePosition)
|
||||
{
|
||||
const QModelIndex task = model.index(row, 0);
|
||||
|
||||
Reference in new issue
Block a user