More settings and UI bugfixes

This commit is contained in:
NeoTheFox 2015-03-06 21:57:46 +03:00
parent 1f287f3b58
commit c174c93ed8
5 changed files with 105 additions and 62 deletions

View File

@ -13,9 +13,9 @@ MainWindow::MainWindow(QWidget *parent) :
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->controlBox->setDisabled(true); ui->controlBox->setDisabled(true);
ui->consoleGroup->setDisabled(true); ui->consoleGroup->setDisabled(true);
ui->pauseBtn->setDisabled("true"); ui->pauseBtn->setDisabled(true);
ui->actionPrint_from_SD->setDisabled("true"); ui->actionPrint_from_SD->setDisabled(true);
ui->actionSet_SD_printing_mode->setDisabled("true"); ui->actionSet_SD_printing_mode->setDisabled(true);
ui->baudbox->addItem(QString::number(4800)); ui->baudbox->addItem(QString::number(4800));
ui->baudbox->addItem(QString::number(9600)); ui->baudbox->addItem(QString::number(9600));
@ -45,6 +45,7 @@ MainWindow::MainWindow(QWidget *parent) :
autolock = settings.value("core/lockcontrols").toBool(); autolock = settings.value("core/lockcontrols").toBool();
sendingChecksum = settings.value("core/checksums").toBool(); sendingChecksum = settings.value("core/checksums").toBool();
chekingSDStatus = settings.value("core/checksdstatus").toBool();
sending = false; sending = false;
paused = false; paused = false;
@ -83,7 +84,7 @@ MainWindow::MainWindow(QWidget *parent) :
sendTimer.start(); sendTimer.start();
progressSDTimer.setInterval(3000); progressSDTimer.setInterval(3000);
progressSDTimer.start(); if(chekingSDStatus)progressSDTimer.start();
tempWarning.setInterval(10000); tempWarning.setInterval(10000);
@ -146,6 +147,7 @@ void MainWindow::parseFile(QFile &file)
{ {
if(sendingChecksum) if(sendingChecksum)
{ {
//Checksum algorithm from RepRap wiki
line = "N"+QString::number(n)+line+"*"; line = "N"+QString::number(n)+line+"*";
int cs = 0; int cs = 0;
for(int i = 0; line.at(i) != '*'; i++) cs = cs ^ line.at(i).toLatin1(); for(int i = 0; line.at(i) != '*'; i++) cs = cs ^ line.at(i).toLatin1();
@ -160,6 +162,8 @@ void MainWindow::parseFile(QFile &file)
file.close(); file.close();
sdprinting = false; sdprinting = false;
ui->fileBox->setEnabled(true); ui->fileBox->setEnabled(true);
ui->progressBar->setEnabled(true);
ui->sendBtn->setText("Send");
ui->filename->setText(file.fileName().split("/").last()); ui->filename->setText(file.fileName().split("/").last());
ui->filelines->setText(QString::number(gcode.size()) + QString("/0 lines")); ui->filelines->setText(QString::number(gcode.size()) + QString("/0 lines"));
} }
@ -234,8 +238,8 @@ void MainWindow::serialconnect()
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->controlBox->setDisabled(false); ui->controlBox->setDisabled(false);
ui->consoleGroup->setDisabled(false); ui->consoleGroup->setDisabled(false);
ui->actionPrint_from_SD->setEnabled("true"); ui->actionPrint_from_SD->setEnabled(true);
ui->actionSet_SD_printing_mode->setEnabled("true"); ui->actionSet_SD_printing_mode->setEnabled(true);
//if(checkingTemperature) injectCommand("M105"); //if(checkingTemperature) injectCommand("M105");
} }
} }
@ -250,8 +254,8 @@ void MainWindow::serialconnect()
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->controlBox->setDisabled(true); ui->controlBox->setDisabled(true);
ui->consoleGroup->setDisabled(true); ui->consoleGroup->setDisabled(true);
ui->actionPrint_from_SD->setDisabled("true"); ui->actionPrint_from_SD->setDisabled(true);
ui->actionSet_SD_printing_mode->setDisabled("true"); ui->actionSet_SD_printing_mode->setDisabled(true);
} }
} }
@ -483,7 +487,7 @@ void MainWindow::readSerial()
sdprinting=false; sdprinting=false;
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->filename->setText(""); ui->filename->setText("");
ui->fileBox->setDisabled("true"); ui->fileBox->setDisabled(true);
} }
else if(data.startsWith("start") && checkingTemperature) injectCommand("M105"); else if(data.startsWith("start") && checkingTemperature) injectCommand("M105");
else if(data.startsWith("SD pr")) else if(data.startsWith("SD pr"))
@ -531,8 +535,8 @@ void MainWindow::on_sendBtn_clicked()
sending = false; sending = false;
ui->sendBtn->setText("Send"); ui->sendBtn->setText("Send");
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText("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;
} }
else if(!sending && !sdprinting) else if(!sending && !sdprinting)
@ -540,8 +544,8 @@ void MainWindow::on_sendBtn_clicked()
sending=true; sending=true;
ui->sendBtn->setText("Stop"); ui->sendBtn->setText("Stop");
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText("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;
} }
else if(sdprinting) else if(sdprinting)
@ -551,7 +555,7 @@ void MainWindow::on_sendBtn_clicked()
injectCommand("M27"); injectCommand("M27");
ui->sendBtn->setText("Send"); ui->sendBtn->setText("Send");
ui->pauseBtn->setText("Pause"); ui->pauseBtn->setText("Pause");
if(autolock) ui->controlBox->setChecked("true"); if(autolock) ui->controlBox->setChecked(true);
paused = false; paused = false;
} }
@ -574,7 +578,7 @@ void MainWindow::sendNext()
sending = false; sending = false;
currentLine = 0; currentLine = 0;
ui->sendBtn->setText("Send"); ui->sendBtn->setText("Send");
ui->pauseBtn->setDisabled("true"); ui->pauseBtn->setDisabled(true);
ui->filelines->setText(QString::number(gcode.size()) ui->filelines->setText(QString::number(gcode.size())
+ QString("/") + QString("/")
+ QString::number(currentLine) + QString::number(currentLine)
@ -672,8 +676,8 @@ void MainWindow::serialError(QSerialPort::SerialPortError error)
ui->pauseBtn->setDisabled(true); ui->pauseBtn->setDisabled(true);
ui->controlBox->setDisabled(true); ui->controlBox->setDisabled(true);
ui->consoleGroup->setDisabled(true); ui->consoleGroup->setDisabled(true);
ui->actionPrint_from_SD->setDisabled("true"); ui->actionPrint_from_SD->setDisabled(true);
ui->actionSet_SD_printing_mode->setDisabled("true"); ui->actionSet_SD_printing_mode->setDisabled(true);
qDebug() << error; qDebug() << error;
@ -804,8 +808,14 @@ void MainWindow::selectSDfile(QString file)
QString filename = file.remove(" "+bytes); QString filename = file.remove(" "+bytes);
ui->filename->setText(filename); ui->filename->setText(filename);
ui->filelines->setText(bytes + QString("/0 bytes")); if(chekingSDStatus)
ui->progressBar->setValue(0); {
ui->filelines->setText(bytes + QString("/0 bytes"));
ui->progressBar->setEnabled(true);
ui->progressBar->setValue(0);
}
else ui->progressBar->setDisabled(true);
ui->sendBtn->setText("Start");
sdBytes = bytes.toDouble(); sdBytes = bytes.toDouble();
userCommands.clear(); userCommands.clear();
@ -827,7 +837,7 @@ void MainWindow::updateSDStatus()
void MainWindow::checkSDStatus() void MainWindow::checkSDStatus()
{ {
if(sdprinting && sdWatcher.isFinished()) injectCommand("M27"); if(sdprinting && chekingSDStatus && sdWatcher.isFinished()) injectCommand("M27");
} }
void MainWindow::on_stepspin_valueChanged(const QString &arg1) void MainWindow::on_stepspin_valueChanged(const QString &arg1)

View File

@ -37,6 +37,7 @@ public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);
~MainWindow(); ~MainWindow();
protected:
QFile gfile; QFile gfile;
QVector<QString> gcode; QVector<QString> gcode;
QQueue <QString> userCommands; QQueue <QString> userCommands;
@ -68,6 +69,7 @@ private:
bool sdprinting; bool sdprinting;
bool echo; bool echo;
bool sendingChecksum; bool sendingChecksum;
bool chekingSDStatus;
long int currentLine; long int currentLine;
int readyRecieve; int readyRecieve;
unsigned long int sdBytes; unsigned long int sdBytes;

View File

@ -965,6 +965,12 @@ STOP</string>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QGroupBox" name="statusGroup"> <widget class="QGroupBox" name="statusGroup">
<property name="maximumSize">
<size>
<width>190</width>
<height>16777215</height>
</size>
</property>
<property name="title"> <property name="title">
<string>Status</string> <string>Status</string>
</property> </property>
@ -1223,8 +1229,8 @@ STOP</string>
<slot>serialupdate()</slot> <slot>serialupdate()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>82</x> <x>100</x>
<y>84</y> <y>110</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>247</x> <x>247</x>
@ -1255,8 +1261,8 @@ STOP</string>
<slot>serialconnect()</slot> <slot>serialconnect()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>82</x> <x>100</x>
<y>116</y> <y>142</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>247</x> <x>247</x>
@ -1271,8 +1277,8 @@ STOP</string>
<slot>xhome()</slot> <slot>xhome()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>455</x> <x>454</x>
<y>81</y> <y>108</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>383</x> <x>383</x>
@ -1288,7 +1294,7 @@ STOP</string>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>739</x> <x>739</x>
<y>331</y> <y>376</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>654</x> <x>654</x>
@ -1303,8 +1309,8 @@ STOP</string>
<slot>xplus()</slot> <slot>xplus()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>323</x> <x>329</x>
<y>110</y> <y>138</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>383</x> <x>383</x>
@ -1320,11 +1326,11 @@ STOP</string>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>739</x> <x>739</x>
<y>360</y> <y>405</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>739</x> <x>739</x>
<y>389</y> <y>434</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1335,8 +1341,8 @@ STOP</string>
<slot>yminus()</slot> <slot>yminus()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>285</x> <x>289</x>
<y>139</y> <y>168</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>383</x> <x>383</x>
@ -1351,8 +1357,8 @@ STOP</string>
<slot>yplus()</slot> <slot>yplus()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>285</x> <x>289</x>
<y>81</y> <y>108</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>383</x> <x>383</x>
@ -1367,8 +1373,8 @@ STOP</string>
<slot>xminus()</slot> <slot>xminus()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>248</x> <x>250</x>
<y>110</y> <y>138</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>189</x> <x>189</x>
@ -1383,8 +1389,8 @@ STOP</string>
<slot>zplus()</slot> <slot>zplus()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>367</x> <x>368</x>
<y>81</y> <y>108</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>356</x> <x>356</x>
@ -1399,8 +1405,8 @@ STOP</string>
<slot>zminus()</slot> <slot>zminus()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>367</x> <x>368</x>
<y>139</y> <y>168</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>209</x> <x>209</x>
@ -1415,8 +1421,8 @@ STOP</string>
<slot>ezero()</slot> <slot>ezero()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>411</x> <x>408</x>
<y>110</y> <y>138</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>220</x> <x>220</x>
@ -1431,8 +1437,8 @@ STOP</string>
<slot>zhome()</slot> <slot>zhome()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>455</x> <x>454</x>
<y>139</y> <y>168</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>209</x> <x>209</x>
@ -1447,8 +1453,8 @@ STOP</string>
<slot>yhome()</slot> <slot>yhome()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>455</x> <x>454</x>
<y>110</y> <y>138</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>383</x> <x>383</x>
@ -1463,8 +1469,8 @@ STOP</string>
<slot>eplus()</slot> <slot>eplus()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>411</x> <x>408</x>
<y>81</y> <y>108</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>397</x> <x>397</x>
@ -1479,8 +1485,8 @@ STOP</string>
<slot>eminus()</slot> <slot>eminus()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>411</x> <x>408</x>
<y>139</y> <y>168</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>475</x> <x>475</x>
@ -1495,8 +1501,8 @@ STOP</string>
<slot>bedcenter()</slot> <slot>bedcenter()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>285</x> <x>289</x>
<y>110</y> <y>138</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>321</x> <x>321</x>
@ -1511,8 +1517,8 @@ STOP</string>
<slot>homeall()</slot> <slot>homeall()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>257</x> <x>329</x>
<y>165</y> <y>198</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>200</x> <x>200</x>
@ -1520,6 +1526,22 @@ STOP</string>
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>sendtext</sender>
<signal>returnPressed()</signal>
<receiver>sendtext</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel">
<x>558</x>
<y>394</y>
</hint>
<hint type="destinationlabel">
<x>494</x>
<y>397</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>open()</slot> <slot>open()</slot>

View File

@ -26,6 +26,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) :
ui->lockbox->setChecked(settings.value("core/lockcontrols").toBool()); ui->lockbox->setChecked(settings.value("core/lockcontrols").toBool());
ui->checksumbox->setChecked(settings.value("core/checksums").toBool()); ui->checksumbox->setChecked(settings.value("core/checksums").toBool());
ui->sdbox->setChecked(settings.value("core/checksdstatus").toBool());
} }
@ -43,4 +44,5 @@ void SettingsWindow::on_buttonBox_accepted()
settings.setValue("core/echo", ui->echobox->isChecked()); settings.setValue("core/echo", ui->echobox->isChecked());
settings.setValue("core/lockcontrols", ui->lockbox->isChecked()); settings.setValue("core/lockcontrols", ui->lockbox->isChecked());
settings.setValue("core/checksums", ui->checksumbox->isChecked()); settings.setValue("core/checksums", ui->checksumbox->isChecked());
settings.setValue("core/checksdstatus", ui->sdbox->isChecked());
} }

View File

@ -89,10 +89,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>ms</string> <string>Sender</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -103,14 +103,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="2">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Sender</string> <string>ms</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="6" column="0">
<widget class="QCheckBox" name="checksumbox"> <widget class="QCheckBox" name="checksumbox">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -142,6 +142,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="sdbox">
<property name="text">
<string>Check SD printing status</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>