MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / closeSourceDialog

Function closeSourceDialog

plugins/base/macro-action-source.cpp:132–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132static void closeSourceDialog(obs_source_t *source, bool accept,
133 const char *className)
134{
135 if (!source) {
136 return;
137 }
138
139 auto mainWindow =
140 reinterpret_cast<QMainWindow *>(obs_frontend_get_main_window());
141 if (!mainWindow) {
142 return;
143 }
144
145 for (const auto widget : mainWindow->children()) {
146 auto dialog = qobject_cast<QDialog *>(widget);
147 if (!dialog) {
148 continue;
149 }
150
151 if (dialog->metaObject()->className() != QString(className)) {
152 continue;
153 }
154
155 const char *name = obs_source_get_name(source);
156 if (!name) {
157 continue;
158 }
159
160 if (!dialog->windowTitle().contains(QString(name))) {
161 continue;
162 }
163
164 if (accept) {
165 dialog->accept();
166 return;
167 }
168
169 // dialog->reject() will ask for confirmation
170 // Try to avoid this by finding and pressing the cancel button
171 for (const auto widget : dialog->children()) {
172 auto buttons = qobject_cast<QDialogButtonBox *>(widget);
173 if (!buttons) {
174 continue;
175 }
176
177 for (auto *button : buttons->buttons()) {
178 if (buttons->buttonRole(button) ==
179 QDialogButtonBox::RejectRole) {
180 button->click();
181 break;
182 }
183 }
184 }
185 }
186}
187
188template<typename F> void QueueUITaskLambda(F &&func)
189{

Callers 1

PerformActionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected