File indexing completed on 2024-12-29 05:06:03
0001 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 #pragma once 0005 0006 #include <QJsonObject> 0007 #include <QObject> 0008 #include <QQuickItem> 0009 #include <QString> 0010 0011 #include <KIO/ApplicationLauncherJob> 0012 #include <KService> 0013 0014 #include <KWayland/Client/connection_thread.h> 0015 #include <KWayland/Client/plasmawindowmanagement.h> 0016 #include <KWayland/Client/registry.h> 0017 #include <KWayland/Client/surface.h> 0018 0019 /** 0020 * @short Object that represents an application. 0021 */ 0022 class FolioApplication : public QObject 0023 { 0024 Q_OBJECT 0025 Q_PROPERTY(bool running READ running NOTIFY windowChanged) 0026 Q_PROPERTY(QString name READ name NOTIFY nameChanged) 0027 Q_PROPERTY(QString icon READ icon NOTIFY iconChanged) 0028 Q_PROPERTY(QString storageId READ storageId NOTIFY storageIdChanged) 0029 0030 public: 0031 FolioApplication(QObject *parent = nullptr, KService::Ptr service = QExplicitlySharedDataPointer<KService>{nullptr}); 0032 0033 static FolioApplication *fromJson(QJsonObject &obj, QObject *parent); // may return nullptr 0034 QJsonObject toJson() const; 0035 0036 bool running() const; 0037 QString name() const; 0038 QString icon() const; 0039 QString storageId() const; 0040 KWayland::Client::PlasmaWindow *window() const; 0041 0042 void setName(QString &name); 0043 void setIcon(QString &icon); 0044 void setStorageId(QString &storageId); 0045 void setWindow(KWayland::Client::PlasmaWindow *window); 0046 0047 Q_INVOKABLE void setMinimizedDelegate(QQuickItem *delegate); 0048 Q_INVOKABLE void unsetMinimizedDelegate(QQuickItem *delegate); 0049 0050 Q_SIGNALS: 0051 void nameChanged(); 0052 void iconChanged(); 0053 void storageIdChanged(); 0054 void windowChanged(); 0055 0056 private: 0057 bool m_running; 0058 QString m_name; 0059 QString m_icon; 0060 QString m_storageId; 0061 KWayland::Client::PlasmaWindow *m_window{nullptr}; 0062 };