shift-shell/containments/homescreens/folio/plugin/applicationlistmodel.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

79 lines
2.3 KiB
C
Raw Normal View History

2022-06-18 19:42:29 +00:00
// SPDX-FileCopyrightText: 2014 Antonis Tsiapaliokas <antonis.tsiapaliokas@kde.org>
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QAbstractListModel>
#include <QList>
#include <QObject>
#include <QQuickItem>
#include <QSet>
2022-06-18 19:42:29 +00:00
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/plasmawindowmanagement.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/surface.h>
/**
* @short The base application list, used directly by the app drawer.
*
* Items that are displayed on the desktop/pinned are done by DesktopModel, which is a subclass.
*/
class ApplicationListModel : public QAbstractListModel
{
Q_OBJECT
public:
// this enum is solely used by DesktopModel
enum LauncherLocation { None = 0, Favorites, Desktop };
2019-09-04 16:39:31 +00:00
Q_ENUM(LauncherLocation)
struct ApplicationData {
QString uniqueId;
QString name;
QString icon;
QString storageId;
QString entryPath;
bool startupNotify = true;
KWayland::Client::PlasmaWindow *window = nullptr;
LauncherLocation location = LauncherLocation::None; // only for DesktopModel
};
2019-09-04 16:39:31 +00:00
enum Roles {
ApplicationNameRole = Qt::UserRole + 1,
ApplicationIconRole,
ApplicationStorageIdRole,
ApplicationEntryPathRole,
ApplicationStartupNotifyRole,
ApplicationRunningRole,
ApplicationUniqueIdRole,
ApplicationLocationRole // only valid for DesktopModel
2019-09-04 16:39:31 +00:00
};
ApplicationListModel(QObject *parent = nullptr);
2018-12-31 03:13:55 +00:00
~ApplicationListModel() override;
2023-03-06 19:13:48 +00:00
static ApplicationListModel *self();
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
Q_INVOKABLE void setMinimizedDelegate(int row, QQuickItem *delegate);
Q_INVOKABLE void unsetMinimizedDelegate(int row, QQuickItem *delegate);
public Q_SLOTS:
void sycocaDbChanged();
void windowCreated(KWayland::Client::PlasmaWindow *window);
Q_SIGNALS:
void launchError(const QString &msg);
protected:
virtual void load();
QList<ApplicationData> m_applicationList;
KWayland::Client::PlasmaWindowManagement *m_windowManagement = nullptr;
};