KDecoration2

decorationsettings.h
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 #ifndef KDECORATION2_DECORATION_SETTINGS_H
7 #define KDECORATION2_DECORATION_SETTINGS_H
8 
9 #include "decorationbutton.h"
10 #include <kdecoration2/kdecoration2_export.h>
11 
12 #include <QFontMetricsF>
13 #include <QObject>
14 
15 #include <memory>
16 
17 namespace KDecoration2
18 {
19 class DecorationBridge;
20 class DecorationSettingsPrivate;
21 
22 /**
23  * @brief Common settings for the Decoration.
24  *
25  * This class gets injected into the Decoration and provides recommendations for the
26  * Decoration. The Decoration is suggested to honor the settings, but may decide that some
27  * settings don't fit the design and ignore them.
28  *
29  * @see Decoration
30  **/
31 class KDECORATIONS2_EXPORT DecorationSettings : public QObject
32 {
33  Q_OBJECT
34  /**
35  * Whether the feature to put a DecoratedClient on all desktops is available.
36  *
37  * If this feature is not available a Decoration might decide to not show the
38  * DecorationButtonType::OnAllDesktops.
39  **/
40  Q_PROPERTY(bool onAllDesktopsAvailable READ isOnAllDesktopsAvailable NOTIFY onAllDesktopsAvailableChanged)
41  /**
42  * Whether the Decoration will be rendered with an alpha channel.
43  *
44  * If no alpha channel is available a Decoration should not use round borders.
45  **/
46  Q_PROPERTY(bool alphaChannelSupported READ isAlphaChannelSupported NOTIFY alphaChannelSupportedChanged)
47  /**
48  * Whether the Decoration should close the DecoratedClient when double clicking on the
49  * DecorationButtonType::Menu.
50  **/
51  Q_PROPERTY(bool closeOnDoubleClickOnMenu READ isCloseOnDoubleClickOnMenu NOTIFY closeOnDoubleClickOnMenuChanged)
52  /**
53  * The suggested ordering of the decoration buttons on the left.
54  **/
55  Q_PROPERTY(QVector<KDecoration2::DecorationButtonType> decorationButtonsLeft READ decorationButtonsLeft NOTIFY decorationButtonsLeftChanged)
56  /**
57  * The suggested ordering of the decoration buttons on the right.
58  **/
59  Q_PROPERTY(QVector<KDecoration2::DecorationButtonType> decorationButtonsRight READ decorationButtonsRight NOTIFY decorationButtonsRightChanged)
60  /**
61  * The suggested border size.
62  **/
63  Q_PROPERTY(KDecoration2::BorderSize borderSize READ borderSize NOTIFY borderSizeChanged)
64  /**
65  * The fundamental unit of space that should be used for sizes, expressed in pixels.
66  * Given the screen has an accurate DPI settings, it corresponds to a millimeter
67  */
68  Q_PROPERTY(int gridUnit READ gridUnit NOTIFY gridUnitChanged)
69  /**
70  * The recommended font for the Decoration's caption.
71  **/
72  Q_PROPERTY(QFont font READ font NOTIFY fontChanged)
73  /**
74  * smallSpacing is the amount of spacing that should be used around smaller UI elements,
75  * for example as spacing in Columns. Internally, this size depends on the size of
76  * the default font as rendered on the screen, so it takes user-configured font size and DPI
77  * into account.
78  */
79  Q_PROPERTY(int smallSpacing READ smallSpacing NOTIFY spacingChanged)
80 
81  /**
82  * largeSpacing is the amount of spacing that should be used inside bigger UI elements,
83  * for example between an icon and the corresponding text. Internally, this size depends on
84  * the size of the default font as rendered on the screen, so it takes user-configured font
85  * size and DPI into account.
86  */
87  Q_PROPERTY(int largeSpacing READ largeSpacing NOTIFY spacingChanged)
88 public:
89  explicit DecorationSettings(DecorationBridge *bridge, QObject *parent = nullptr);
90  ~DecorationSettings() override;
91  bool isOnAllDesktopsAvailable() const;
92  bool isAlphaChannelSupported() const;
93  bool isCloseOnDoubleClickOnMenu() const;
94  QVector<DecorationButtonType> decorationButtonsLeft() const;
95  QVector<DecorationButtonType> decorationButtonsRight() const;
96  BorderSize borderSize() const;
97 
98  QFont font() const;
99  /**
100  * The fontMetrics for the recommended font.
101  * @see font
102  **/
103  QFontMetricsF fontMetrics() const;
104 
105  int gridUnit() const;
106  int smallSpacing() const;
107  int largeSpacing() const;
108 
109 Q_SIGNALS:
110  void onAllDesktopsAvailableChanged(bool);
111  void alphaChannelSupportedChanged(bool);
112  void closeOnDoubleClickOnMenuChanged(bool);
113  void decorationButtonsLeftChanged(const QVector<KDecoration2::DecorationButtonType> &);
114  void decorationButtonsRightChanged(const QVector<KDecoration2::DecorationButtonType> &);
115  void borderSizeChanged(KDecoration2::BorderSize size);
116  void fontChanged(const QFont &font);
117  void gridUnitChanged(int);
118  void spacingChanged();
119 
120  /**
121  * This signal is emitted when the backend got reconfigured.
122  * If the plugin uses custom settings, it is recommended to re-read
123  * them after this signal got emitted.
124  **/
125  void reconfigured();
126 
127 private:
128  const std::unique_ptr<DecorationSettingsPrivate> d;
129 };
130 
131 }
132 
133 Q_DECLARE_METATYPE(KDecoration2::BorderSize)
134 
135 #endif
Framework for creating window decorations.
DecorationButtonType
The DecorationButtonType is a helper type for the DecorationButton.
Common settings for the Decoration.
BorderSize
Border sizes are a combination of visual and accessibility features.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Jun 20 2021 23:07:39 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.