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
|
2014-10-28 12:27:54 +00:00
|
|
|
|
2022-04-06 02:06:05 +00:00
|
|
|
#pragma once
|
2014-10-28 12:27:54 +00:00
|
|
|
|
2019-09-18 11:55:07 +00:00
|
|
|
#include <QAbstractListModel>
|
2014-10-28 12:27:54 +00:00
|
|
|
#include <QList>
|
2022-04-06 02:06:05 +00:00
|
|
|
#include <QObject>
|
2022-04-07 14:52:12 +00:00
|
|
|
#include <QQuickItem>
|
2019-12-06 21:04:33 +00:00
|
|
|
#include <QSet>
|
2014-10-28 12:27:54 +00:00
|
|
|
|
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>
|
2020-07-28 11:24:13 +00:00
|
|
|
|
2022-06-17 04:48:53 +00:00
|
|
|
/**
|
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2022-04-06 02:06:05 +00:00
|
|
|
class ApplicationListModel : public QAbstractListModel
|
|
|
|
|
{
|
2014-10-28 12:27:54 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2022-06-17 04:48:53 +00:00
|
|
|
// this enum is solely used by DesktopModel
|
|
|
|
|
enum LauncherLocation { None = 0, Favorites, Desktop };
|
2019-09-04 16:39:31 +00:00
|
|
|
Q_ENUM(LauncherLocation)
|
|
|
|
|
|
2020-03-21 11:48:45 +00:00
|
|
|
struct ApplicationData {
|
2021-02-15 10:44:48 +00:00
|
|
|
QString uniqueId;
|
2020-03-21 11:48:45 +00:00
|
|
|
QString name;
|
|
|
|
|
QString icon;
|
|
|
|
|
QString storageId;
|
|
|
|
|
QString entryPath;
|
|
|
|
|
bool startupNotify = true;
|
2020-07-28 11:24:13 +00:00
|
|
|
KWayland::Client::PlasmaWindow *window = nullptr;
|
2022-06-17 04:48:53 +00:00
|
|
|
LauncherLocation location = LauncherLocation::None; // only for DesktopModel
|
2020-03-21 11:48:45 +00:00
|
|
|
};
|
|
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
enum Roles {
|
2019-09-18 11:55:07 +00:00
|
|
|
ApplicationNameRole = Qt::UserRole + 1,
|
|
|
|
|
ApplicationIconRole,
|
|
|
|
|
ApplicationStorageIdRole,
|
|
|
|
|
ApplicationEntryPathRole,
|
|
|
|
|
ApplicationStartupNotifyRole,
|
2021-02-15 10:44:48 +00:00
|
|
|
ApplicationRunningRole,
|
2022-06-17 04:48:53 +00:00
|
|
|
ApplicationUniqueIdRole,
|
|
|
|
|
ApplicationLocationRole // only valid for DesktopModel
|
2019-09-04 16:39:31 +00:00
|
|
|
};
|
|
|
|
|
|
2021-03-18 14:07:33 +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();
|
2014-10-28 12:27:54 +00:00
|
|
|
|
2019-09-18 11:55:07 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
2014-10-28 12:27:54 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
|
|
|
|
|
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
|
|
|
|
|
|
2020-07-30 15:20:07 +00:00
|
|
|
Q_INVOKABLE void setMinimizedDelegate(int row, QQuickItem *delegate);
|
2020-07-31 09:11:26 +00:00
|
|
|
Q_INVOKABLE void unsetMinimizedDelegate(int row, QQuickItem *delegate);
|
2020-07-30 15:20:07 +00:00
|
|
|
|
2015-03-18 13:57:54 +00:00
|
|
|
public Q_SLOTS:
|
2022-05-13 06:32:52 +00:00
|
|
|
void sycocaDbChanged();
|
2022-04-06 21:18:20 +00:00
|
|
|
void windowCreated(KWayland::Client::PlasmaWindow *window);
|
2015-03-18 13:57:54 +00:00
|
|
|
|
2014-10-28 12:27:54 +00:00
|
|
|
Q_SIGNALS:
|
2021-09-13 12:22:47 +00:00
|
|
|
void launchError(const QString &msg);
|
2014-10-28 12:27:54 +00:00
|
|
|
|
2021-02-15 10:44:48 +00:00
|
|
|
protected:
|
2023-03-05 17:39:03 +00:00
|
|
|
virtual void load();
|
|
|
|
|
|
2019-09-18 11:55:07 +00:00
|
|
|
QList<ApplicationData> m_applicationList;
|
|
|
|
|
|
2022-06-17 04:48:53 +00:00
|
|
|
KWayland::Client::PlasmaWindowManagement *m_windowManagement = nullptr;
|
2014-10-28 12:27:54 +00:00
|
|
|
};
|