From d1ab12d208006830771ba64233692668f339f57f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 3 Jan 2022 23:41:28 +0100 Subject: gui/options-dialog: reduce copy-pasting --- gui/options-dialog.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp index b4d5d3e3..d121a0bd 100644 --- a/gui/options-dialog.cpp +++ b/gui/options-dialog.cpp @@ -173,24 +173,18 @@ options_dialog::options_dialog(std::unique_ptr& tracker_dialog_, } } - if (tracker_dialog_ && tracker_dialog_->embeddable()) - { - tracker_dialog = tracker_dialog_.release(); - tracker_dialog->set_buttons_visible(false); - ui.tabWidget->addTab(tracker_dialog, tr("Tracker")); - } - if (proto_dialog_ && proto_dialog_->embeddable()) - { - proto_dialog = proto_dialog_.release(); - proto_dialog->set_buttons_visible(false); - ui.tabWidget->addTab(proto_dialog, tr("Output")); - } - if (filter_dialog_ && filter_dialog_->embeddable()) - { - filter_dialog = filter_dialog_.release(); - filter_dialog->set_buttons_visible(false); - ui.tabWidget->addTab(filter_dialog, tr("Filter")); - } + auto add_module_tab = [this] (auto& place, auto&& dlg, const QString& label) { + if (dlg && dlg->embeddable()) + { + dlg->set_buttons_visible(false); + place = dlg.release(); + ui.tabWidget->addTab(place, label); + } + }; + + add_module_tab(tracker_dialog, tracker_dialog_, tr("Tracker")); + add_module_tab(proto_dialog, proto_dialog_, tr("Output")); + add_module_tab(filter_dialog, filter_dialog_, tr("Filter")); } void options_dialog::bind_key(key_opts& kopts, QLabel* label) -- cgit v1.2.3