Auto-capitalize manual commands

This commit is contained in:
NeoTheFox 2015-03-23 16:04:41 +03:00
parent b0190ded97
commit 2fdd05cac1
3 changed files with 41 additions and 37 deletions

View File

@ -11,13 +11,13 @@ ErrorWindow::ErrorWindow(QWidget *parent, QString errorText, int errType):
switch(errType) switch(errType)
{ {
case SerialPortError: case SerialPortError:
ui->label->setText("Serial port error:"); ui->label->setText(tr("Serial port error:"));
break; break;
case OpenFileError: case OpenFileError:
ui->label->setText("File open error:"); ui->label->setText(tr("File open error:"));
break; break;
default: default:
ui->label->setText("Unknown error type:"); ui->label->setText(tr("Unknown error type:"));
break; break;
} }

View File

@ -7,6 +7,10 @@ MainWindow::MainWindow(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
//Set parents
settings.setParent(this);
gfile.setParent(this);
//Setup the UI //Setup the UI
ui->fileBox->setDisabled(true); ui->fileBox->setDisabled(true);
ui->sendBtn->setDisabled(true); ui->sendBtn->setDisabled(true);
@ -188,7 +192,7 @@ void MainWindow::open()
QString filename; QString filename;
QDir home; QDir home;
filename = QFileDialog::getOpenFileName(this, filename = QFileDialog::getOpenFileName(this,
"Open GCODE", tr("Open GCODE"),
home.home().absolutePath(), home.home().absolutePath(),
"GCODE (*.g *.gco *.gcode *.nc)"); "GCODE (*.g *.gco *.gcode *.nc)");
gfile.setFileName(filename); gfile.setFileName(filename);
@ -224,7 +228,7 @@ void MainWindow::parseFile(QString filename)
} }
else else
{ {
ErrorWindow window(this, "Can't open file", OpenFileError); ErrorWindow window(this, tr("Can't open file"), OpenFileError);
ui->filename->setText(""); ui->filename->setText("");
ui->filelines->setText(""); ui->filelines->setText("");
window.exec(); window.exec();
@ -283,7 +287,7 @@ void MainWindow::serialconnect()
//Set the flag //Set the flag
opened = false; opened = false;
//Update UI //Update UI
ui->connectBtn->setText("Connect"); ui->connectBtn->setText(tr("Connect"));
ui->sendBtn->setDisabled(true); ui->sendBtn->setDisabled(true);
ui->pauseBtn->setDisabled(true); ui->pauseBtn->setDisabled(true);
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
@ -375,9 +379,9 @@ void MainWindow::homeall()
void MainWindow::on_sendbtn_clicked() void MainWindow::on_sendbtn_clicked()
{ {
QString command = ui->sendtext->text(); QString command = ui->sendtext->text().toUpper();
emit injectCommand(command); emit injectCommand(command);
userHistory.append(command); userHistory.prepend(command);
userHistoryPos = 0; userHistoryPos = 0;
} }
@ -487,8 +491,8 @@ void MainWindow::on_sendBtn_clicked()
if(sending && !sdprinting) if(sending && !sdprinting)
{ {
sending = false; sending = false;
ui->sendBtn->setText("Send"); ui->sendBtn->setText(tr("Send"));
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText(tr("Pause"));
ui->pauseBtn->setDisabled(true); ui->pauseBtn->setDisabled(true);
if(autolock) ui->controlBox->setChecked(true); if(autolock) ui->controlBox->setChecked(true);
paused = false; paused = false;
@ -498,8 +502,8 @@ void MainWindow::on_sendBtn_clicked()
else if(!sending && !sdprinting) else if(!sending && !sdprinting)
{ {
sending=true; sending=true;
ui->sendBtn->setText("Stop"); ui->sendBtn->setText(tr("Stop"));
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText(tr("Pause"));
ui->pauseBtn->setEnabled(true); ui->pauseBtn->setEnabled(true);
if(autolock) ui->controlBox->setChecked(false); if(autolock) ui->controlBox->setChecked(false);
paused = false; paused = false;
@ -511,8 +515,8 @@ void MainWindow::on_sendBtn_clicked()
sending = false; sending = false;
emit injectCommand("M24"); emit injectCommand("M24");
emit injectCommand("M27"); emit injectCommand("M27");
ui->sendBtn->setText("Start"); ui->sendBtn->setText(tr("Start"));
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText(tr("Pause"));
ui->pauseBtn->setEnabled(true); ui->pauseBtn->setEnabled(true);
if(autolock) ui->controlBox->setChecked(true); if(autolock) ui->controlBox->setChecked(true);
paused = false; paused = false;
@ -529,14 +533,14 @@ void MainWindow::on_pauseBtn_clicked()
paused = false; paused = false;
emit pause(paused); emit pause(paused);
if(autolock) ui->controlBox->setChecked(false); if(autolock) ui->controlBox->setChecked(false);
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText(tr("Pause"));
} }
else if(!paused && !sdprinting) else if(!paused && !sdprinting)
{ {
paused = true; paused = true;
emit pause(paused); emit pause(paused);
if(autolock) ui->controlBox->setChecked(true); if(autolock) ui->controlBox->setChecked(true);
ui->pauseBtn->setText("Resume"); ui->pauseBtn->setText(tr("Resume"));
} }
else if(sdprinting) else if(sdprinting)
{ {
@ -647,7 +651,7 @@ void MainWindow::serialError(QSerialPort::SerialPortError error)
opened = false; opened = false;
//Update UI //Update UI
ui->connectBtn->setText("Connect"); ui->connectBtn->setText(tr("Connect"));
ui->sendBtn->setDisabled(true); ui->sendBtn->setDisabled(true);
ui->pauseBtn->setDisabled(true); ui->pauseBtn->setDisabled(true);
ui->controlBox->setDisabled(true); ui->controlBox->setDisabled(true);
@ -664,37 +668,37 @@ void MainWindow::serialError(QSerialPort::SerialPortError error)
switch(error) switch(error)
{ {
case QSerialPort::DeviceNotFoundError: case QSerialPort::DeviceNotFoundError:
errorMsg = "Device not found"; errorMsg = tr("Device not found");
break; break;
case QSerialPort::PermissionError: case QSerialPort::PermissionError:
errorMsg = "Insufficient permissions\nAlready opened?"; errorMsg = tr("Insufficient permissions\nAlready opened?");
break; break;
case QSerialPort::OpenError: case QSerialPort::OpenError:
errorMsg = "Cant open port\nAlready opened?"; errorMsg = tr("Cant open port\nAlready opened?");
break; break;
case QSerialPort::TimeoutError: case QSerialPort::TimeoutError:
errorMsg = "Serial connection timed out"; errorMsg = tr("Serial connection timed out");
break; break;
//These errors are the same really //These errors are the same really
case QSerialPort::WriteError: case QSerialPort::WriteError:
case QSerialPort::ReadError: case QSerialPort::ReadError:
errorMsg = "I/O Error"; errorMsg = tr("I/O Error");
break; break;
case QSerialPort::ResourceError: case QSerialPort::ResourceError:
errorMsg = "Disconnected"; errorMsg = tr("Disconnected");
break; break;
case QSerialPort::UnsupportedOperationError: case QSerialPort::UnsupportedOperationError:
errorMsg = "Operation not supported.\nUnsupported baudrate?"; errorMsg = tr("Operation not supported.\nUnsupported baudrate?");
break; break;
default: default:
errorMsg = "Unknown error\nSomething went wrong"; errorMsg = tr("Unknown error\nSomething went wrong");
break; break;
} }
@ -730,12 +734,12 @@ void MainWindow::selectSDfile(QString file)
ui->filename->setText(filename); ui->filename->setText(filename);
if(chekingSDStatus) if(chekingSDStatus)
{ {
ui->filelines->setText(bytes + QString("/0 bytes")); ui->filelines->setText(bytes + tr("/0 bytes"));
ui->progressBar->setEnabled(true); ui->progressBar->setEnabled(true);
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
} }
else ui->progressBar->setDisabled(true); else ui->progressBar->setDisabled(true);
ui->sendBtn->setText("Start"); ui->sendBtn->setText(tr("Start"));
sdBytes = bytes.toDouble(); sdBytes = bytes.toDouble();
emit flushInjectionBuffer(); emit flushInjectionBuffer();
@ -749,7 +753,7 @@ void MainWindow::updateSDStatus(SDProgress p)
ui->filelines->setText(QString::number(p.progress) ui->filelines->setText(QString::number(p.progress)
+ QString("/") + QString("/")
+ QString::number(p.total) + QString::number(p.total)
+ QString(" bytes")); + QString(tr(" bytes")));
if(p.progress != 0) ui->progressBar->setValue(((double)p.progress/p.total) * 100); if(p.progress != 0) ui->progressBar->setValue(((double)p.progress/p.total) * 100);
else ui->progressBar->setValue(0); else ui->progressBar->setValue(0);
if(p.total == p.progress) sdprinting = false; if(p.total == p.progress) sdprinting = false;
@ -838,7 +842,7 @@ void MainWindow::EEPROMSettingReceived(QString esetting)
void MainWindow::receivedError() void MainWindow::receivedError()
{ {
//This should be raised if "!!" received //This should be raised if "!!" received
ErrorWindow errorwindow(this,"Hardware failure"); ErrorWindow errorwindow(this, tr("Hardware failure"));
errorwindow.exec(); errorwindow.exec();
} }
@ -855,7 +859,7 @@ void MainWindow::updateFileProgress(FileProgress p)
//Check if file is at end //Check if file is at end
if(p.P >= p.T) if(p.P >= p.T)
{ {
ui->sendBtn->setText("Send"); ui->sendBtn->setText(tr("Send"));
ui->pauseBtn->setDisabled(true); ui->pauseBtn->setDisabled(true);
sending = false; sending = false;
paused = false; paused = false;
@ -863,7 +867,7 @@ void MainWindow::updateFileProgress(FileProgress p)
} }
else else
{ {
ui->sendBtn->setText("Stop"); ui->sendBtn->setText(tr("Stop"));
ui->pauseBtn->setEnabled(true); ui->pauseBtn->setEnabled(true);
sending = true; sending = true;
} }
@ -871,15 +875,15 @@ void MainWindow::updateFileProgress(FileProgress p)
ui->filelines->setText(QString::number(p.T) ui->filelines->setText(QString::number(p.T)
+ QString("/") + QString("/")
+ QString::number(p.P) + QString::number(p.P)
+ QString(" Lines")); + tr(" Lines"));
ui->progressBar->setValue(((float)p.P/p.T) * 100); ui->progressBar->setValue(((float)p.P/p.T) * 100);
} }
void MainWindow::baudrateSetFailed(int b) void MainWindow::baudrateSetFailed(int b)
{ {
ErrorWindow errorwindow(this, QString("Baudrate set failed:\n" + ErrorWindow errorwindow(this, tr("Baudrate set failed:\n") +
QString::number(b) + QString::number(b) +
" baud"), SerialPortError); tr(" baud"), SerialPortError);
errorwindow.show(); errorwindow.show();
} }

View File

@ -6,9 +6,9 @@ SettingsWindow::SettingsWindow(QWidget *parent) :
ui(new Ui::SettingsWindow) ui(new Ui::SettingsWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->flowcontrolbox->addItem("No control"); ui->flowcontrolbox->addItem(tr("No control"));
ui->flowcontrolbox->addItem("Hardware control"); ui->flowcontrolbox->addItem(tr("Hardware control"));
ui->flowcontrolbox->addItem("Software control"); ui->flowcontrolbox->addItem(tr("Software control"));
//bool firstrun = !settings.value("core/firstrun").toBool(); //firstrun is inverted! //bool firstrun = !settings.value("core/firstrun").toBool(); //firstrun is inverted!