| 159 | } |
| 160 | |
| 161 | MacroActionHttpEdit::MacroActionHttpEdit( |
| 162 | QWidget *parent, std::shared_ptr<MacroActionHttp> entryData) |
| 163 | : QWidget(parent), |
| 164 | _url(new VariableLineEdit(this)), |
| 165 | _methods(new QComboBox()), |
| 166 | _data(new VariableTextEdit(this)), |
| 167 | _setHeaders(new QCheckBox( |
| 168 | obs_module_text("AdvSceneSwitcher.action.http.setHeaders"))), |
| 169 | _headerListLayout(new QVBoxLayout()), |
| 170 | _headerList(new StringListEdit( |
| 171 | this, obs_module_text("AdvSceneSwitcher.action.http.headers"), |
| 172 | obs_module_text("AdvSceneSwitcher.action.http.addHeader"), |
| 173 | 170, [](const std::string &input) { return input.empty(); })), |
| 174 | _timeout(new DurationSelection(this, false)) |
| 175 | { |
| 176 | populateMethodSelection(_methods); |
| 177 | _headerList->SetMaxStringSize(4096); |
| 178 | |
| 179 | QWidget::connect(_url, SIGNAL(editingFinished()), this, |
| 180 | SLOT(URLChanged())); |
| 181 | QWidget::connect(_data, SIGNAL(textChanged()), this, |
| 182 | SLOT(DataChanged())); |
| 183 | QWidget::connect(_methods, SIGNAL(currentIndexChanged(int)), this, |
| 184 | SLOT(MethodChanged(int))); |
| 185 | QWidget::connect(_setHeaders, SIGNAL(stateChanged(int)), this, |
| 186 | SLOT(SetHeadersChanged(int))); |
| 187 | QWidget::connect(_headerList, |
| 188 | SIGNAL(StringListChanged(const StringList &)), this, |
| 189 | SLOT(HeadersChanged(const StringList &))); |
| 190 | QWidget::connect(_timeout, SIGNAL(DurationChanged(const Duration &)), |
| 191 | this, SLOT(TimeoutChanged(const Duration &))); |
| 192 | |
| 193 | std::unordered_map<std::string, QWidget *> widgetPlaceholders = { |
| 194 | {"{{url}}", _url}, |
| 195 | {"{{method}}", _methods}, |
| 196 | {"{{data}}", _data}, |
| 197 | {"{{timeout}}", _timeout}, |
| 198 | }; |
| 199 | auto *actionLayout = new QHBoxLayout; |
| 200 | PlaceWidgets( |
| 201 | obs_module_text("AdvSceneSwitcher.action.http.entry.line1"), |
| 202 | actionLayout, widgetPlaceholders); |
| 203 | auto *timeoutLayout = new QHBoxLayout; |
| 204 | PlaceWidgets( |
| 205 | obs_module_text("AdvSceneSwitcher.action.http.entry.line2"), |
| 206 | timeoutLayout, widgetPlaceholders); |
| 207 | |
| 208 | _headerListLayout->addWidget(new QLabel( |
| 209 | obs_module_text("AdvSceneSwitcher.action.http.headers"))); |
| 210 | _headerListLayout->addWidget(_headerList); |
| 211 | |
| 212 | QVBoxLayout *mainLayout = new QVBoxLayout; |
| 213 | mainLayout->addLayout(actionLayout); |
| 214 | mainLayout->addWidget(_setHeaders); |
| 215 | mainLayout->addLayout(_headerListLayout); |
| 216 | mainLayout->addWidget(_data); |
| 217 | mainLayout->addLayout(timeoutLayout); |
| 218 | setLayout(mainLayout); |
nothing calls this directly
no test coverage detected