File indexing completed on 2024-05-05 05:29:53
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 #pragma once 0007 0008 #include "decoration.h" 0009 #include "decorationdefines.h" 0010 #include <kdecoration2/kdecoration2_export.h> 0011 0012 #include <QFont> 0013 #include <QIcon> 0014 #include <QObject> 0015 #include <QPalette> 0016 #include <QPointer> 0017 #include <QtGui/qwindowdefs.h> 0018 0019 #include <memory> 0020 0021 namespace KDecoration2 0022 { 0023 class DecorationBridge; 0024 class DecoratedClientPrivate; 0025 0026 /** 0027 * @brief The Client which gets decorated. 0028 * 0029 * The DecoratedClient provides access to all the properties relevant for decorating the Client. 0030 * Each DecoratedClient is bound to one Decoration and each Decoration is bound to this one 0031 * DecoratedClient. 0032 * 0033 * The DecoratedClient only exports properties, it does not provide any means to change the state. 0034 * To change state one needs to call the methods on Decoration. This is as the backend might 0035 * disallow state changes. Therefore any changes should be bound to the change signals of the 0036 * DecoratedClient and not be bound to state changes of input elements (such as a button). 0037 */ 0038 class KDECORATIONS2_EXPORT DecoratedClient : public QObject 0039 { 0040 Q_OBJECT 0041 /** 0042 * The Decoration of this DecoratedClient 0043 **/ 0044 Q_PROPERTY(KDecoration2::Decoration *decoration READ decoration CONSTANT) 0045 /** 0046 * Whether the DecoratedClient is active (has focus) or is inactive. 0047 **/ 0048 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) 0049 /** 0050 * The caption of the DecoratedClient. 0051 **/ 0052 Q_PROPERTY(QString caption READ caption NOTIFY captionChanged) 0053 /** 0054 * Whether the DecoratedClient is on all desktops or on just one. 0055 **/ 0056 Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops NOTIFY onAllDesktopsChanged) 0057 /** 0058 * Whether the DecoratedClient is shaded. Shaded means that the actual content is 0059 * not visible, only the Decoration is visible. 0060 **/ 0061 Q_PROPERTY(bool shaded READ isShaded NOTIFY shadedChanged) 0062 /** 0063 * The icon of the DecoratedClient. This can be used as the icon for the window menu button. 0064 **/ 0065 Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) 0066 /** 0067 * Whether the DecoratedClient is maximized. A DecoratedClient is maximized if it is both 0068 * maximizedHorizontally and maximizedVertically. The Decoration of a maximized DecoratedClient 0069 * should only consist of the title bar area. 0070 **/ 0071 Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged) 0072 /** 0073 * Whether the DecoratedClient is maximized horizontally. A horizontally maximized DecoratedClient 0074 * uses the maximal possible width. 0075 **/ 0076 Q_PROPERTY(bool maximizedHorizontally READ isMaximizedHorizontally NOTIFY maximizedHorizontallyChanged) 0077 /** 0078 * Whether the DecoratedClient is maximized vertically. A vertically maximized DecoratedClient 0079 * uses the maximal possible height. 0080 **/ 0081 Q_PROPERTY(bool maximizedVertically READ isMaximizedVertically NOTIFY maximizedVerticallyChanged) 0082 /** 0083 * Whether the DecoratedClient is set to be kept above other DecoratedClients. There can be multiple 0084 * DecoratedClients which are set to be kept above. 0085 **/ 0086 Q_PROPERTY(bool keepAbove READ isKeepAbove NOTIFY keepAboveChanged) 0087 /** 0088 * Whether the DecoratedClient is set to be kept below other DecoratedClients. There can be multiple 0089 * DecoratedClients which are set to be kept below. 0090 **/ 0091 Q_PROPERTY(bool keepBelow READ isKeepBelow NOTIFY keepBelowChanged) 0092 0093 /** 0094 * Whether the DecoratedClient can be closed. If this property is @c false a DecorationButton 0095 * for closing the DecoratedClient should be disabled. 0096 **/ 0097 Q_PROPERTY(bool closeable READ isCloseable NOTIFY closeableChanged) 0098 /** 0099 * Whether the DecoratedClient can be maximized. If this property is @c false a DecorationButton 0100 * for maximizing the DecoratedClient should be disabled. 0101 **/ 0102 Q_PROPERTY(bool maximizeable READ isMaximizeable NOTIFY maximizeableChanged) 0103 /** 0104 * Whether the DecoratedClient can be minimized. If this property is @c false a DecorationButton 0105 * for minimizing the DecoratedClient should be disabled. 0106 **/ 0107 Q_PROPERTY(bool minimizeable READ isMinimizeable NOTIFY minimizeableChanged) 0108 /** 0109 * Whether the DecoratedClient provides context help. 0110 * The Decoration should only show a context help button if this property is @c true. 0111 **/ 0112 Q_PROPERTY(bool providesContextHelp READ providesContextHelp NOTIFY providesContextHelpChanged) 0113 /** 0114 * Whether the DecoratedClient is a modal dialog. 0115 **/ 0116 Q_PROPERTY(bool modal READ isModal CONSTANT) 0117 /** 0118 * Whether the DecoratedClient can be shaded. If this property is @c false a DecorationButton 0119 * for shading the DecoratedClient should be disabled. 0120 **/ 0121 Q_PROPERTY(bool shadeable READ isShadeable NOTIFY shadeableChanged) 0122 /** 0123 * Whether the DecoratedClient can be moved. 0124 **/ 0125 Q_PROPERTY(bool moveable READ isMoveable NOTIFY moveableChanged) 0126 /** 0127 * Whether the DecoratedClient can be resized. 0128 **/ 0129 Q_PROPERTY(bool resizeable READ isResizeable NOTIFY resizeableChanged) 0130 0131 /** 0132 * The width of the DecoratedClient. 0133 **/ 0134 Q_PROPERTY(int width READ width NOTIFY widthChanged) 0135 /** 0136 * The height of the DecoratedClient. 0137 **/ 0138 Q_PROPERTY(int height READ height NOTIFY heightChanged) 0139 /** 0140 * The size of the DecoratedClient. 0141 **/ 0142 Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) 0143 /** 0144 * The palette this DecoratedClient uses. The palette might be different for each 0145 * DecoratedClient and the Decoration should honor the palette. 0146 **/ 0147 Q_PROPERTY(QPalette palette READ palette NOTIFY paletteChanged) 0148 /** 0149 * The Edges which are adjacent to a screen edge. E.g. for a maximized DecoratedClient this 0150 * will include all Edges. The Decoration can use this information to hide borders. 0151 **/ 0152 Q_PROPERTY(Qt::Edges adjacentScreenEdges READ adjacentScreenEdges NOTIFY adjacentScreenEdgesChanged) 0153 /** 0154 * Whether the DecoratedClient has an application menu 0155 * @since 5.9 0156 */ 0157 Q_PROPERTY(bool hasApplicationMenu READ hasApplicationMenu NOTIFY hasApplicationMenuChanged) 0158 /** 0159 * Whether the application menu for this DecoratedClient is currently shown to the user 0160 * The Decoration can use this information to highlight the respective button. 0161 * @since 5.9 0162 */ 0163 Q_PROPERTY(bool applicationMenuActive READ isApplicationMenuActive NOTIFY applicationMenuActiveChanged) 0164 0165 // TODO: properties for windowId and decorationId? 0166 0167 public: 0168 DecoratedClient() = delete; 0169 ~DecoratedClient() override; 0170 bool isActive() const; 0171 QString caption() const; 0172 bool isOnAllDesktops() const; 0173 bool isShaded() const; 0174 QIcon icon() const; 0175 bool isMaximized() const; 0176 bool isMaximizedHorizontally() const; 0177 bool isMaximizedVertically() const; 0178 bool isKeepAbove() const; 0179 bool isKeepBelow() const; 0180 0181 bool isCloseable() const; 0182 bool isMaximizeable() const; 0183 bool isMinimizeable() const; 0184 bool providesContextHelp() const; 0185 bool isModal() const; 0186 bool isShadeable() const; 0187 bool isMoveable() const; 0188 bool isResizeable() const; 0189 0190 Qt::Edges adjacentScreenEdges() const; 0191 0192 WId windowId() const; 0193 WId decorationId() const; 0194 0195 QString windowClass() const; 0196 0197 int width() const; 0198 int height() const; 0199 QSize size() const; 0200 0201 Decoration *decoration() const; 0202 QPalette palette() const; 0203 /** 0204 * Used to get colors in QPalette. 0205 * @param group The color group 0206 * @param role The color role 0207 * @return palette().color(group, role) 0208 * @since 5.3 0209 **/ 0210 QColor color(QPalette::ColorGroup group, QPalette::ColorRole role) const; 0211 /** 0212 * Used to get additional colors that are not in QPalette. 0213 * @param group The color group 0214 * @param role The color role 0215 * @return The color if provided for combination of group and role, otherwise invalid QColor. 0216 * @since 5.3 0217 **/ 0218 QColor color(ColorGroup group, ColorRole role) const; 0219 0220 /** 0221 * Whether the DecoratedClient has an application menu 0222 * @since 5.9 0223 */ 0224 bool hasApplicationMenu() const; 0225 /** 0226 * Whether the application menu for this DecoratedClient is currently shown to the user 0227 * The Decoration can use this information to highlight the respective button. 0228 * @since 5.9 0229 */ 0230 bool isApplicationMenuActive() const; 0231 0232 /** 0233 * Request the application menu to be shown to the user 0234 * @param actionId The DBus menu ID of the action that should be highlighted, 0 for none. 0235 */ 0236 void showApplicationMenu(int actionId); 0237 0238 Q_SIGNALS: 0239 void activeChanged(bool); 0240 void captionChanged(QString); 0241 void onAllDesktopsChanged(bool); 0242 void shadedChanged(bool); 0243 void iconChanged(QIcon); 0244 void maximizedChanged(bool); 0245 void maximizedHorizontallyChanged(bool); 0246 void maximizedVerticallyChanged(bool); 0247 void keepAboveChanged(bool); 0248 void keepBelowChanged(bool); 0249 0250 void closeableChanged(bool); 0251 void maximizeableChanged(bool); 0252 void minimizeableChanged(bool); 0253 void providesContextHelpChanged(bool); 0254 void shadeableChanged(bool); 0255 void moveableChanged(bool); 0256 void resizeableChanged(bool); 0257 0258 void widthChanged(int); 0259 void heightChanged(int); 0260 void sizeChanged(const QSize &size); 0261 void paletteChanged(const QPalette &palette); 0262 void adjacentScreenEdgesChanged(Qt::Edges edges); 0263 0264 void hasApplicationMenuChanged(bool); 0265 void applicationMenuActiveChanged(bool); 0266 0267 private: 0268 friend class Decoration; 0269 DecoratedClient(Decoration *parent, DecorationBridge *bridge); 0270 const std::unique_ptr<DecoratedClientPrivate> d; 0271 }; 0272 0273 } // namespace