KWin
Loading...
Searching...
No Matches
fakedecoration_with_shadows.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#include <QPainter>
11
12#include <KDecoration2/Decoration>
13#include <KPluginFactory>
14
15class FakeDecoWithShadows : public KDecoration2::Decoration
16{
17 Q_OBJECT
18
19public:
20 explicit FakeDecoWithShadows(QObject *parent = nullptr, const QVariantList &args = QVariantList())
21 : Decoration(parent, args)
22 {
23 }
25 {
26 }
27
28 void paint(QPainter *painter, const QRect &repaintRegion) override
29 {
30 }
31
32public Q_SLOTS:
33 bool init() override
34 {
35 const int shadowSize = 128;
36 const int offsetTop = 64;
37 const int offsetLeft = 48;
38 const QRect shadowRect(0, 0, 4 * shadowSize + 1, 4 * shadowSize + 1);
39
40 QImage shadowTexture(shadowRect.size(), QImage::Format_ARGB32_Premultiplied);
41 shadowTexture.fill(Qt::transparent);
42
43 const QMargins padding(
44 shadowSize - offsetLeft,
45 shadowSize - offsetTop,
46 shadowSize + offsetLeft,
47 shadowSize + offsetTop);
48
49 auto decoShadow = std::make_shared<KDecoration2::DecorationShadow>();
50 decoShadow->setPadding(padding);
51 decoShadow->setInnerShadowRect(QRect(shadowRect.center(), QSize(1, 1)));
52 decoShadow->setShadow(shadowTexture);
53
54 setShadow(decoShadow);
55 return true;
56 }
57};
58
60 FakeDecoWithShadowsFactory,
61 "fakedecoration_with_shadows.json",
62 registerPlugin<FakeDecoWithShadows>();)
63
64#include "fakedecoration_with_shadows.moc"
void paint(QPainter *painter, const QRect &repaintRegion) override
FakeDecoWithShadows(QObject *parent=nullptr, const QVariantList &args=QVariantList())
K_PLUGIN_FACTORY_WITH_JSON(KCMKWinDecorationFactory, "kcm_kwindecoration.json", registerPlugin< KCMKWinDecoration >();registerPlugin< KWinDecorationData >();) namespace
Definition kcm.cpp:29