forked from lirios/fluid
/
windowdecoration.h
65 lines (53 loc) · 1.46 KB
/
windowdecoration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* This file is part of Fluid.
*
* Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
*
* $BEGIN_LICENSE:MPL2$
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* $END_LICENSE$
*/
#pragma once
#include <QObject>
#include <QColor>
#include <QWindow>
#include <QQmlParserStatus>
class WindowDecoration : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged)
Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_INTERFACES(QQmlParserStatus)
public:
enum Theme {
Light,
Dark
};
Q_ENUM(Theme)
explicit WindowDecoration(QObject *parent = nullptr);
QWindow *window() const;
void setWindow(QWindow *window);
Theme theme() const;
void setTheme(Theme theme);
QColor color() const;
void setColor(const QColor &color);
void classBegin() override;
void componentComplete() override;
Q_SIGNALS:
void windowChanged();
void themeChanged();
void colorChanged();
protected:
bool eventFilter(QObject *object, QEvent *event) override;
private:
QWindow *m_window;
Theme m_theme;
QColor m_color;
private Q_SLOTS:
void updateDecorationColor();
};