KDecoration2

decoratedclient.cpp
1 /*
2  * SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5  */
6 #include "decoratedclient.h"
7 #include "private/decoratedclientprivate.h"
8 #include "private/decorationbridge.h"
9 #include "decoration.h"
10 
11 #include <QColor>
12 
13 namespace KDecoration2
14 {
15 
16 DecoratedClient::DecoratedClient(Decoration *parent, DecorationBridge *bridge)
17  : QObject()
18  , d(std::move(bridge->createClient(this, parent)))
19 {
20 }
21 
22 DecoratedClient::~DecoratedClient() = default;
23 
24 #define DELEGATE(type, method) \
25 type DecoratedClient::method() const \
26 { \
27  return d->method(); \
28 }
29 
30 DELEGATE(bool, isActive)
31 DELEGATE(QString, caption)
32 DELEGATE(int, desktop)
33 DELEGATE(bool, isOnAllDesktops)
34 DELEGATE(bool, isShaded)
35 DELEGATE(QIcon, icon)
36 DELEGATE(bool, isMaximized)
37 DELEGATE(bool, isMaximizedHorizontally)
38 DELEGATE(bool, isMaximizedVertically)
39 DELEGATE(bool, isKeepAbove)
40 DELEGATE(bool, isKeepBelow)
41 DELEGATE(bool, isCloseable)
42 DELEGATE(bool, isMaximizeable)
43 DELEGATE(bool, isMinimizeable)
44 DELEGATE(bool, providesContextHelp)
45 DELEGATE(bool, isModal)
46 DELEGATE(bool, isShadeable)
47 DELEGATE(bool, isMoveable)
48 DELEGATE(bool, isResizeable)
49 DELEGATE(WId, windowId)
50 DELEGATE(WId, decorationId)
51 DELEGATE(int, width)
52 DELEGATE(int, height)
53 DELEGATE(QSize, size)
54 DELEGATE(QPalette, palette)
55 DELEGATE(Qt::Edges, adjacentScreenEdges)
56 
57 #undef DELEGATE
58 
60 {
61  if (const auto *appMenuEnabledPrivate = dynamic_cast<ApplicationMenuEnabledDecoratedClientPrivate *>(d.get())) {
62  return appMenuEnabledPrivate->hasApplicationMenu();
63  }
64  return false;
65 }
66 
68 {
69  if (const auto *appMenuEnabledPrivate = dynamic_cast<ApplicationMenuEnabledDecoratedClientPrivate *>(d.get())) {
70  return appMenuEnabledPrivate->isApplicationMenuActive();
71  }
72  return false;
73 }
74 
75 QPointer< Decoration > DecoratedClient::decoration() const
76 {
77  return QPointer<Decoration>(d->decoration());
78 }
79 
81 {
82  return d->palette().color(group, role);
83 }
84 
86 {
87  return d->color(group, role);
88 }
89 
91 {
92  if (auto *appMenuEnabledPrivate = dynamic_cast<ApplicationMenuEnabledDecoratedClientPrivate *>(d.get())) {
93  appMenuEnabledPrivate->showApplicationMenu(actionId);
94  }
95 }
96 
97 } // namespace
Framework for creating window decorations.
typedef Edges
void showApplicationMenu(int actionId)
Request the application menu to be shown to the user.
bool isApplicationMenuActive() const
Whether the application menu for this DecoratedClient is currently shown to the user The Decoration c...
QColor color(QPalette::ColorGroup group, QPalette::ColorRole role) const
Used to get colors in QPalette.
ColorGroup
Color groups are used for DecoratedClient::color().
ColorRole
Color roles are used for DecoratedClient::color().
bool hasApplicationMenu() const
Whether the DecoratedClient has an application menu.
Base class for the Decoration.
Definition: decoration.h:60
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 02:41:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.