Skip to content

Commit 707234d

Browse files
committed
settings: Move apply button into the designer form
There is no need to create the apply button manually. Move it into the designer form so that all the UI elements are managed in the same place. The one exception is the OBSPropertiesView widget, but that is because it needs extra context when it is created that designer does not have. Signed-off-by: Grant Likely <[email protected]>
1 parent c761464 commit 707234d

File tree

3 files changed

+33
-25
lines changed

3 files changed

+33
-25
lines changed

src/settings.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ QString SourceNameDelegate::displayText(const QVariant &value, const QLocale &lo
6565

6666
obs_properties_t *PTZSettings::getProperties(void)
6767
{
68-
auto applycb = [](obs_properties_t *, obs_property_t *, void *data_) {
69-
auto s = static_cast<PTZSettings *>(data_);
70-
PTZDevice *ptz = ptzDeviceList.getDevice(s->ui->deviceList->currentIndex());
71-
if (ptz)
72-
ptz->set_config(s->propertiesView->GetSettings());
73-
return true;
74-
};
7568
auto cb = [](obs_properties_t *, obs_property_t *, void *data_) {
7669
auto data = static_cast<obs_data_t *>(data_);
7770
blog(LOG_INFO, "%s", obs_data_get_string(data, "debug_info"));
@@ -83,13 +76,6 @@ obs_properties_t *PTZSettings::getProperties(void)
8376
return obs_properties_create();
8477

8578
auto props = ptz->get_obs_properties();
86-
auto p = obs_properties_get(props, "interface");
87-
if (p) {
88-
auto iface = obs_property_group_content(p);
89-
if (iface)
90-
obs_properties_add_button2(iface, "iface_apply", "Apply", applycb, this);
91-
}
92-
9379
auto debug = obs_properties_create();
9480
obs_properties_add_text(debug, "debug_info", NULL, OBS_TEXT_INFO);
9581
obs_properties_add_button2(debug, "dbgdump", "Write to OBS log", cb, settings);
@@ -301,6 +287,13 @@ void PTZSettings::on_removePTZ_clicked()
301287
delete ptz;
302288
}
303289

290+
void PTZSettings::on_applyButton_clicked()
291+
{
292+
PTZDevice *ptz = ptzDeviceList.getDevice(ui->deviceList->currentIndex());
293+
if (ptz)
294+
ptz->set_config(propertiesView->GetSettings());
295+
}
296+
304297
void PTZSettings::currentChanged(const QModelIndex &current, const QModelIndex &previous)
305298
{
306299
auto ptz = ptzDeviceList.getDevice(previous);

src/settings.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ protected slots:
5757
public slots:
5858
void on_addPTZ_clicked();
5959
void on_removePTZ_clicked();
60+
void on_applyButton_clicked();
6061

6162
void currentChanged(const QModelIndex &current, const QModelIndex &previous);
6263
void settingsChanged(OBSData settings);

src/settings.ui

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,34 @@
260260
</layout>
261261
</widget>
262262
<widget class="QWidget" name="widget" native="true">
263-
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
263+
<layout class="QVBoxLayout" name="propertiesLayout" stretch="0">
264264
<property name="sizeConstraint">
265265
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
266266
</property>
267-
<item>
268-
<layout class="QHBoxLayout" name="propertiesLayout">
269-
<property name="spacing">
270-
<number>0</number>
271-
</property>
272-
<property name="sizeConstraint">
273-
<enum>QLayout::SizeConstraint::SetNoConstraint</enum>
274-
</property>
275-
</layout>
276-
</item>
267+
<item>
268+
<layout class="QHBoxLayout" name="horizontalLayout_4">
269+
<item>
270+
<spacer name="horizontalSpacer">
271+
<property name="orientation">
272+
<enum>Qt::Orientation::Horizontal</enum>
273+
</property>
274+
<property name="sizeHint" stdset="0">
275+
<size>
276+
<width>40</width>
277+
<height>20</height>
278+
</size>
279+
</property>
280+
</spacer>
281+
</item>
282+
<item>
283+
<widget class="QPushButton" name="applyButton">
284+
<property name="text">
285+
<string>Apply</string>
286+
</property>
287+
</widget>
288+
</item>
289+
</layout>
290+
</item>
277291
</layout>
278292
</widget>
279293
</widget>

0 commit comments

Comments
 (0)