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 
10 #include <QColor>
11 
12 namespace KDecoration2
13 {
14 DecoratedClient::DecoratedClient(Decoration *parent, DecorationBridge *bridge)
15  : QObject()
16  , d(bridge->createClient(this, parent))
17 {
18 }
19 
20 DecoratedClient::~DecoratedClient() = default;
21 
22 #define DELEGATE(type, method) \
23  type DecoratedClient::method() const \
24  { \
25  return d->method(); \
26  }
27 
28 DELEGATE(bool, isActive)
29 DELEGATE(QString, caption)
30 DELEGATE(int, desktop)
31 DELEGATE(bool, isOnAllDesktops)
32 DELEGATE(bool, isShaded)
33 DELEGATE(QIcon, icon)
34 DELEGATE(bool, isMaximized)
35 DELEGATE(bool, isMaximizedHorizontally)
36 DELEGATE(bool, isMaximizedVertically)
37 DELEGATE(bool, isKeepAbove)
38 DELEGATE(bool, isKeepBelow)
39 DELEGATE(bool, isCloseable)
40 DELEGATE(bool, isMaximizeable)
41 DELEGATE(bool, isMinimizeable)
42 DELEGATE(bool, providesContextHelp)
43 DELEGATE(bool, isModal)
44 DELEGATE(bool, isShadeable)
45 DELEGATE(bool, isMoveable)
46 DELEGATE(bool, isResizeable)
47 DELEGATE(WId, windowId)
48 DELEGATE(WId, decorationId)
49 DELEGATE(int, width)
50 DELEGATE(int, height)
51 DELEGATE(QSize, size)
52 DELEGATE(QPalette, palette)
53 DELEGATE(Qt::Edges, adjacentScreenEdges)
54 
55 #undef DELEGATE
56 
58 {
59  if (const auto *appMenuEnabledPrivate = dynamic_cast<ApplicationMenuEnabledDecoratedClientPrivate *>(d.get())) {
60  return appMenuEnabledPrivate->hasApplicationMenu();
61  }
62  return false;
63 }
64 
66 {
67  if (const auto *appMenuEnabledPrivate = dynamic_cast<ApplicationMenuEnabledDecoratedClientPrivate *>(d.get())) {
68  return appMenuEnabledPrivate->isApplicationMenuActive();
69  }
70  return false;
71 }
72 
74 {
75  return QPointer<Decoration>(d->decoration());
76 }
77 
79 {
80  return d->palette().color(group, role);
81 }
82 
84 {
85  return d->color(group, role);
86 }
87 
89 {
90  if (auto *appMenuEnabledPrivate = dynamic_cast<ApplicationMenuEnabledDecoratedClientPrivate *>(d.get())) {
91  appMenuEnabledPrivate->showApplicationMenu(actionId);
92  }
93 }
94 
95 } // namespace
void showApplicationMenu(int actionId)
Request the application menu to be shown to the user.
Base class for the Decoration.
Definition: decoration.h:59
bool isApplicationMenuActive() const
Whether the application menu for this DecoratedClient is currently shown to the user The Decoration c...
bool hasApplicationMenu
Whether the DecoratedClient has an application menu.
QColor color(QPalette::ColorGroup group, QPalette::ColorRole role) const
Used to get colors in QPalette.
ColorGroup
Color groups are used for DecoratedClient::color().
KDecoration2::Decoration decoration
The Decoration of this DecoratedClient.
ColorRole
Color roles are used for DecoratedClient::color().
typedef Edges
Framework for creating window decorations.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Oct 6 2022 04:01:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.