KDecoration3

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 <kdecoration3/kdecoration3_export.h>
10
11#include <QFontMetricsF>
12#include <QObject>
13
14#include <memory>
15
16namespace KDecoration3
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 KDECORATIONS3_EXPORT DecorationSettings : public QObject
31{
33 /**
34 * Whether the feature to put a DecoratedWindow 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 DecoratedWindow 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 **/
55 /**
56 * The suggested ordering of the decoration buttons on the right.
57 **/
59 /**
60 * The suggested border size.
61 **/
62 Q_PROPERTY(KDecoration3::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;
95 BorderSize borderSize() const;
96
97 QFont font() const;
98 /**
99 * The fontMetrics for the recommended font.
100 * @see font
101 **/
103
104 int gridUnit() const;
105 int smallSpacing() const;
106 int largeSpacing() const;
107
109 void onAllDesktopsAvailableChanged(bool);
110 void alphaChannelSupportedChanged(bool);
111 void closeOnDoubleClickOnMenuChanged(bool);
112 void decorationButtonsLeftChanged(const QList<KDecoration3::DecorationButtonType> &);
113 void decorationButtonsRightChanged(const QList<KDecoration3::DecorationButtonType> &);
114 void borderSizeChanged(KDecoration3::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 **/
125
126private:
127 const std::unique_ptr<DecorationSettingsPrivate> d;
128};
129
130}
131
132Q_DECLARE_METATYPE(KDecoration3::BorderSize)
int smallSpacing
smallSpacing is the amount of spacing that should be used around smaller UI elements,...
bool onAllDesktopsAvailable
Whether the feature to put a DecoratedWindow on all desktops is available.
QFont font
The recommended font for the Decoration's caption.
bool alphaChannelSupported
Whether the Decoration will be rendered with an alpha channel.
int gridUnit
The fundamental unit of space that should be used for sizes, expressed in pixels.
void reconfigured()
This signal is emitted when the backend got reconfigured.
bool closeOnDoubleClickOnMenu
Whether the Decoration should close the DecoratedWindow when double clicking on the DecorationButtonT...
int largeSpacing
largeSpacing is the amount of spacing that should be used inside bigger UI elements,...
QList< KDecoration3::DecorationButtonType > decorationButtonsRight
The suggested ordering of the decoration buttons on the right.
QList< KDecoration3::DecorationButtonType > decorationButtonsLeft
The suggested ordering of the decoration buttons on the left.
QFontMetricsF fontMetrics() const
The fontMetrics for the recommended font.
KDecoration3::BorderSize borderSize
The suggested border size.
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.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:56:48 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.