diff --git a/GUI/setdialog.cpp b/GUI/setdialog.cpp index d86ae14..f16d8e1 100644 --- a/GUI/setdialog.cpp +++ b/GUI/setdialog.cpp @@ -12,17 +12,18 @@ SetDialog::SetDialog(QWidget* parent) : QFormLayout* layout = findChild("layout"); - auto addSpinBox = [&](QString label, int value) + using Bindable = std::tuple; + for (auto[spinBox, value, label] : { + Bindable{ flushDelay, TextThread::flushDelay, FLUSH_DELAY }, + Bindable{ maxBufferSize, TextThread::maxBufferSize, MAX_BUFFER_SIZE }, + Bindable{ defaultCodepage, TextThread::defaultCodepage, DEFAULT_CODEPAGE } + }) { - auto spinbox = new QSpinBox(this); - spinbox->setMaximum(INT_MAX); - spinbox->setValue(value); - layout->insertRow(0, label, spinbox); - return spinbox; - }; - flushDelay = addSpinBox(FLUSH_DELAY, TextThread::flushDelay); - maxBufferSize = addSpinBox(MAX_BUFFER_SIZE, TextThread::maxBufferSize); - defaultCodepage = addSpinBox(DEFAULT_CODEPAGE, TextThread::defaultCodepage); + spinBox = new QSpinBox(this); + spinBox->setMaximum(INT_MAX); + spinBox->setValue(value); + layout->insertRow(0, label, spinBox); + } } SetDialog::~SetDialog() @@ -37,4 +38,4 @@ void SetDialog::on_buttonBox_accepted() settings.setValue(MAX_BUFFER_SIZE, TextThread::maxBufferSize = maxBufferSize->value()); settings.setValue(DEFAULT_CODEPAGE, TextThread::defaultCodepage = defaultCodepage->value()); settings.sync(); -} \ No newline at end of file +}