KDecoration2

decorationsettings.cpp
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#include "decorationsettings.h"
7#include "private/decorationbridge.h"
8#include "private/decorationsettingsprivate.h"
9
10#include <QFontMetrics>
11
12namespace KDecoration2
13{
14DecorationSettings::DecorationSettings(DecorationBridge *bridge, QObject *parent)
15 : QObject(parent)
16 , d(bridge->settings(this))
17{
18 auto updateUnits = [this] {
19 int gridUnit = QFontMetrics(font()).boundingRect(QLatin1Char('M')).height();
20 ;
21 if (gridUnit % 2 != 0) {
22 gridUnit++;
23 }
24 if (gridUnit != d->gridUnit()) {
25 d->setGridUnit(gridUnit);
26 Q_EMIT gridUnitChanged(gridUnit);
27 }
28 if (gridUnit != d->largeSpacing()) {
29 d->setSmallSpacing(qMax(2, (int)(gridUnit / 4))); // 1/4 of gridUnit, at least 2
30 d->setLargeSpacing(gridUnit); // msize.height
31 Q_EMIT spacingChanged();
32 }
33 };
34 updateUnits();
35 connect(this, &DecorationSettings::fontChanged, this, updateUnits);
36}
37
38DecorationSettings::~DecorationSettings() = default;
39
40bool DecorationSettings::isOnAllDesktopsAvailable() const
41{
42 return d->isOnAllDesktopsAvailable();
43}
44
45bool DecorationSettings::isAlphaChannelSupported() const
46{
47 return d->isAlphaChannelSupported();
48}
49
50bool DecorationSettings::isCloseOnDoubleClickOnMenu() const
51{
52 return d->isCloseOnDoubleClickOnMenu();
53}
54
55QList<DecorationButtonType> DecorationSettings::decorationButtonsLeft() const
56{
57 return d->decorationButtonsLeft();
58}
59
60QList<DecorationButtonType> DecorationSettings::decorationButtonsRight() const
61{
62 return d->decorationButtonsRight();
63}
64
65BorderSize DecorationSettings::borderSize() const
66{
67 return d->borderSize();
68}
69
70QFont DecorationSettings::font() const
71{
72 return d->font();
73}
74
75QFontMetricsF DecorationSettings::fontMetrics() const
76{
77 return d->fontMetrics();
78}
79
80int DecorationSettings::gridUnit() const
81{
82 return d->gridUnit();
83}
84
85int DecorationSettings::smallSpacing() const
86{
87 return d->smallSpacing();
88}
89
90int DecorationSettings::largeSpacing() const
91{
92 return d->largeSpacing();
93}
94}
95
96#include "moc_decorationsettings.cpp"
Framework for creating window decorations.
QRect boundingRect(QChar ch) const const
int height() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.