structured bindings are awesome!
This commit is contained in:
parent
efa8d26ada
commit
966620429e
@ -12,17 +12,18 @@ SetDialog::SetDialog(QWidget* parent) :
|
||||
|
||||
QFormLayout* layout = findChild<QFormLayout*>("layout");
|
||||
|
||||
auto addSpinBox = [&](QString label, int value)
|
||||
using Bindable = std::tuple<QSpinBox*&, int, const char*>;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user