KWin
Loading...
Searching...
No Matches
previewbutton.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5*/
6#pragma once
7
8#include <KDecoration2/DecorationButton>
9#include <QColor>
10#include <QPointer>
11#include <QQuickPaintedItem>
12
13namespace KDecoration2
14{
15class Decoration;
16
17namespace Preview
18{
19class PreviewBridge;
20class Settings;
21
22class PreviewButtonItem : public QQuickPaintedItem
23{
24 Q_OBJECT
26 Q_PROPERTY(KDecoration2::Preview::Settings *settings READ settings WRITE setSettings NOTIFY settingsChanged)
27 Q_PROPERTY(int type READ typeAsInt WRITE setType NOTIFY typeChanged)
28 Q_PROPERTY(QColor color READ color WRITE setColor)
29
30public:
31 explicit PreviewButtonItem(QQuickItem *parent = nullptr);
32 ~PreviewButtonItem() override;
33 void paint(QPainter *painter) override;
34
35 PreviewBridge *bridge() const;
37
38 Settings *settings() const;
40
41 KDecoration2::DecorationButtonType type() const;
42 int typeAsInt() const;
43 void setType(KDecoration2::DecorationButtonType type);
44 void setType(int type);
45
46 const QColor &color() const
47 {
48 return m_color;
49 }
50 void setColor(const QColor &color);
51
52Q_SIGNALS:
56
57protected:
58 void componentComplete() override;
59
60private:
61 void createButton();
62 void syncGeometry();
63 QColor m_color;
64 QPointer<KDecoration2::Preview::PreviewBridge> m_bridge;
65 QPointer<KDecoration2::Preview::Settings> m_settings;
66 KDecoration2::Decoration *m_decoration = nullptr;
67 KDecoration2::DecorationButton *m_button = nullptr;
68 KDecoration2::DecorationButtonType m_type = KDecoration2::DecorationButtonType::Custom;
69};
70
71} // Preview
72} // KDecoration2
KDecoration2::Preview::Settings * settings
void setBridge(PreviewBridge *bridge)
void paint(QPainter *painter) override
void setType(KDecoration2::DecorationButtonType type)
KDecoration2::Preview::PreviewBridge * bridge
#define explicit