KDecoration2

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

KDE's Doxygen guidelines are available online.