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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#pragma once
#include "libvideostitch-gui/caps/guistatecaps.hpp"
#include <QWidget>
#include <QPointer>
#include <QStateMachine>
#include <atomic>
class VS_GUI_EXPORT IFreezableWidget : public QWidget, protected GUIStateCaps {
Q_OBJECT
public:
explicit IFreezableWidget(const QString& name, QWidget* parent = nullptr);
/**
* @brief Activate the widget.
*/
virtual void activate();
/**
* @brief Deactivate the widget, freezing and hiding it.
*/
virtual void deactivate();
/**
* @brief if active, opengl is unloaded when the widget is hidden (not active).
*/
void setIsLowPerformance(bool isLowPerformance);
signals:
void reqPreviousState();
void reqChangeState(GUIStateCaps::State) override;
void reqFreeze();
void reqUnfreeze();
void glViewReady();
void unloaded();
public slots:
/**
* @brief Changes the widget's stats to the given state.
* @param s State you want to switch to.
*/
virtual void changeState(GUIStateCaps::State s) override;
/**
* @brief Set the widget's device writer.
* @param writer Device writer.
*/
// void setDeviceWriter(QtDeviceWriter* writer);
protected slots:
void disconnectFromDeviceWriter();
virtual void clearScreenshot() = 0;
protected:
virtual void updateOnState();
virtual void unload();
virtual void freeze() = 0;
virtual void unfreeze() = 0;
virtual void showGLView() = 0;
virtual void connectToDeviceWriter() = 0;
std::atomic<bool> isActive;
std::atomic<bool> isLowPerformance;
// QPointer<QtDeviceWriter> deviceWriter;
QList<QMetaObject::Connection> connections;
private slots:
void onStateUnloadedEntered();
void onStateFrozenEntered();
void onStateWaitForGLEntered();
void onStateNormalEntered();
private:
void initializeStateMachine();
QStateMachine stateMachine;
QString name;
};