KWayland

plasmawindowmodel.h
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:
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  */
73  /**
74  * @since 5.22
75  */
77  /**
78  * @since 5.22
79  */
81  /**
82  * @since 5.22
83  */
85  /**
86  * @since 5.22
87  */
89  /**
90  * @since 5.22
91  */
93  /**
94  * @since 5.25
95  */
97  /**
98  * @since 5.35
99  */
101  /**
102  * @since 5.47
103  */
105  /**
106  * @since 5.53
107  */
109  /**
110  * @since 5.73
111  */
113  LastRole,
114  };
115  Q_ENUM(AdditionalRoles)
116 
117  explicit PlasmaWindowModel(PlasmaWindowManagement *parent);
118  ~PlasmaWindowModel() override;
119 
120  QHash<int, QByteArray> roleNames() const override;
121 
122  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
123  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
124 
125  /**
126  * Returns an index with internalPointer() pointing to a PlasmaWindow instance.
127  **/
128  QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
129 
130  QMap<int, QVariant> itemData(const QModelIndex &index) const override;
131 
132  /**
133  * Request the window at this model row index be activated.
134  **/
135  Q_INVOKABLE void requestActivate(int row);
136 
137  /**
138  * Request the window at this model row index be closed.
139  **/
140  Q_INVOKABLE void requestClose(int row);
141 
142  /**
143  * Request an interactive move for the window at this model row index.
144  * @since 5.22
145  **/
146  Q_INVOKABLE void requestMove(int row);
147 
148  /**
149  * Request an interactive resize for the window at this model row index.
150  * @since 5.22
151  **/
152  Q_INVOKABLE void requestResize(int row);
153 
154 #if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 52)
155  /**
156  * Request the window at this model row index be moved to this virtual desktop.
157  *
158  * @deprecated Since 5.52; starting from 5.90, use requestEnterVirtualDesktop(int row, const QString &id) instead.
159  **/
160  KWAYLANDCLIENT_DEPRECATED_VERSION(5, 52, "Starting from 5.90 use PlasmaWindowModel::requestEnterVirtualDesktop(int row, const QString &id) instead.")
161  Q_INVOKABLE void requestVirtualDesktop(int row, quint32 desktop);
162 #endif
163 
164  /**
165  * Request the window at the model index @p row to be moved to the virtual desktop @p id.
166  *
167  * @since 5.90
168  **/
169  Q_INVOKABLE void requestEnterVirtualDesktop(int row, const QString &id);
170 
171  /**
172  * Requests the window at this model row index have its keep above state toggled.
173  * @since 5.35
174  */
175  Q_INVOKABLE void requestToggleKeepAbove(int row);
176 
177  /**
178  * Requests the window at this model row index have its keep above state toggled.
179  * @since 5.35
180  */
181  Q_INVOKABLE void requestToggleKeepBelow(int row);
182 
183  /**
184  * Requests the window at this model row index have its minimized state toggled.
185  */
186  Q_INVOKABLE void requestToggleMinimized(int row);
187 
188  /**
189  * Requests the window at this model row index have its maximized state toggled.
190  */
191  Q_INVOKABLE void requestToggleMaximized(int row);
192 
193  /**
194  * Sets the geometry of the taskbar entry for the window at the model row
195  * relative to a panel in particular. QRectF, intended for use from QML
196  * @since 5.5
197  */
198  Q_INVOKABLE void setMinimizedGeometry(int row, Surface *panel, const QRect &geom);
199 
200  /**
201  * Requests the window at this model row index have its shaded state toggled.
202  * @since 5.22
203  */
204  Q_INVOKABLE void requestToggleShaded(int row);
205 
206 private:
207  class Private;
209 };
210 
211 }
212 }
213 
214 #endif
UserRole
Wrapper for the wl_surface interface.
Definition: surface.h:43
Wrapper for the org_kde_plasma_window_management interface.
Exposes the window list and window state as a Qt item model.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Feb 5 2023 03:56:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.