1 /* 2 SPDX-FileCopyrightText: 2015 Eike Hein <hein.org> 3 4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 5 */ 6 #ifndef WAYLAND_PLASMAWINDOWMODEL_H 7 #define WAYLAND_PLASMAWINDOWMODEL_H 8 9 #include <QAbstractListModel> 10 11 #include <KWayland/Client/kwaylandclient_export.h> 12 13 namespace KWayland 14 { 15 namespace Client 16 { 17 class PlasmaWindowManagement; 18 class Surface; 19 20 /** 21 * @short Exposes the window list and window state as a Qt item model. 22 * 23 * This class is a QAbstractListModel implementation that exposes information 24 * from a PlasmaWindowManagement instance passed as parent and enables convenient 25 * calls to PlasmaWindow methods through a model row index. 26 * 27 * The model is destroyed when the PlasmaWindowManagement parent is. 28 * 29 * The model resets when the PlasmaWindowManagement parent signals that its 30 * interface is about to be destroyed. 31 * 32 * To use this class you can create an instance yourself, or preferably use the 33 * convenience method in PlasmaWindowManagement: 34 * @code 35 * PlasmaWindowModel *model = wm->createWindowModel(); 36 * @endcode 37 * 38 * @see PlasmaWindowManagement 39 * @see PlasmaWindow 40 **/ 41 42 class KWAYLANDCLIENT_EXPORT PlasmaWindowModel : public QAbstractListModel 43 { 44 Q_OBJECT 45 46 public: 47 enum AdditionalRoles { 48 AppId = Qt::UserRole + 1, 49 IsActive, 50 IsFullscreenable, 51 IsFullscreen, 52 IsMaximizable, 53 IsMaximized, 54 IsMinimizable, 55 IsMinimized, 56 IsKeepAbove, 57 IsKeepBelow, 58 #if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 53) 59 /** 60 @deprecated Since 5.53, use VirtualDesktops 61 */ 62 VirtualDesktop KWAYLANDCLIENT_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 53, "Use VirtualDesktops"), 63 #else 64 VirtualDesktop_DEPRECATED_DO_NOT_USE, 65 #endif 66 IsOnAllDesktops, 67 IsDemandingAttention, 68 SkipTaskbar, 69 /** 70 * @since 5.22 71 */ 72 IsShadeable, 73 /** 74 * @since 5.22 75 */ 76 IsShaded, 77 /** 78 * @since 5.22 79 */ 80 IsMovable, 81 /** 82 * @since 5.22 83 */ 84 IsResizable, 85 /** 86 * @since 5.22 87 */ 88 IsVirtualDesktopChangeable, 89 /** 90 * @since 5.22 91 */ 92 IsCloseable, 93 /** 94 * @since 5.25 95 */ 96 Geometry, 97 /** 98 * @since 5.35 99 */ 100 Pid, 101 /** 102 * @since 5.47 103 */ 104 SkipSwitcher, 105 /** 106 * @since 5.53 107 */ 108 VirtualDesktops, 109 /** 110 * @since 5.73 111 */ 112 Uuid, 113 }; 114 Q_ENUM(AdditionalRoles) 115 116 explicit PlasmaWindowModel(PlasmaWindowManagement *parent); 117 ~PlasmaWindowModel() override; 118 119 QHash<int, QByteArray> roleNames() const override; 120 121 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 122 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 123 124 /** 125 * Returns an index with internalPointer() pointing to a PlasmaWindow instance. 126 **/ 127 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override; 128 129 /** 130 * Request the window at this model row index be activated. 131 **/ 132 Q_INVOKABLE void requestActivate(int row); 133 134 /** 135 * Request the window at this model row index be closed. 136 **/ 137 Q_INVOKABLE void requestClose(int row); 138 139 /** 140 * Request an interactive move for the window at this model row index. 141 * @since 5.22 142 **/ 143 Q_INVOKABLE void requestMove(int row); 144 145 /** 146 * Request an interactive resize for the window at this model row index. 147 * @since 5.22 148 **/ 149 Q_INVOKABLE void requestResize(int row); 150 151 /** 152 * Request the window at this model row index be moved to this virtual desktop. 153 **/ 154 Q_INVOKABLE void requestVirtualDesktop(int row, quint32 desktop); 155 156 /** 157 * Requests the window at this model row index have its keep above state toggled. 158 * @since 5.35 159 */ 160 Q_INVOKABLE void requestToggleKeepAbove(int row); 161 162 /** 163 * Requests the window at this model row index have its keep above state toggled. 164 * @since 5.35 165 */ 166 Q_INVOKABLE void requestToggleKeepBelow(int row); 167 168 /** 169 * Requests the window at this model row index have its minimized state toggled. 170 */ 171 Q_INVOKABLE void requestToggleMinimized(int row); 172 173 /** 174 * Requests the window at this model row index have its maximized state toggled. 175 */ 176 Q_INVOKABLE void requestToggleMaximized(int row); 177 178 /** 179 * Sets the geometry of the taskbar entry for the window at the model row 180 * relative to a panel in particular. QRectF, intended for use from QML 181 * @since 5.5 182 */ 183 Q_INVOKABLE void setMinimizedGeometry(int row, Surface *panel, const QRect &geom); 184 185 /** 186 * Requests the window at this model row index have its shaded state toggled. 187 * @since 5.22 188 */ 189 Q_INVOKABLE void requestToggleShaded(int row); 190 191 private: 192 class Private; 193 QScopedPointer<Private> d; 194 }; 195 196 } 197 } 198 199 #endif 200