2018-11-10 18:13:59 +08:00
|
|
|
#include "setdialog.h"
|
|
|
|
#include "ui_setdialog.h"
|
|
|
|
#include "defs.h"
|
2018-12-15 11:26:49 +08:00
|
|
|
#include "text.h"
|
2018-11-10 18:13:59 +08:00
|
|
|
#include "host/host.h"
|
|
|
|
#include <QSettings>
|
|
|
|
|
|
|
|
SetDialog::SetDialog(QWidget* parent) :
|
|
|
|
QDialog(parent, Qt::WindowCloseButtonHint),
|
|
|
|
ui(new Ui::SetDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
QFormLayout* layout = findChild<QFormLayout*>("layout");
|
|
|
|
|
2018-12-13 16:17:28 +08:00
|
|
|
for (auto[spinBox, value, label] : std::initializer_list<std::tuple<QSpinBox*&, int, const char*>>{
|
|
|
|
{ flushDelay, TextThread::flushDelay, FLUSH_DELAY },
|
|
|
|
{ maxBufferSize, TextThread::maxBufferSize, MAX_BUFFER_SIZE },
|
|
|
|
{ defaultCodepage, TextThread::defaultCodepage, DEFAULT_CODEPAGE }
|
2018-11-28 04:54:18 +08:00
|
|
|
})
|
2018-11-10 18:13:59 +08:00
|
|
|
{
|
2018-11-28 04:54:18 +08:00
|
|
|
spinBox = new QSpinBox(this);
|
|
|
|
spinBox->setMaximum(INT_MAX);
|
|
|
|
spinBox->setValue(value);
|
|
|
|
layout->insertRow(0, label, spinBox);
|
|
|
|
}
|
2018-11-10 18:13:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SetDialog::~SetDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDialog::on_buttonBox_accepted()
|
|
|
|
{
|
|
|
|
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-28 04:54:18 +08:00
|
|
|
}
|