Added option to enable\disable controls autolock

This commit is contained in:
NeoTheFox 2015-03-06 15:13:12 +03:00
parent af4c29ecdd
commit 3bb5133ea9
3 changed files with 11 additions and 5 deletions

View File

@ -42,6 +42,8 @@ MainWindow::MainWindow(QWidget *parent) :
if(!firstrun) echo = settings.value("core/echo").toBool(); if(!firstrun) echo = settings.value("core/echo").toBool();
else echo = false; else echo = false;
autolock = settings.value("core/lockcontrols").toBool();
sending = false; sending = false;
paused = false; paused = false;
injectingCommand = false; injectingCommand = false;
@ -492,7 +494,7 @@ void MainWindow::on_sendBtn_clicked()
ui->sendBtn->setText("Send"); ui->sendBtn->setText("Send");
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText("Pause");
ui->pauseBtn->setDisabled("true"); ui->pauseBtn->setDisabled("true");
ui->controlBox->setChecked("true"); if(autolock) ui->controlBox->setChecked("true");
paused = false; paused = false;
} }
else if(!sending && !sdprinting) else if(!sending && !sdprinting)
@ -501,7 +503,7 @@ void MainWindow::on_sendBtn_clicked()
ui->sendBtn->setText("Stop"); ui->sendBtn->setText("Stop");
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText("Pause");
ui->pauseBtn->setEnabled("true"); ui->pauseBtn->setEnabled("true");
ui->controlBox->setChecked("false"); if(autolock) ui->controlBox->setChecked("false");
paused = false; paused = false;
} }
else if(sdprinting) else if(sdprinting)
@ -510,7 +512,7 @@ void MainWindow::on_sendBtn_clicked()
sendLine("M24"); sendLine("M24");
ui->sendBtn->setText("Send"); ui->sendBtn->setText("Send");
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText("Pause");
ui->controlBox->setChecked("true"); if(autolock) ui->controlBox->setChecked("true");
paused = false; paused = false;
} }
@ -558,13 +560,13 @@ void MainWindow::on_pauseBtn_clicked()
if(paused && !sdprinting) if(paused && !sdprinting)
{ {
paused = false; paused = false;
ui->controlBox->setChecked(false); if(autolock) ui->controlBox->setChecked(false);
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText("Pause");
} }
else if(!paused && !sdprinting) else if(!paused && !sdprinting)
{ {
paused = true; paused = true;
ui->controlBox->setChecked(true); if(autolock) ui->controlBox->setChecked(true);
ui->pauseBtn->setText("Resume"); ui->pauseBtn->setText("Resume");
} }
else if(sdprinting) else if(sdprinting)

View File

@ -59,6 +59,7 @@ private:
QSerialPort printer; QSerialPort printer;
QSerialPortInfo printerinfo; QSerialPortInfo printerinfo;
bool firstrun; bool firstrun;
bool autolock;
bool sending; bool sending;
bool paused; bool paused;
bool checkingTemperature; bool checkingTemperature;

View File

@ -22,6 +22,8 @@ SettingsWindow::SettingsWindow(QWidget *parent) :
if(settings.value("printer/bedy").toInt()) ui->bedybox->setValue(settings.value("printer/bedy").toInt()); if(settings.value("printer/bedy").toInt()) ui->bedybox->setValue(settings.value("printer/bedy").toInt());
else ui->bedybox->setValue(200); else ui->bedybox->setValue(200);
ui->lockbox->setChecked(settings.value("core/lockcontrols").toBool());
} }
SettingsWindow::~SettingsWindow() SettingsWindow::~SettingsWindow()
@ -36,4 +38,5 @@ void SettingsWindow::on_buttonBox_accepted()
settings.setValue("printer/bedy", ui->bedybox->value()); settings.setValue("printer/bedy", ui->bedybox->value());
settings.setValue("printer/bedx", ui->bedxbox->value()); settings.setValue("printer/bedx", ui->bedxbox->value());
settings.setValue("core/echo", ui->echobox->isChecked()); settings.setValue("core/echo", ui->echobox->isChecked());
settings.setValue("core/lockcontrols", ui->lockbox->isChecked());
} }