-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathInstantReplay_callout.cpp
More file actions
149 lines (122 loc) · 3.28 KB
/
Copy pathInstantReplay_callout.cpp
File metadata and controls
149 lines (122 loc) · 3.28 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "InstantReplay_callout.h"
#include "InstantReplay.h"
#include <obs-frontend-api.h>
#include <obs-module.h>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMessageBox>
//#include <QtWidgets/QAction>
#include <QtWidgets/qaction.h>
#include <sstream>
replayCallout *co;
bool get_enabled()
{
return co->ui->enableCheck->isChecked();
}
int get_wait()
{
return co->ui->waitSpinBox->value() * 1000;
}
int get_pause()
{
return co->ui->pauseSpinBox->value();
}
int get_replay()
{
return co->ui->replaySpinBox->value() * 1000;
}
std::string get_scene()
{
return co->ui->sceneLineEdit->text().toStdString();
}
bool get_D_mute()
{
return co->ui->muteDCheck->isChecked();
}
bool get_A_mute()
{
return co->ui->muteACheck->isChecked();
}
replayCallout::replayCallout(QWidget *parent)
: QDialog(parent),
ui(new Ui_replayCallout)
{
ui->setupUi(this);
QObject::connect(ui->closeButton->button(QDialogButtonBox::Close),
SIGNAL(clicked()), this, SLOT(hide()));
}
void replayCallout::ShowHideDialog()
{
if(!isVisible())
{
setVisible(true);
}
else
{
setVisible(false);
}
}
void replayCallout::closeEvent(QCloseEvent* event)
{
obs_frontend_save();
}
static void save_replay_callout(obs_data_t *save_data, bool saving, void *)
{
if(saving)
{
obs_data_t *obj = obs_data_create();
QString qstr;
std::string str;
obs_data_set_bool(obj, "enable", co->ui->enableCheck->isChecked());
obs_data_set_int(obj, "wait", co->ui->waitSpinBox->value());
obs_data_set_int(obj, "pause", co->ui->pauseSpinBox->value());
obs_data_set_int(obj, "replay", co->ui->replaySpinBox->value());
qstr = co->ui->sceneLineEdit->text();
str = qstr.toStdString();
obs_data_set_string(obj, "scene", str.c_str());
obs_data_set_bool(obj, "Dmute", co->ui->muteDCheck->isChecked());
obs_data_set_bool(obj, "Amute", co->ui->muteACheck->isChecked());
obs_data_set_obj(save_data, "replayCallout_data", obj);
obs_data_release(obj);
}
else
{
obs_data_t *obj = obs_data_get_obj(save_data, "replayCallout_data");
QString qstr;
if(!obj)
{
obj = obs_data_create();
}
co->ui->enableCheck->setChecked(obs_data_get_bool(obj, "enable"));
co->ui->waitSpinBox->setValue(obs_data_get_int(obj, "wait"));
co->ui->pauseSpinBox->setValue(obs_data_get_int(obj, "pause"));
co->ui->replaySpinBox->setValue(obs_data_get_int(obj, "replay"));
qstr = QString::fromLocal8Bit(obs_data_get_string(obj, "scene"));
co->ui->sceneLineEdit->setText(qstr);
co->ui->muteDCheck->setChecked(obs_data_get_bool(obj, "Dmute"));
co->ui->muteACheck->setChecked(obs_data_get_bool(obj, "Amute"));
obs_data_release(obj);
}
}
static void replay_callout_event(enum obs_frontend_event event, void *)
{
if(event == OBS_FRONTEND_EVENT_EXIT)
{
obs_frontend_save();
}
}
void replay_callout_init()
{
QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
obs_module_text("InstantReplaySettings"));
obs_frontend_push_ui_translation(obs_module_get_string);
QMainWindow *window = (QMainWindow*)obs_frontend_get_main_window();
co = new replayCallout(window);
auto cb = []()
{
co->ShowHideDialog();
};
obs_frontend_pop_ui_translation();
obs_frontend_add_event_callback(replay_callout_event, nullptr);
obs_frontend_add_save_callback(save_replay_callout, nullptr);
action->connect(action, &QAction::triggered, cb);
}