Warning, file /plasma/plasma-workspace/shell/shellcontainmentconfig.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2021 Cyril Rossi <cyril.rossi@enioka.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractTableModel> 0010 #include <QHash> 0011 #include <QObject> 0012 #include <QQmlApplicationEngine> 0013 #include <QQuickView> 0014 0015 #include <plasma/containment.h> 0016 #include <plasma/plasma.h> 0017 0018 namespace KActivities 0019 { 0020 class Consumer; 0021 class Info; 0022 } 0023 0024 class ShellCorona; 0025 class ShellContainmentModel; 0026 0027 class ScreenPoolModel : public QAbstractListModel 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 enum ScreenPoolModelRoles { ScreenIdRole = Qt::UserRole + 1, ScreenNameRole, ContainmentsRole, PrimaryRole, EnabledRole }; 0033 0034 public: 0035 explicit ScreenPoolModel(ShellCorona *corona, QObject *parent = nullptr); 0036 ~ScreenPoolModel() override; 0037 0038 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0039 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0040 QHash<int, QByteArray> roleNames() const override; 0041 0042 public Q_SLOTS: 0043 void load(); 0044 void remove(int screenId); 0045 0046 private: 0047 ShellCorona *m_corona; 0048 struct Data { 0049 int id; 0050 QString name; 0051 bool primary; 0052 bool enabled; 0053 }; 0054 QTimer *m_reloadTimer = nullptr; 0055 QList<Data> m_screens; 0056 QList<ShellContainmentModel *> m_containments; 0057 }; 0058 0059 class ShellContainmentModel : public QAbstractListModel 0060 { 0061 Q_OBJECT 0062 0063 Q_PROPERTY(ScreenPoolModel *screenPoolModel READ screenPoolModel CONSTANT) 0064 0065 public: 0066 enum ShellContainmentModelRoles { 0067 ContainmentIdRole = Qt::UserRole + 1, 0068 ScreenRole, 0069 EdgeRole, 0070 EdgePositionRole, 0071 PanelCountAtRightRole, 0072 PanelCountAtTopRole, 0073 PanelCountAtLeftRole, 0074 PanelCountAtBottomRole, 0075 ActivityRole, 0076 IsActiveRole, 0077 ImageSourceRole, 0078 DestroyedRole 0079 }; 0080 0081 public: 0082 explicit ShellContainmentModel(ShellCorona *corona, int screenId, ScreenPoolModel *parent = nullptr); 0083 ~ShellContainmentModel() override; 0084 0085 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0086 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0087 QHash<int, QByteArray> roleNames() const override; 0088 0089 ScreenPoolModel *screenPoolModel() const; 0090 0091 Q_INVOKABLE void remove(int contId); 0092 Q_INVOKABLE void moveContainementToScreen(unsigned int contId, int newScreen); 0093 0094 bool findContainment(unsigned int containmentId) const; 0095 0096 void loadActivitiesInfos(); 0097 0098 public Q_SLOTS: 0099 void load(); 0100 0101 private: 0102 static QString plasmaLocationToString(const Plasma::Types::Location location); 0103 0104 Plasma::Containment *containmentById(unsigned int id); 0105 QString containmentPreview(Plasma::Containment *containment); 0106 0107 private: 0108 int m_screenId = -1; 0109 ShellCorona *m_corona; 0110 struct Data { 0111 unsigned int id; 0112 int screen; 0113 Plasma::Types::Location edge; 0114 QString activity; 0115 bool changed = false; 0116 bool isActive = true; 0117 QString image; 0118 const Plasma::Containment *containment; 0119 }; 0120 QTimer *m_reloadTimer = nullptr; 0121 QList<Data> m_containments; 0122 ScreenPoolModel *m_screenPoolModel; 0123 QHash<QString, KActivities::Info *> m_activitiesInfos; 0124 KActivities::Consumer *m_activityConsumer; 0125 QHash<int, QHash<Plasma::Types::Location, QList<int>>> m_edgeCount; 0126 }; 0127 0128 class ShellContainmentConfig : public QQmlApplicationEngine 0129 { 0130 Q_OBJECT 0131 0132 public: 0133 ShellContainmentConfig(ShellCorona *corona, QWindow *parent = nullptr); 0134 ~ShellContainmentConfig() override; 0135 0136 void init(); 0137 0138 private: 0139 ShellCorona *m_corona; 0140 ScreenPoolModel *m_model; 0141 };