-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
qt-display.hpp
46 lines (34 loc) · 1.33 KB
/
qt-display.hpp
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
#pragma once
#include <QWidget>
#include <obs.hpp>
#define GREY_COLOR_BACKGROUND 0xFF4C4C4C
class OBSQTDisplay : public QWidget {
Q_OBJECT
Q_PROPERTY(
QColor displayBackgroundColor MEMBER backgroundColor READ GetDisplayBackgroundColor WRITE SetDisplayBackgroundColor)
OBSDisplay display;
virtual void paintEvent(QPaintEvent *event) override;
virtual void moveEvent(QMoveEvent *event) override;
virtual void resizeEvent(QResizeEvent *event) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
#else
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#endif
signals:
void DisplayCreated(OBSQTDisplay *window);
void DisplayResized();
public:
OBSQTDisplay(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~OBSQTDisplay() { display = nullptr; }
virtual QPaintEngine *paintEngine() const override;
inline obs_display_t *GetDisplay() const { return display; }
uint32_t backgroundColor = GREY_COLOR_BACKGROUND;
QColor GetDisplayBackgroundColor() const;
void SetDisplayBackgroundColor(const QColor &color);
void UpdateDisplayBackgroundColor();
void CreateDisplay(bool force = false);
void DestroyDisplay() { display = nullptr; };
void OnMove();
void OnDisplayChange();
};