shift-shell/kwin/mobiletaskswitcher/plugin/taskmodel.h
Devin Lin bbac7e98b4 taskswitcher: Switch to declarative effect
This switches the kwin effect to be a declarative effect. However, for
now I have retained much of the logic that exists in cpp as a QML
plugin.

Fixes https://invent.kde.org/plasma/plasma-mobile/-/issues/448

Also implements https://invent.kde.org/plasma/plasma-mobile/-/issues/408 now that we can access the QML api
2025-03-01 21:26:47 +00:00

49 lines
No EOL
1.2 KiB
C++

// SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
// SPDX-FileCopyrightText: 2024 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <window.h>
#include <QAbstractListModel>
#include <QHash>
#include <QSortFilterProxyModel>
#include <QVariant>
namespace KWin
{
class TaskModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Roles {
WindowRole = Qt::UserRole + 1,
OutputRole,
DesktopRole,
ActivityRole,
LastActivatedRole
};
explicit TaskModel(QObject *parent = nullptr);
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
private:
void markRoleChanged(Window *window, int role);
void handleWindowAdded(Window *window);
void handleWindowRemoved(Window *window);
void setupWindowConnections(Window *window);
void handleActiveWindowChanged();
// qint64 - Last activated timestamp
QList<std::pair<Window *, qint64>> m_windows;
};
}; // namespace KWin