forked from obsproject/obs-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
properties-view.hpp
135 lines (107 loc) · 3.95 KB
/
properties-view.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#pragma once
#include "vertical-scroll-area.hpp"
#include <obs.hpp>
#include <vector>
#include <memory>
class QFormLayout;
class OBSPropertiesView;
class QLabel;
typedef obs_properties_t *(*PropertiesReloadCallback)(void *obj);
typedef void (*PropertiesUpdateCallback)(void *obj,
obs_data_t *settings);
/* ------------------------------------------------------------------------- */
class WidgetInfo : public QObject {
Q_OBJECT
friend class OBSPropertiesView;
private:
OBSPropertiesView *view;
obs_property_t *property;
QWidget *widget;
void BoolChanged(const char *setting);
void IntChanged(const char *setting);
void FloatChanged(const char *setting);
void TextChanged(const char *setting);
bool PathChanged(const char *setting);
void ListChanged(const char *setting);
bool ColorChanged(const char *setting);
bool FontChanged(const char *setting);
void EditableListChanged();
void ButtonClicked();
void TogglePasswordText(bool checked);
public:
inline WidgetInfo(OBSPropertiesView *view_, obs_property_t *prop,
QWidget *widget_)
: view(view_), property(prop), widget(widget_)
{}
public slots:
void ControlChanged();
/* editable list */
void EditListAdd();
void EditListAddText();
void EditListAddFiles();
void EditListAddDir();
void EditListRemove();
void EditListEdit();
void EditListUp();
void EditListDown();
};
/* ------------------------------------------------------------------------- */
class OBSPropertiesView : public VScrollArea {
Q_OBJECT
friend class WidgetInfo;
using properties_delete_t = decltype(&obs_properties_destroy);
using properties_t =
std::unique_ptr<obs_properties_t, properties_delete_t>;
private:
QWidget *widget = nullptr;
properties_t properties;
OBSData settings;
void *obj = nullptr;
std::string type;
PropertiesReloadCallback reloadCallback;
PropertiesUpdateCallback callback = nullptr;
int minSize;
std::vector<std::unique_ptr<WidgetInfo>> children;
std::string lastFocused;
QWidget *lastWidget = nullptr;
bool deferUpdate;
QWidget *NewWidget(obs_property_t *prop, QWidget *widget,
const char *signal);
QWidget *AddCheckbox(obs_property_t *prop);
QWidget *AddText(obs_property_t *prop, QFormLayout *layout,
QLabel *&label);
void AddPath(obs_property_t *prop, QFormLayout *layout, QLabel **label);
void AddInt(obs_property_t *prop, QFormLayout *layout, QLabel **label);
void AddFloat(obs_property_t *prop, QFormLayout *layout,
QLabel**label);
QWidget *AddList(obs_property_t *prop, bool &warning);
void AddEditableList(obs_property_t *prop, QFormLayout *layout,
QLabel *&label);
QWidget *AddButton(obs_property_t *prop);
void AddColor(obs_property_t *prop, QFormLayout *layout, QLabel *&label);
void AddFont(obs_property_t *prop, QFormLayout *layout, QLabel *&label);
void AddFrameRate(obs_property_t *prop, bool &warning,
QFormLayout *layout, QLabel *&label);
void AddProperty(obs_property_t *property, QFormLayout *layout);
void resizeEvent(QResizeEvent *event) override;
void GetScrollPos(int &h, int &v);
void SetScrollPos(int h, int v);
public slots:
void ReloadProperties();
void RefreshProperties();
void SignalChanged();
signals:
void PropertiesResized();
void Changed();
public:
OBSPropertiesView(OBSData settings, void *obj,
PropertiesReloadCallback reloadCallback,
PropertiesUpdateCallback callback,
int minSize = 0);
OBSPropertiesView(OBSData settings, const char *type,
PropertiesReloadCallback reloadCallback,
int minSize = 0);
inline obs_data_t *GetSettings() const {return settings;}
inline void UpdateSettings() {callback(obj, settings);}
inline bool DeferUpdate() const {return deferUpdate;}
};