More comments

This commit is contained in:
NeoTheFox 2015-03-15 19:54:40 +03:00
parent 9fa7e3d2c8
commit 1162748acd

View File

@ -764,15 +764,18 @@ void MainWindow::on_estepspin_valueChanged(const QString &arg1)
void MainWindow::on_actionSet_SD_printing_mode_triggered() void MainWindow::on_actionSet_SD_printing_mode_triggered()
{ {
//This is a manual switch to SD printing mode
//It can be useful if you have no display, and connected
//to a printer already printing something
sdprinting = true; sdprinting = true;
ui->fileBox->setDisabled(false); ui->fileBox->setDisabled(false);
} }
void MainWindow::requestEEPROMSettings() void MainWindow::requestEEPROMSettings()
{ {
emit flushInjectionBuffer(); emit flushInjectionBuffer(); //Request ASAP
EEPROMSettings.clear(); EEPROMSettings.clear(); //Clear anything stored before
//Find out what to call according to firmware
switch(firmware) switch(firmware)
{ {
case Marlin: case Marlin:
@ -797,7 +800,7 @@ void MainWindow::openEEPROMeditor()
{ {
EEPROMWindow eepromwindow(EEPROMSettings, this); EEPROMWindow eepromwindow(EEPROMSettings, this);
eepromwindow.setWindowModality(Qt::NonModal); eepromwindow.setWindowModality(Qt::NonModal); //Do not bloct the UI when EEPROM editor is shown
connect(&eepromwindow, SIGNAL(changesComplete(QStringList)), this, SLOT(sendEEPROMsettings(QStringList))); connect(&eepromwindow, SIGNAL(changesComplete(QStringList)), this, SLOT(sendEEPROMsettings(QStringList)));
eepromwindow.exec(); eepromwindow.exec();
@ -805,7 +808,7 @@ void MainWindow::openEEPROMeditor()
void MainWindow::sendEEPROMsettings(QStringList changes) void MainWindow::sendEEPROMsettings(QStringList changes)
{ {
emit flushInjectionBuffer(); emit flushInjectionBuffer(); //To send EEPROM settings asap
foreach (QString str, changes) foreach (QString str, changes)
{ {
emit injectCommand(str); emit injectCommand(str);
@ -819,6 +822,7 @@ void MainWindow::EEPROMSettingRecieved(QString esetting)
void MainWindow::recievedError() void MainWindow::recievedError()
{ {
//This should be raised if "!!" recieved
ErrorWindow errorwindow(this,"Hardware failure"); ErrorWindow errorwindow(this,"Hardware failure");
errorwindow.exec(); errorwindow.exec();
} }
@ -833,6 +837,7 @@ void MainWindow::recievedSDDone()
void MainWindow::updateFileProgress(FileProgress p) void MainWindow::updateFileProgress(FileProgress p)
{ {
//Check if file is at end
if(p.P >= p.T) if(p.P >= p.T)
{ {
ui->sendBtn->setText("Send"); ui->sendBtn->setText("Send");
@ -847,6 +852,7 @@ void MainWindow::updateFileProgress(FileProgress p)
ui->pauseBtn->setEnabled(true); ui->pauseBtn->setEnabled(true);
sending = true; sending = true;
} }
//Update progressbar and text lines
ui->filelines->setText(QString::number(p.T) ui->filelines->setText(QString::number(p.T)
+ QString("/") + QString("/")
+ QString::number(p.P) + QString::number(p.P)
@ -854,22 +860,24 @@ void MainWindow::updateFileProgress(FileProgress p)
ui->progressBar->setValue(((float)p.P/p.T) * 100); ui->progressBar->setValue(((float)p.P/p.T) * 100);
} }
//Needed for keypress handling
bool MainWindow::eventFilter(QObject *obj, QEvent *event) bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{ {
//User history
if(obj == ui->sendtext && !userHistory.isEmpty()) if(obj == ui->sendtext && !userHistory.isEmpty())
{ {
if(event->type() == QEvent::KeyPress) if(event->type() == QEvent::KeyPress)
{ {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); //Fetch the event
if (keyEvent->key() == Qt::Key_Up) if (keyEvent->key() == Qt::Key_Up) //Scroll up with up arrow
{ {
if(++userHistoryPos <= userHistory.size()-1) if(++userHistoryPos <= userHistory.size()-1)
ui->sendtext->setText(userHistory.at(userHistoryPos)); ui->sendtext->setText(userHistory.at(userHistoryPos));
else userHistoryPos--; else userHistoryPos--;
return true; return true;
} }
else if(keyEvent->key() == Qt::Key_Down) else if(keyEvent->key() == Qt::Key_Down) //Scroll down with down arow
{ {
if(--userHistoryPos >= 0) if(--userHistoryPos >= 0)
ui->sendtext->setText(userHistory.at(userHistoryPos)); ui->sendtext->setText(userHistory.at(userHistoryPos));
@ -879,13 +887,14 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
} }
return false; return false;
} }
//Temperature
else if(obj == ui->etmpspin) else if(obj == ui->etmpspin)
{ {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if(keyEvent->key() == Qt::Key_Return) if(keyEvent->key() == Qt::Key_Return)
{ {
ui->etmpset->click(); ui->etmpset->click(); //Emulate keypress
return true; return true;
} }
return false; return false;
@ -896,7 +905,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
if(keyEvent->key() == Qt::Key_Return) if(keyEvent->key() == Qt::Key_Return)
{ {
ui->btmpset->click(); ui->btmpset->click(); //Emulate keypress
return true; return true;
} }
return false; return false;
@ -906,5 +915,8 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
void MainWindow::recentClicked() void MainWindow::recentClicked()
{ {
//Actually a dirty hack, but it is fast and simple
//So this slot is not for anything to trigger, but
//recent files menu
parseFile(sender()->objectName()); parseFile(sender()->objectName());
} }