Textractor/GUI/setdialog.cpp

39 lines
1.1 KiB
C++
Raw Normal View History

2018-11-10 05:13:59 -05:00
#include "setdialog.h"
#include "ui_setdialog.h"
#include "defs.h"
2018-12-14 22:26:49 -05:00
#include "text.h"
2018-11-10 05:13:59 -05:00
#include "host/host.h"
SetDialog::SetDialog(QWidget* parent) :
QDialog(parent, Qt::WindowCloseButtonHint),
ui(new Ui::SetDialog)
{
ui->setupUi(this);
for (auto[spinBox, value, label] : Array<std::tuple<QSpinBox*&, int, const char*>>{
2018-12-13 03:17:28 -05:00
{ flushDelay, TextThread::flushDelay, FLUSH_DELAY },
{ maxBufferSize, TextThread::maxBufferSize, MAX_BUFFER_SIZE },
{ defaultCodepage, TextThread::defaultCodepage, DEFAULT_CODEPAGE }
2018-11-27 15:54:18 -05:00
})
2018-11-10 05:13:59 -05:00
{
2018-11-27 15:54:18 -05:00
spinBox = new QSpinBox(this);
spinBox->setMaximum(INT_MAX);
spinBox->setValue(value);
ui->layout->insertRow(0, label, spinBox);
2018-11-27 15:54:18 -05:00
}
2018-12-18 12:14:54 -05:00
2018-12-18 12:55:11 -05:00
connect(ui->buttonBox, &QDialogButtonBox::accepted, [this] { edited = true; });
2018-11-10 05:13:59 -05:00
}
SetDialog::~SetDialog()
{
2018-12-18 12:14:54 -05:00
if (edited)
{
QSettings settings(CONFIG_FILE, QSettings::IniFormat);
settings.setValue(FLUSH_DELAY, TextThread::flushDelay = flushDelay->value());
settings.setValue(MAX_BUFFER_SIZE, TextThread::maxBufferSize = maxBufferSize->value());
settings.setValue(DEFAULT_CODEPAGE, TextThread::defaultCodepage = defaultCodepage->value());
settings.sync();
}
2018-11-10 05:13:59 -05:00
delete ui;
}