@@ -11,15 +11,19 @@ bool MacroActionSource::_registered = MacroActionFactory::Register(
11
11
{MacroActionSource::Create, MacroActionSourceEdit::Create,
12
12
" AdvSceneSwitcher.action.source" });
13
13
14
- const static std::map<SourceAction, std::string> actionTypes = {
15
- {SourceAction::ENABLE, " AdvSceneSwitcher.action.source.type.enable" },
16
- {SourceAction::DISABLE, " AdvSceneSwitcher.action.source.type.disable" },
17
- {SourceAction::SETTINGS,
14
+ const static std::map<MacroActionSource::Action, std::string> actionTypes = {
15
+ {MacroActionSource::Action::ENABLE,
16
+ " AdvSceneSwitcher.action.source.type.enable" },
17
+ {MacroActionSource::Action::DISABLE,
18
+ " AdvSceneSwitcher.action.source.type.disable" },
19
+ {MacroActionSource::Action::SETTINGS,
18
20
" AdvSceneSwitcher.action.source.type.settings" },
19
- {SourceAction ::REFRESH_SETTINGS,
21
+ {MacroActionSource::Action ::REFRESH_SETTINGS,
20
22
" AdvSceneSwitcher.action.source.type.refreshSettings" },
21
- {SourceAction ::SETTINGS_BUTTON,
23
+ {MacroActionSource::Action ::SETTINGS_BUTTON,
22
24
" AdvSceneSwitcher.action.source.type.pressSettingsButton" },
25
+ {MacroActionSource::Action::INTERACT,
26
+ " AdvSceneSwitcher.action.source.type.interact" },
23
27
};
24
28
25
29
static std::vector<SourceSettingButton> getSourceButtons (OBSWeakSource source)
@@ -78,20 +82,22 @@ bool MacroActionSource::PerformAction()
78
82
{
79
83
auto s = obs_weak_source_get_source (_source);
80
84
switch (_action) {
81
- case SourceAction ::ENABLE:
85
+ case Action ::ENABLE:
82
86
obs_source_set_enabled (s, true );
83
87
break ;
84
- case SourceAction ::DISABLE:
88
+ case Action ::DISABLE:
85
89
obs_source_set_enabled (s, false );
86
90
break ;
87
- case SourceAction ::SETTINGS:
91
+ case Action ::SETTINGS:
88
92
setSourceSettings (s, _settings);
89
93
break ;
90
- case SourceAction ::REFRESH_SETTINGS:
94
+ case Action ::REFRESH_SETTINGS:
91
95
refreshSourceSettings (s);
92
96
break ;
93
- case SourceAction ::SETTINGS_BUTTON:
97
+ case Action ::SETTINGS_BUTTON:
94
98
pressSourceButton (_button, s);
99
+ case Action::INTERACT:
100
+ _interaction.SendToSource (s);
95
101
break ;
96
102
default :
97
103
break ;
@@ -119,6 +125,7 @@ bool MacroActionSource::Save(obs_data_t *obj)
119
125
obs_data_set_int (obj, " action" , static_cast <int >(_action));
120
126
obs_data_set_string (obj, " settings" , _settings.c_str ());
121
127
_button.Save (obj);
128
+ _interaction.Save (obj);
122
129
return true ;
123
130
}
124
131
@@ -127,9 +134,11 @@ bool MacroActionSource::Load(obs_data_t *obj)
127
134
MacroAction::Load (obj);
128
135
const char *sourceName = obs_data_get_string (obj, " source" );
129
136
_source = GetWeakSourceByName (sourceName);
130
- _action = static_cast <SourceAction>(obs_data_get_int (obj, " action" ));
137
+ _action = static_cast <MacroActionSource::Action>(
138
+ obs_data_get_int (obj, " action" ));
131
139
_settings = obs_data_get_string (obj, " settings" );
132
140
_button.Load (obj);
141
+ _interaction.Load (obj);
133
142
return true ;
134
143
}
135
144
@@ -145,7 +154,7 @@ static inline void populateActionSelection(QComboBox *list)
145
154
{
146
155
for (auto &[actionType, name] : actionTypes) {
147
156
list->addItem (obs_module_text (name.c_str ()));
148
- if (actionType == SourceAction ::REFRESH_SETTINGS) {
157
+ if (actionType == MacroActionSource::Action ::REFRESH_SETTINGS) {
149
158
list->setItemData (
150
159
list->count () - 1 ,
151
160
obs_module_text (
@@ -174,17 +183,17 @@ static inline void populateSourceButtonSelection(QComboBox *list,
174
183
175
184
MacroActionSourceEdit::MacroActionSourceEdit (
176
185
QWidget *parent, std::shared_ptr<MacroActionSource> entryData)
177
- : QWidget(parent)
186
+ : QWidget(parent),
187
+ _sources(new QComboBox),
188
+ _actions(new QComboBox),
189
+ _settingsButtons(new QComboBox),
190
+ _getSettings(new QPushButton(obs_module_text(
191
+ " AdvSceneSwitcher.action.source.getSettings" ))),
192
+ _settings(new ResizingPlainTextEdit(this )),
193
+ _warning(new QLabel(
194
+ obs_module_text (" AdvSceneSwitcher.action.source.warning" ))),
195
+ _interaction(new SourceInteractionWidget())
178
196
{
179
- _sources = new QComboBox ();
180
- _actions = new QComboBox ();
181
- _settingsButtons = new QComboBox ();
182
- _getSettings = new QPushButton (
183
- obs_module_text (" AdvSceneSwitcher.action.source.getSettings" ));
184
- _settings = new ResizingPlainTextEdit (this );
185
- _warning = new QLabel (
186
- obs_module_text (" AdvSceneSwitcher.action.source.warning" ));
187
-
188
197
populateActionSelection (_actions);
189
198
populateSourceSelection (_sources);
190
199
@@ -198,6 +207,13 @@ MacroActionSourceEdit::MacroActionSourceEdit(
198
207
SLOT (GetSettingsClicked ()));
199
208
QWidget::connect (_settings, SIGNAL (textChanged ()), this ,
200
209
SLOT (SettingsChanged ()));
210
+ QWidget::connect (
211
+ _interaction,
212
+ SIGNAL (SettingsChanged (SourceInteractionInstance *)), this ,
213
+ SLOT (InteractionSettingsChanged (SourceInteractionInstance *)));
214
+ QWidget::connect (_interaction,
215
+ SIGNAL (TypeChanged (SourceInteraction::Type)), this ,
216
+ SLOT (InteractionTypeChanged (SourceInteraction::Type)));
201
217
202
218
QVBoxLayout *mainLayout = new QVBoxLayout;
203
219
QHBoxLayout *entryLayout = new QHBoxLayout;
@@ -217,6 +233,7 @@ MacroActionSourceEdit::MacroActionSourceEdit(
217
233
buttonLayout->addWidget (_getSettings);
218
234
buttonLayout->addStretch ();
219
235
mainLayout->addLayout (buttonLayout);
236
+ mainLayout->addWidget (_interaction);
220
237
setLayout (mainLayout);
221
238
222
239
_entryData = entryData;
@@ -238,6 +255,7 @@ void MacroActionSourceEdit::UpdateEntryData()
238
255
_settings->setPlainText (QString::fromStdString (_entryData->_settings ));
239
256
_settingsButtons->setCurrentText (
240
257
QString::fromStdString (_entryData->_button .ToString ()));
258
+ _interaction->SetSourceInteractionSelection (_entryData->_interaction );
241
259
SetWidgetVisibility ();
242
260
243
261
adjustSize ();
@@ -266,7 +284,7 @@ void MacroActionSourceEdit::ActionChanged(int value)
266
284
}
267
285
268
286
std::lock_guard<std::mutex> lock (switcher->m );
269
- _entryData->_action = static_cast <SourceAction >(value);
287
+ _entryData->_action = static_cast <MacroActionSource::Action >(value);
270
288
SetWidgetVisibility ();
271
289
}
272
290
@@ -299,22 +317,48 @@ void MacroActionSourceEdit::SettingsChanged()
299
317
300
318
std::lock_guard<std::mutex> lock (switcher->m );
301
319
_entryData->_settings = _settings->toPlainText ().toStdString ();
320
+ }
321
+
322
+ void MacroActionSourceEdit::InteractionTypeChanged (SourceInteraction::Type value)
323
+ {
324
+ if (_loading || !_entryData) {
325
+ return ;
326
+ }
327
+
328
+ std::lock_guard<std::mutex> lock (switcher->m );
329
+ _entryData->_interaction .SetType (value);
302
330
303
331
adjustSize ();
304
332
updateGeometry ();
305
333
}
306
334
335
+ void MacroActionSourceEdit::InteractionSettingsChanged (
336
+ SourceInteractionInstance *value)
337
+ {
338
+ if (_loading || !_entryData) {
339
+ return ;
340
+ }
341
+
342
+ std::lock_guard<std::mutex> lock (switcher->m );
343
+ _entryData->_interaction .SetSettings (value);
344
+ }
345
+
307
346
void MacroActionSourceEdit::SetWidgetVisibility ()
308
347
{
309
- const bool showSettings = _entryData->_action == SourceAction::SETTINGS;
310
- const bool showWarning = _entryData->_action == SourceAction::ENABLE ||
311
- _entryData->_action == SourceAction::DISABLE;
348
+ const bool showSettings = _entryData->_action ==
349
+ MacroActionSource::Action::SETTINGS;
350
+ const bool showWarning =
351
+ _entryData->_action == MacroActionSource::Action::ENABLE ||
352
+ _entryData->_action == MacroActionSource::Action::DISABLE;
312
353
_settings->setVisible (showSettings);
313
354
_getSettings->setVisible (showSettings);
314
355
_warning->setVisible (showWarning);
315
356
_settingsButtons->setVisible (_entryData->_action ==
316
357
SourceAction::SETTINGS_BUTTON);
358
+ _interaction->setVisible (_entryData->_action ==
359
+ MacroActionSource::Action::INTERACT);
317
360
adjustSize ();
361
+ updateGeometry ();
318
362
}
319
363
320
364
bool SourceSettingButton::Save (obs_data_t *obj) const
0 commit comments