KDecoration3

decoratedwindow.h
1/*
2 * SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6#pragma once
7
8#include "decoration.h"
9#include "decorationdefines.h"
10#include <kdecoration3/kdecoration3_export.h>
11
12#include <QFont>
13#include <QIcon>
14#include <QObject>
15#include <QPalette>
16#include <QPointer>
17#include <QtGui/qwindowdefs.h>
18
19#include <memory>
20
21namespace KDecoration3
22{
23class DecorationBridge;
24class DecoratedWindowPrivate;
25
26/**
27 * @brief The Client which gets decorated.
28 *
29 * The DecoratedWindow provides access to all the properties relevant for decorating the Client.
30 * Each DecoratedWindow is bound to one Decoration and each Decoration is bound to this one
31 * DecoratedWindow.
32 *
33 * The DecoratedWindow only exports properties, it does not provide any means to change the state.
34 * To change state one needs to call the methods on Decoration. This is as the backend might
35 * disallow state changes. Therefore any changes should be bound to the change signals of the
36 * DecoratedWindow and not be bound to state changes of input elements (such as a button).
37 */
38class KDECORATIONS3_EXPORT DecoratedWindow : public QObject
39{
41 /**
42 * The Decoration of this DecoratedWindow
43 **/
45 /**
46 * Whether the DecoratedWindow is active (has focus) or is inactive.
47 **/
48 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
49 /**
50 * The caption of the DecoratedWindow.
51 **/
52 Q_PROPERTY(QString caption READ caption NOTIFY captionChanged)
53 /**
54 * Whether the DecoratedWindow is on all desktops or on just one.
55 **/
56 Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops NOTIFY onAllDesktopsChanged)
57 /**
58 * Whether the DecoratedWindow is shaded. Shaded means that the actual content is
59 * not visible, only the Decoration is visible.
60 **/
61 Q_PROPERTY(bool shaded READ isShaded NOTIFY shadedChanged)
62 /**
63 * The icon of the DecoratedWindow. This can be used as the icon for the window menu button.
64 **/
65 Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
66 /**
67 * Whether the DecoratedWindow is maximized. A DecoratedWindow is maximized if it is both
68 * maximizedHorizontally and maximizedVertically. The Decoration of a maximized DecoratedWindow
69 * should only consist of the title bar area.
70 **/
71 Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged)
72 /**
73 * Whether the DecoratedWindow is maximized horizontally. A horizontally maximized DecoratedWindow
74 * uses the maximal possible width.
75 **/
76 Q_PROPERTY(bool maximizedHorizontally READ isMaximizedHorizontally NOTIFY maximizedHorizontallyChanged)
77 /**
78 * Whether the DecoratedWindow is maximized vertically. A vertically maximized DecoratedWindow
79 * uses the maximal possible height.
80 **/
81 Q_PROPERTY(bool maximizedVertically READ isMaximizedVertically NOTIFY maximizedVerticallyChanged)
82 /**
83 * Whether the DecoratedWindow is set to be kept above other DecoratedWindows. There can be multiple
84 * DecoratedWindows which are set to be kept above.
85 **/
86 Q_PROPERTY(bool keepAbove READ isKeepAbove NOTIFY keepAboveChanged)
87 /**
88 * Whether the DecoratedWindow is set to be kept below other DecoratedWindows. There can be multiple
89 * DecoratedWindows which are set to be kept below.
90 **/
91 Q_PROPERTY(bool keepBelow READ isKeepBelow NOTIFY keepBelowChanged)
92
93 /**
94 * Whether the DecoratedWindow can be closed. If this property is @c false a DecorationButton
95 * for closing the DecoratedWindow should be disabled.
96 **/
97 Q_PROPERTY(bool closeable READ isCloseable NOTIFY closeableChanged)
98 /**
99 * Whether the DecoratedWindow can be maximized. If this property is @c false a DecorationButton
100 * for maximizing the DecoratedWindow should be disabled.
101 **/
102 Q_PROPERTY(bool maximizeable READ isMaximizeable NOTIFY maximizeableChanged)
103 /**
104 * Whether the DecoratedWindow can be minimized. If this property is @c false a DecorationButton
105 * for minimizing the DecoratedWindow should be disabled.
106 **/
107 Q_PROPERTY(bool minimizeable READ isMinimizeable NOTIFY minimizeableChanged)
108 /**
109 * Whether the DecoratedWindow provides context help.
110 * The Decoration should only show a context help button if this property is @c true.
111 **/
112 Q_PROPERTY(bool providesContextHelp READ providesContextHelp NOTIFY providesContextHelpChanged)
113 /**
114 * Whether the DecoratedWindow is a modal dialog.
115 **/
116 Q_PROPERTY(bool modal READ isModal CONSTANT)
117 /**
118 * Whether the DecoratedWindow can be shaded. If this property is @c false a DecorationButton
119 * for shading the DecoratedWindow should be disabled.
120 **/
121 Q_PROPERTY(bool shadeable READ isShadeable NOTIFY shadeableChanged)
122 /**
123 * Whether the DecoratedWindow can be moved.
124 **/
125 Q_PROPERTY(bool moveable READ isMoveable NOTIFY moveableChanged)
126 /**
127 * Whether the DecoratedWindow can be resized.
128 **/
129 Q_PROPERTY(bool resizeable READ isResizeable NOTIFY resizeableChanged)
130
131 /**
132 * The width of the DecoratedWindow.
133 **/
134 Q_PROPERTY(qreal width READ width NOTIFY widthChanged)
135 /**
136 * The height of the DecoratedWindow.
137 **/
138 Q_PROPERTY(qreal height READ height NOTIFY heightChanged)
139 /**
140 * The size of the DecoratedWindow.
141 **/
142 Q_PROPERTY(QSizeF size READ size NOTIFY sizeChanged)
143 /**
144 * The palette this DecoratedWindow uses. The palette might be different for each
145 * DecoratedWindow and the Decoration should honor the palette.
146 **/
147 Q_PROPERTY(QPalette palette READ palette NOTIFY paletteChanged)
148 /**
149 * The Edges which are adjacent to a screen edge. E.g. for a maximized DecoratedWindow this
150 * will include all Edges. The Decoration can use this information to hide borders.
151 **/
152 Q_PROPERTY(Qt::Edges adjacentScreenEdges READ adjacentScreenEdges NOTIFY adjacentScreenEdgesChanged)
153 /**
154 * Whether the DecoratedWindow has an application menu
155 * @since 5.9
156 */
157 Q_PROPERTY(bool hasApplicationMenu READ hasApplicationMenu NOTIFY hasApplicationMenuChanged)
158 /**
159 * Whether the application menu for this DecoratedWindow is currently shown to the user
160 * The Decoration can use this information to highlight the respective button.
161 * @since 5.9
162 */
163 Q_PROPERTY(bool applicationMenuActive READ isApplicationMenuActive NOTIFY applicationMenuActiveChanged)
164 /**
165 * Returns the DBus service name of the application menu. If the window has no application
166 * menu associated with it, an empty string will be returned.
167 *
168 * @since 6.3.2
169 */
171 /**
172 * Returns the DBus object path of the application menu. If the window has no application
173 * menu associated with it, an empty string will be returned.
174 *
175 * @since 6.3.2
176 */
178
179 /**
180 * The current scale this decorated window is targeting.
181 * @since 6.3
182 */
183 Q_PROPERTY(qreal scale READ scale NOTIFY scaleChanged);
184
185 /**
186 * The next scale this decorated window is going to target.
187 * @since 6.3
188 */
189 Q_PROPERTY(qreal nextScale READ nextScale NOTIFY nextScaleChanged)
190
191public:
192 DecoratedWindow() = delete;
193 ~DecoratedWindow() override;
194 bool isActive() const;
195 QString caption() const;
196 bool isOnAllDesktops() const;
197 bool isShaded() const;
198 QIcon icon() const;
199 bool isMaximized() const;
200 bool isMaximizedHorizontally() const;
201 bool isMaximizedVertically() const;
202 bool isKeepAbove() const;
203 bool isKeepBelow() const;
204
205 bool isCloseable() const;
206 bool isMaximizeable() const;
207 bool isMinimizeable() const;
208 bool providesContextHelp() const;
209 bool isModal() const;
210 bool isShadeable() const;
211 bool isMoveable() const;
212 bool isResizeable() const;
213
214 Qt::Edges adjacentScreenEdges() const;
215
216 QString windowClass() const;
217
218 qreal width() const;
219 qreal height() const;
220 QSizeF size() const;
221
222 Decoration *decoration() const;
223 QPalette palette() const;
224 /**
225 * Used to get colors in QPalette.
226 * @param group The color group
227 * @param role The color role
228 * @return palette().color(group, role)
229 * @since 5.3
230 **/
231 QColor color(QPalette::ColorGroup group, QPalette::ColorRole role) const;
232 /**
233 * Used to get additional colors that are not in QPalette.
234 * @param group The color group
235 * @param role The color role
236 * @return The color if provided for combination of group and role, otherwise invalid QColor.
237 * @since 5.3
238 **/
239 QColor color(ColorGroup group, ColorRole role) const;
240
241 /**
242 * Whether the DecoratedWindow has an application menu
243 * @since 5.9
244 */
245 bool hasApplicationMenu() const;
246 /**
247 * Returns the DBus service name of the application menu. If the window has no application
248 * menu associated with it, an empty string will be returned.
249 *
250 * @since 6.3.2
251 */
253 /**
254 * Returns the DBus object path of the application menu. If the window has no application
255 * menu associated with it, an empty string will be returned.
256 *
257 * @since 6.3.2
258 */
260 /**
261 * Whether the application menu for this DecoratedWindow is currently shown to the user
262 * The Decoration can use this information to highlight the respective button.
263 * @since 5.9
264 */
265 bool isApplicationMenuActive() const;
266
267 /**
268 * Request the application menu to be shown to the user
269 * @param actionId The DBus menu ID of the action that should be highlighted, 0 for none.
270 */
271 void showApplicationMenu(int actionId);
272
273 /**
274 * Returns the current scale this decorated window is targeting
275 * @since 6.3
276 */
277 qreal scale() const;
278 /**
279 * Returns the next scale this decorated window is going to target.
280 */
281 qreal nextScale() const;
282
284 void activeChanged(bool);
285 void captionChanged(QString);
286 void onAllDesktopsChanged(bool);
287 void shadedChanged(bool);
288 void iconChanged(QIcon);
289 void maximizedChanged(bool);
290 void maximizedHorizontallyChanged(bool);
291 void maximizedVerticallyChanged(bool);
292 void keepAboveChanged(bool);
293 void keepBelowChanged(bool);
294
295 void closeableChanged(bool);
296 void maximizeableChanged(bool);
297 void minimizeableChanged(bool);
298 void providesContextHelpChanged(bool);
299 void shadeableChanged(bool);
300 void moveableChanged(bool);
301 void resizeableChanged(bool);
302
303 void widthChanged(qreal);
304 void heightChanged(qreal);
305 void sizeChanged(const QSizeF &size);
306 void paletteChanged(const QPalette &palette);
307 void adjacentScreenEdgesChanged(Qt::Edges edges);
308
309 void hasApplicationMenuChanged(bool);
310 void applicationMenuActiveChanged(bool);
311 void scaleChanged();
312 void nextScaleChanged();
313 void applicationMenuChanged();
314
315private:
316 friend class Decoration;
317 DecoratedWindow(Decoration *parent, DecorationBridge *bridge);
318 const std::unique_ptr<DecoratedWindowPrivate> d;
319};
320
321} // namespace
QString applicationMenuServiceName
Returns the DBus service name of the application menu.
bool onAllDesktops
Whether the DecoratedWindow is on all desktops or on just one.
bool maximizedHorizontally
Whether the DecoratedWindow is maximized horizontally.
bool minimizeable
Whether the DecoratedWindow can be minimized.
bool isApplicationMenuActive() const
Whether the application menu for this DecoratedWindow is currently shown to the user The Decoration c...
bool modal
Whether the DecoratedWindow is a modal dialog.
bool maximizeable
Whether the DecoratedWindow can be maximized.
QIcon icon
The icon of the DecoratedWindow.
bool shaded
Whether the DecoratedWindow is shaded.
bool maximized
Whether the DecoratedWindow is maximized.
bool hasApplicationMenu
Whether the DecoratedWindow has an application menu.
void showApplicationMenu(int actionId)
Request the application menu to be shown to the user.
QColor color(QPalette::ColorGroup group, QPalette::ColorRole role) const
Used to get colors in QPalette.
Qt::Edges adjacentScreenEdges
The Edges which are adjacent to a screen edge.
QString caption
The caption of the DecoratedWindow.
bool applicationMenuActive
Whether the application menu for this DecoratedWindow is currently shown to the user The Decoration c...
qreal nextScale
The next scale this decorated window is going to target.
KDecoration3::Decoration * decoration
The Decoration of this DecoratedWindow.
qreal height
The height of the DecoratedWindow.
QPalette palette
The palette this DecoratedWindow uses.
qreal width
The width of the DecoratedWindow.
bool shadeable
Whether the DecoratedWindow can be shaded.
bool providesContextHelp
Whether the DecoratedWindow provides context help.
bool keepAbove
Whether the DecoratedWindow is set to be kept above other DecoratedWindows.
bool active
Whether the DecoratedWindow is active (has focus) or is inactive.
bool moveable
Whether the DecoratedWindow can be moved.
bool maximizedVertically
Whether the DecoratedWindow is maximized vertically.
QString applicationMenuObjectPath
Returns the DBus object path of the application menu.
qreal scale
The current scale this decorated window is targeting.
bool closeable
Whether the DecoratedWindow can be closed.
QSizeF size
The size of the DecoratedWindow.
bool resizeable
Whether the DecoratedWindow can be resized.
bool keepBelow
Whether the DecoratedWindow is set to be kept below other DecoratedWindows.
Base class for the Decoration.
Definition decoration.h:83
Framework for creating window decorations.
ColorGroup
Color groups are used for DecoratedWindow::color().
ColorRole
Color roles are used for DecoratedWindow::color().
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 28 2025 12:01:53 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.