40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
#include "connectionconfiguration.h"
|
|
#include "ui_connectionconfiguration.h"
|
|
|
|
ConnectionConfiguration::ConnectionConfiguration(QSettings *settings, ShimLCController *ctrl, QWidget *parent)
|
|
: QDialog(parent), settings(settings), ctrl(ctrl)
|
|
, ui(new Ui::ConnectionConfiguration)
|
|
{
|
|
ui->setupUi(this);
|
|
ui->addrEntry->setText(settings->value("connection/addr", "localhost").toString());
|
|
ui->portEntry->setValue(settings->value("connection/port", 5001).toInt());
|
|
|
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ConnectionConfiguration::apply);
|
|
}
|
|
|
|
ConnectionConfiguration::~ConnectionConfiguration()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void ConnectionConfiguration::apply()
|
|
{
|
|
settings->setValue("connection/addr", ui->addrEntry->text());
|
|
settings->setValue("connection/port", ui->portEntry->value());
|
|
ctrl->reconnect(settings);
|
|
if(settings->value("connection/showInfo").toBool() == 0)
|
|
switch( QMessageBox::information(
|
|
this,
|
|
tr("QtChroma"),
|
|
tr("Connection settings changed!\r\nWill try to reconnect with new settings.\r\nShow this message again?"),
|
|
|
|
QMessageBox::Yes |
|
|
QMessageBox::No,
|
|
|
|
QMessageBox::Yes ) )
|
|
{
|
|
case QMessageBox::No:
|
|
settings->setValue("connection/showInfo", true);
|
|
break;
|
|
}
|
|
}
|