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 KDECORATIONS2_EXPORT DecoratedWindow : public QObject
39{
40 Q_OBJECT
41 /**
42 * The Decoration of this DecoratedWindow
43 **/
44 Q_PROPERTY(KDecoration3::Decoration *decoration READ decoration CONSTANT)
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(int width READ width NOTIFY widthChanged)
135 /**
136 * The height of the DecoratedWindow.
137 **/
138 Q_PROPERTY(int height READ height NOTIFY heightChanged)
139 /**
140 * The size of the DecoratedWindow.
141 **/
142 Q_PROPERTY(QSize 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
165public:
166 DecoratedWindow() = delete;
167 ~DecoratedWindow() override;
168 bool isActive() const;
169 QString caption() const;
170 bool isOnAllDesktops() const;
171 bool isShaded() const;
172 QIcon icon() const;
173 bool isMaximized() const;
174 bool isMaximizedHorizontally() const;
175 bool isMaximizedVertically() const;
176 bool isKeepAbove() const;
177 bool isKeepBelow() const;
178
179 bool isCloseable() const;
180 bool isMaximizeable() const;
181 bool isMinimizeable() const;
182 bool providesContextHelp() const;
183 bool isModal() const;
184 bool isShadeable() const;
185 bool isMoveable() const;
186 bool isResizeable() const;
187
188 Qt::Edges adjacentScreenEdges() const;
189
190 QString windowClass() const;
191
192 int width() const;
193 int height() const;
194 QSize size() const;
195
196 Decoration *decoration() const;
197 QPalette palette() const;
198 /**
199 * Used to get colors in QPalette.
200 * @param group The color group
201 * @param role The color role
202 * @return palette().color(group, role)
203 * @since 5.3
204 **/
205 QColor color(QPalette::ColorGroup group, QPalette::ColorRole role) const;
206 /**
207 * Used to get additional colors that are not in QPalette.
208 * @param group The color group
209 * @param role The color role
210 * @return The color if provided for combination of group and role, otherwise invalid QColor.
211 * @since 5.3
212 **/
213 QColor color(ColorGroup group, ColorRole role) const;
214
215 /**
216 * Whether the DecoratedWindow has an application menu
217 * @since 5.9
218 */
219 bool hasApplicationMenu() const;
220 /**
221 * Whether the application menu for this DecoratedWindow is currently shown to the user
222 * The Decoration can use this information to highlight the respective button.
223 * @since 5.9
224 */
225 bool isApplicationMenuActive() const;
226
227 /**
228 * Request the application menu to be shown to the user
229 * @param actionId The DBus menu ID of the action that should be highlighted, 0 for none.
230 */
231 void showApplicationMenu(int actionId);
232
233Q_SIGNALS:
234 void activeChanged(bool);
235 void captionChanged(QString);
236 void onAllDesktopsChanged(bool);
237 void shadedChanged(bool);
238 void iconChanged(QIcon);
239 void maximizedChanged(bool);
240 void maximizedHorizontallyChanged(bool);
241 void maximizedVerticallyChanged(bool);
242 void keepAboveChanged(bool);
243 void keepBelowChanged(bool);
244
245 void closeableChanged(bool);
246 void maximizeableChanged(bool);
247 void minimizeableChanged(bool);
248 void providesContextHelpChanged(bool);
249 void shadeableChanged(bool);
250 void moveableChanged(bool);
251 void resizeableChanged(bool);
252
253 void widthChanged(int);
254 void heightChanged(int);
255 void sizeChanged(const QSize &size);
256 void paletteChanged(const QPalette &palette);
257 void adjacentScreenEdgesChanged(Qt::Edges edges);
258
259 void hasApplicationMenuChanged(bool);
260 void applicationMenuActiveChanged(bool);
261
262private:
263 friend class Decoration;
264 DecoratedWindow(Decoration *parent, DecorationBridge *bridge);
265 const std::unique_ptr<DecoratedWindowPrivate> d;
266};
267
268} // namespace
The Client which gets decorated.
Base class for the Decoration.
Definition decoration.h:58
Framework for creating window decorations.
ColorGroup
Color groups are used for DecoratedWindow::color().
ColorRole
Color roles are used for DecoratedWindow::color().
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:02:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.