Compare commits

...

56 Commits

Author SHA1 Message Date
cf81418938 Merge pull request #8 from probonopd/patch-1
Build and upload AppImage for Linux
2017-03-27 15:08:22 +04:00
probonopd
9a3af3047f Update RepRaptor.desktop 2017-03-25 14:03:19 +01:00
probonopd
f94938b372 Update .travis.yml 2017-03-25 13:55:45 +01:00
60bb57f374 Switched settingswindow.ui to tabbed mode 2017-03-06 15:10:33 +03:00
98b10de3f4 Bumped version 2016-04-16 13:11:29 +03:00
1589d1a4ae New PPA name to fix build 2016-04-16 12:59:36 +03:00
5c790251c1 Added log buffe settings (should also fix the memory leak) 2016-04-16 12:56:30 +03:00
094d7a04b3 Updated printMsg to prevent possible bugs 2016-04-16 12:41:14 +03:00
1533625411 Added travis icon 2015-12-04 10:22:13 +01:00
747b9ebe62 Cleanup for travis 2015-12-04 10:20:13 +01:00
b5b4af8a2e forgot --yes for travis 2015-12-04 10:17:22 +01:00
549d7a76f5 changed travis qt to 55 2015-12-04 10:15:12 +01:00
de6e25391a More travis scripting 2015-12-04 10:08:04 +01:00
705e6ef5b6 Travis package change 2015-12-04 10:02:32 +01:00
c64598d640 Changed travis qmake 2015-12-04 09:57:47 +01:00
bd76f479e7 Second attempt at travis config 2015-12-04 09:55:36 +01:00
a0fb0d588b Fixed apt name 2015-12-04 09:51:58 +01:00
5ae242b4e4 Added travis config 2015-12-04 09:44:13 +01:00
8469e2a6b6 Remember last folder 2015-05-20 17:02:55 +03:00
10365239a5 Remember Step and EStep 2015-05-15 14:37:57 +03:00
7eabc94adf Added "wait" supression 2015-05-02 14:22:54 +03:00
c90153a750 Code cleanup 2015-05-02 14:06:54 +03:00
f7ff8882f2 Release version updated 2015-03-29 14:03:12 +03:00
169cb07d28 Minor refactoring 2015-03-28 21:39:20 +03:00
ce33d5a804 Added new error type 2015-03-28 21:34:49 +03:00
deceb81c8b Flush user buffer upon printing 2015-03-27 23:29:01 +03:00
2d6d09743e Fixed crash in SD window
Fixed '\r\n' at the end of string and pressing "ok" with no selection
2015-03-26 21:12:38 +03:00
ecc6e5570d Ui tweaks 2015-03-26 18:17:24 +03:00
136c2f1077 Set parent for QSettings 2015-03-26 18:10:44 +03:00
a6b57d0da0 Set parent for QSettings 2015-03-26 18:10:11 +03:00
74ec8c9806 Prevent SD printing if no files available 2015-03-26 17:59:47 +03:00
83a5f0eb1d Handle "Not SD printing" 2015-03-26 17:32:48 +03:00
b986c98f9c Optimized priority 2015-03-26 15:33:32 +03:00
c4ba7c8e4f Moved set priority 2015-03-26 15:22:43 +03:00
ae27a3cc96 Merged 2015-03-26 14:42:08 +03:00
7f57b698a1 Merge branch 'master' of https://github.com/NeoTheFox/RepRaptor 2015-03-26 14:40:06 +03:00
6e52256bd9 Better user history 2015-03-26 14:39:00 +03:00
70963c8f59 No need for QPixmap 2015-03-25 23:00:05 +03:00
3cc2dcabb5 Added check for empty filename 2015-03-25 22:36:49 +03:00
1294d65618 Added tray icon 2015-03-25 16:54:08 +03:00
7e18e2fd2f Added tooltips 2015-03-25 15:32:58 +03:00
933163257d Set dialog title 2015-03-24 16:18:12 +03:00
c7b4ba29de Corrected event 2015-03-24 16:16:01 +03:00
dd59c0c54a Added warning on closeEvent 2015-03-24 16:13:43 +03:00
908f49389a Sender priority tweak 2015-03-24 15:09:43 +03:00
2fdd05cac1 Auto-capitalize manual commands 2015-03-23 16:04:41 +03:00
b0190ded97 Made dirty hack less dirty 2015-03-23 14:28:18 +03:00
ec902e01b6 Update settings on change 2015-03-22 14:42:25 +03:00
2e24c28bbf Got rid of compilation warnings
More refactoring
2015-03-21 18:42:44 +03:00
7e354a56d7 More error messages 2015-03-21 16:36:14 +03:00
9fff9d6743 Typo fix 2015-03-21 16:16:53 +03:00
157f3e5535 Refactoring 2015-03-21 01:16:15 +03:00
5f1c9d68f7 Refactoring
Converted old signals and slots to new style
Cleanup
2015-03-21 01:11:50 +03:00
f38e1bf069 Unsupported by OS error handling 2015-03-21 00:57:03 +03:00
6cd2ac8d2e Editable baudrate
Minor UI fixes
2015-03-21 00:52:28 +03:00
b24017e138 Moved to the next version development 2015-03-20 21:44:34 +03:00
24 changed files with 658 additions and 348 deletions

26
.travis.yml Normal file
View File

@ -0,0 +1,26 @@
language: cpp
compiler: gcc
sudo: require
dist: trusty
before_install:
- sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y
- sudo apt-get update -qq
install:
- sudo apt-get -y install qt58base qt58serialport qt58tools
- source /opt/qt58/bin/qt58-env.sh
script:
- qmake PREFIX=/usr
- make -j4
- sudo make INSTALL_ROOT=appdir install ; sudo chown -R $USER appdir ; find appdir/
after_success:
- wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
- chmod a+x linuxdeployqt*.AppImage
- unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
- ./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -bundle-non-qt-libs
- ./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -appimage
- find ./appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq
- curl --upload-file ./RepRaptor*.AppImage https://transfer.sh/RepRaptor-git.$(git rev-parse --short HEAD)-x86_64.AppImage

View File

@ -1,5 +1,5 @@
![RepRaptor logo](http://reprap.org/mediawiki/images/b/b0/RepRaptor_logo2.png) ![RepRaptor logo](http://reprap.org/mediawiki/images/b/b0/RepRaptor_logo2.png)
# RepRaptor # RepRaptor [![Build Status](https://travis-ci.org/NeoTheFox/RepRaptor.svg?branch=master)](https://travis-ci.org/NeoTheFox/RepRaptor)
A Qt RepRap gcode sender/host controller aimed to be fast and minimalistic. A Qt RepRap gcode sender/host controller aimed to be fast and minimalistic.
Right now the project is in early stage. This means some features are still absent, but it is already usable. Right now the project is in early stage. This means some features are still absent, but it is already usable.

View File

@ -1,9 +1,8 @@
[Desktop Entry] [Desktop Entry]
Name=RepRaptor Name=RepRaptor
Comment=A Qt RepRap gcode sender/host controller aimed to be fast and minimalistic. Comment=A Qt RepRap gcode sender/host controller aimed to be fast and minimalistic.
Exec=/usr/bin/RepRaptor Exec=RepRaptor
Icon=/usr/share/icons/repraptor.png Icon=repraptor
Terminal=false Terminal=false
Type=Application Type=Application
Categories=Utility;Application; Categories=Utility;Application;

View File

@ -71,4 +71,5 @@ RESOURCES += \
DISTFILES += \ DISTFILES += \
LICENCE \ LICENCE \
README.md \ README.md \
RepRaptor.desktop RepRaptor.desktop \
.travis.yml

View File

@ -64,7 +64,7 @@ EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) :
break; break;
} }
connect(edit, SIGNAL(textChanged(QString)), this, SLOT(lineChanged(QString))); connect(edit, &QLineEdit::textChanged, this, &EEPROMWindow::lineChanged);
line->addWidget(label); line->addWidget(label);
line->addWidget(edit); line->addWidget(edit);

View File

@ -4,16 +4,18 @@ ErrorIcon::ErrorIcon(QWidget *parent) : QWidget(parent)
{ {
framenum = 0; framenum = 0;
frame = ":icons/error_a.png"; frame = ":icons/error_a.png";
animation.setInterval(300); animation = new QTimer(this);
animation.start(); animation->setInterval(300);
animation->start();
connect(&animation, SIGNAL(timeout()), this, SLOT(changeFrame())); connect(animation, &QTimer::timeout, this, &ErrorIcon::changeFrame);
} }
void ErrorIcon::paintEvent(QPaintEvent *pe) void ErrorIcon::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
painter.drawPixmap(0,0,128,87,QPixmap(frame)); QPixmap pframe(frame);
painter.drawPixmap(0,0,pframe.width(),pframe.height(),pframe);
} }
void ErrorIcon::changeFrame() void ErrorIcon::changeFrame()
@ -33,6 +35,6 @@ void ErrorIcon::changeFrame()
ErrorIcon::~ErrorIcon() ErrorIcon::~ErrorIcon()
{ {
animation->stop();
} }

View File

@ -11,12 +11,12 @@ class ErrorIcon : public QWidget
public: public:
explicit ErrorIcon(QWidget *parent = 0); explicit ErrorIcon(QWidget *parent = 0);
~ErrorIcon(); ~ErrorIcon();
QTimer animation; QTimer *animation;
QString frame; QString frame;
int framenum; int framenum;
protected: protected:
virtual void paintEvent(QPaintEvent *pe); virtual void paintEvent(QPaintEvent *);
signals: signals:

View File

@ -1,11 +1,29 @@
#include "errorwindow.h" #include "errorwindow.h"
#include "ui_errorwindow.h" #include "ui_errorwindow.h"
ErrorWindow::ErrorWindow(QWidget *parent, QString errorText) : using namespace RepRaptor;
ErrorWindow::ErrorWindow(QWidget *parent, QString errorText, int errType):
QDialog(parent), QDialog(parent),
ui(new Ui::ErrorWindow) ui(new Ui::ErrorWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
switch(errType)
{
case SerialPortError:
ui->label->setText(tr("Serial port error:"));
break;
case OpenFileError:
ui->label->setText(tr("File open error:"));
break;
case HardwareFailure:
ui->label->setText(tr("Hardware failure:"));
break;
default:
ui->label->setText(tr("Unknown error type:"));
break;
}
ui->errorlabel->setText(errorText); ui->errorlabel->setText(errorText);
} }

View File

@ -4,6 +4,7 @@
#include <QDialog> #include <QDialog>
#include "erroricon.h" #include "erroricon.h"
#include "repraptor.h"
namespace Ui { namespace Ui {
class ErrorWindow; class ErrorWindow;
@ -14,7 +15,7 @@ class ErrorWindow : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit ErrorWindow(QWidget *parent = 0, QString errorText = "Unknown error"); explicit ErrorWindow(QWidget *parent = 0, QString errorText = "Unknown error", int errType = 0);
~ErrorWindow(); ~ErrorWindow();
private: private:

View File

@ -12,9 +12,6 @@ int main(int argc, char *argv[])
QCoreApplication::setApplicationName("RepRaptor"); QCoreApplication::setApplicationName("RepRaptor");
QCoreApplication::setApplicationVersion(REPRAPTOR_VERSION); QCoreApplication::setApplicationVersion(REPRAPTOR_VERSION);
//Set the priority, so the OS would not mess up serial communication
QThread::currentThread()->setPriority(QThread::HighestPriority);
MainWindow w; MainWindow w;
w.show(); w.show();

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);
@ -25,9 +29,18 @@ MainWindow::MainWindow(QWidget *parent) :
ui->etmpspin->installEventFilter(this); ui->etmpspin->installEventFilter(this);
ui->btmpspin->installEventFilter(this); ui->btmpspin->installEventFilter(this);
recentMenu = new QMenu(this); recentMenu = new QMenu(this);
//Note about tray icon - possible bug with Qt 5.4
trayIcon = new QSystemTrayIcon(this);
trayIcon->setIcon(QIcon(":icons/repraptor.png"));
trayIconMenu = new QMenu(this);
trayIconMenu->addAction(ui->actionOpen);
trayIconMenu->addAction(ui->actionExit);
trayIcon->setToolTip(tr("RepRaptor running in the background"));
trayIcon->setContextMenu(trayIconMenu);
recentMenu->setTitle("Recent files"); recentMenu->setTitle("Recent files");
ui->menuFile->insertMenu(ui->actionSettings, recentMenu); ui->menuFile->insertMenu(ui->actionSettings, recentMenu);
ui->menuFile->insertSeparator(ui->actionSettings); ui->menuFile->insertSeparator(ui->actionSettings);
terminalCursor = ui->terminal->textCursor();
//Init baudrate combobox //Init baudrate combobox
ui->baudbox->addItem(QString::number(4800)); ui->baudbox->addItem(QString::number(4800));
@ -67,6 +80,10 @@ MainWindow::MainWindow(QWidget *parent) :
ui->checktemp->setChecked(checkingTemperature); ui->checktemp->setChecked(checkingTemperature);
ui->etmpspin->setValue(settings.value("user/extrudertemp", 210).toInt()); ui->etmpspin->setValue(settings.value("user/extrudertemp", 210).toInt());
ui->btmpspin->setValue(settings.value("user/bedtemp", 60).toInt()); ui->btmpspin->setValue(settings.value("user/bedtemp", 60).toInt());
ui->stepspin->setValue(settings.value("user/step", 1).toInt());
ui->estepspin->setValue(settings.value("user/estep", 1).toInt());
ui->terminal->document()->setMaximumBlockCount(
settings.value("core/logbuffersize", 1000).toInt());
echo = settings.value("core/echo", 0).toBool(); echo = settings.value("core/echo", 0).toBool();
autolock = settings.value("core/lockcontrols", 0).toBool(); autolock = settings.value("core/lockcontrols", 0).toBool();
chekingSDStatus = settings.value("core/checksdstatus", 1).toBool(); chekingSDStatus = settings.value("core/checksdstatus", 1).toBool();
@ -74,6 +91,9 @@ MainWindow::MainWindow(QWidget *parent) :
statusTimer->setInterval(settings.value("core/statusinterval", 3000).toInt()); statusTimer->setInterval(settings.value("core/statusinterval", 3000).toInt());
feedrate = settings.value("feedrate", 1500).toInt(); feedrate = settings.value("feedrate", 1500).toInt();
extruderFeedrate = settings.value("extruderfeedrate", 200).toInt(); extruderFeedrate = settings.value("extruderfeedrate", 200).toInt();
trayIconEnabled = settings.value("core/trayiconenabled", 1).toBool();
supressWait = settings.value("user/supresswait", 0).toBool();
lastDir.append(settings.value("user/lastdir", "").toString());
int size = settings.beginReadArray("user/recentfiles"); int size = settings.beginReadArray("user/recentfiles");
for(int i = 0; i < size; ++i) for(int i = 0; i < size; ++i)
{ {
@ -88,16 +108,7 @@ MainWindow::MainWindow(QWidget *parent) :
sdprinting = false; sdprinting = false;
opened = false; opened = false;
sdBytes = 0; sdBytes = 0;
userHistoryPos = 0; userHistoryPos = -1;
userHistory.append("");
//Update serial ports
serialupdate();
//Internal signal-slots
connect(statusTimer, SIGNAL(timeout()), this, SLOT(checkStatus()));
connect(progressSDTimer, SIGNAL(timeout()), this, SLOT(checkSDStatus()));
connect(this, SIGNAL(eepromReady()), this, SLOT(openEEPROMeditor()));
//Register all the types //Register all the types
qRegisterMetaType<TemperatureReadings>("TemperatureReadings"); qRegisterMetaType<TemperatureReadings>("TemperatureReadings");
@ -107,10 +118,14 @@ MainWindow::MainWindow(QWidget *parent) :
qRegisterMetaType<FileProgress>("FileProgress"); qRegisterMetaType<FileProgress>("FileProgress");
qRegisterMetaType<QSerialPort::SerialPortError>("QSerialPort::SerialPortError"); qRegisterMetaType<QSerialPort::SerialPortError>("QSerialPort::SerialPortError");
//Internal signal-slots
connect(statusTimer, &QTimer::timeout, this, &MainWindow::checkStatus);
connect(progressSDTimer, &QTimer::timeout, this, &MainWindow::checkSDStatus);
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconClicked);
//Parser thread signal-slots and init //Parser thread signal-slots and init
parserWorker->moveToThread(parserThread); parserWorker->moveToThread(parserThread);
connect(parserThread, &QThread::finished, parserWorker, &QObject::deleteLater); connect(parserThread, &QThread::finished, parserWorker, &QObject::deleteLater);
connect(this, &MainWindow::receivedData, parserWorker, &Parser::parse);
connect(this, &MainWindow::startedReadingEEPROM, parserWorker, &Parser::setEEPROMReadingMode); connect(this, &MainWindow::startedReadingEEPROM, parserWorker, &Parser::setEEPROMReadingMode);
connect(parserWorker, &Parser::receivedTemperature, this, &MainWindow::updateTemperature); connect(parserWorker, &Parser::receivedTemperature, this, &MainWindow::updateTemperature);
connect(parserWorker, &Parser::receivedSDFilesList, this, &MainWindow::initSDprinting); connect(parserWorker, &Parser::receivedSDFilesList, this, &MainWindow::initSDprinting);
@ -119,7 +134,9 @@ MainWindow::MainWindow(QWidget *parent) :
connect(parserWorker, &Parser::receivedError, this, &MainWindow::receivedError); connect(parserWorker, &Parser::receivedError, this, &MainWindow::receivedError);
connect(parserWorker, &Parser::receivedSDDone, this, &MainWindow::receivedSDDone); connect(parserWorker, &Parser::receivedSDDone, this, &MainWindow::receivedSDDone);
connect(parserWorker, &Parser::receivedSDUpdate, this, &MainWindow::updateSDStatus); connect(parserWorker, &Parser::receivedSDUpdate, this, &MainWindow::updateSDStatus);
connect(parserWorker, &Parser::receivedNotSDPrinting, this, &MainWindow::receivedNotSDPrinting);
parserThread->start(); parserThread->start();
parserThread->setPriority(QThread::HighestPriority);
//Sender thread signal-slots and init //Sender thread signal-slots and init
senderWorker->moveToThread(senderThread); senderWorker->moveToThread(senderThread);
@ -129,8 +146,8 @@ MainWindow::MainWindow(QWidget *parent) :
connect(parserWorker, &Parser::receivedResend, senderWorker, &Sender::receivedResend); connect(parserWorker, &Parser::receivedResend, senderWorker, &Sender::receivedResend);
connect(parserWorker, &Parser::receivedStart, senderWorker, &Sender::receivedStart); connect(parserWorker, &Parser::receivedStart, senderWorker, &Sender::receivedStart);
connect(senderWorker, &Sender::errorReceived, this, &MainWindow::serialError); connect(senderWorker, &Sender::errorReceived, this, &MainWindow::serialError);
connect(senderWorker, &Sender::dataReceived, parserWorker, &Parser::parse, Qt::QueuedConnection); connect(senderWorker, &Sender::dataReceived, parserWorker, &Parser::parse);
connect(senderWorker, &Sender::dataReceived, this, &MainWindow::readSerial, Qt::QueuedConnection); connect(senderWorker, &Sender::dataReceived, this, &MainWindow::readSerial);
connect(senderWorker, &Sender::reportProgress, this, &MainWindow::updateFileProgress); connect(senderWorker, &Sender::reportProgress, this, &MainWindow::updateFileProgress);
connect(senderWorker, &Sender::baudrateSetFailed, this, &MainWindow::baudrateSetFailed); connect(senderWorker, &Sender::baudrateSetFailed, this, &MainWindow::baudrateSetFailed);
connect(this, &MainWindow::setFile, senderWorker, &Sender::setFile); connect(this, &MainWindow::setFile, senderWorker, &Sender::setFile);
@ -143,6 +160,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(this, &MainWindow::injectCommand, senderWorker, &Sender::injectCommand); connect(this, &MainWindow::injectCommand, senderWorker, &Sender::injectCommand);
connect(this, &MainWindow::flushInjectionBuffer, senderWorker, &Sender::flushInjectionBuffer); connect(this, &MainWindow::flushInjectionBuffer, senderWorker, &Sender::flushInjectionBuffer);
senderThread->start(); senderThread->start();
senderThread->setPriority(QThread::TimeCriticalPriority);
//Timers init //Timers init
statusTimer->start(); statusTimer->start();
@ -151,8 +169,15 @@ MainWindow::MainWindow(QWidget *parent) :
sinceLastTemp->start(); sinceLastTemp->start();
sinceLastSDStatus->start(); sinceLastSDStatus->start();
//Update serial ports
serialupdate();
//Update recent files list //Update recent files list
updateRecent(); updateRecent();
//Update icon
if(trayIconEnabled) trayIcon->show();
else trayIcon->hide();
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -163,6 +188,9 @@ MainWindow::~MainWindow()
settings.setValue("core/checktemperature", ui->checktemp->isChecked()); settings.setValue("core/checktemperature", ui->checktemp->isChecked());
settings.setValue("user/extrudertemp", ui->etmpspin->value()); settings.setValue("user/extrudertemp", ui->etmpspin->value());
settings.setValue("user/bedtemp", ui->btmpspin->value()); settings.setValue("user/bedtemp", ui->btmpspin->value());
settings.setValue("user/step", ui->stepspin->value());
settings.setValue("user/estep", ui->estepspin->value());
settings.setValue("user/lastdir", lastDir);
settings.beginWriteArray("user/recentfiles"); settings.beginWriteArray("user/recentfiles");
for(int i = 0; i < recentFiles.size(); ++i) for(int i = 0; i < recentFiles.size(); ++i)
{ {
@ -185,13 +213,34 @@ MainWindow::~MainWindow()
void MainWindow::open() void MainWindow::open()
{ {
if(this->isHidden()) this->show();
sdprinting = false; sdprinting = false;
QString filename; QString filename;
QDir home; QDir home;
if(lastDir == "")
{
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)");
}
else
{
filename = QFileDialog::getOpenFileName(this,
tr("Open GCODE"),
lastDir,
"GCODE (*.g *.gco *.gcode *.nc)");
}
if(filename.isEmpty() || filename.isNull()) return;
//Remember the last folder
lastDir.clear();
lastDir.append(filename);
int filenameChars = 0;
for(int i = filename.count()-1; filename.at(i) != QDir::separator(); i--)
{
filenameChars++; //Count how many characters are in the filename
}
lastDir.remove(lastDir.count()-filenameChars, filenameChars);//remove filename
gfile.setFileName(filename); gfile.setFileName(filename);
if(!recentFiles.contains(filename)) if(!recentFiles.contains(filename))
{ {
@ -223,6 +272,13 @@ void MainWindow::parseFile(QString filename)
ui->filename->setText(gfile.fileName().split(QDir::separator()).last()); ui->filename->setText(gfile.fileName().split(QDir::separator()).last());
ui->filelines->setText(QString::number(gcode.size()) + QString("/0 lines")); ui->filelines->setText(QString::number(gcode.size()) + QString("/0 lines"));
} }
else
{
ErrorWindow window(this, tr("Can't open file"), OpenFileError);
ui->filename->setText("");
ui->filelines->setText("");
window.exec();
}
} }
void MainWindow::serialupdate() void MainWindow::serialupdate()
@ -277,7 +333,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);
@ -369,10 +425,10 @@ 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 = -1;
} }
void MainWindow::on_fanonbtn_clicked() void MainWindow::on_fanonbtn_clicked()
@ -481,8 +537,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;
@ -492,11 +548,13 @@ 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;
emit flushInjectionBuffer();
emit pause(paused); emit pause(paused);
emit startPrinting(); emit startPrinting();
} }
@ -505,8 +563,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;
@ -523,14 +581,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)
{ {
@ -547,6 +605,8 @@ void MainWindow::on_actionSettings_triggered()
{ {
SettingsWindow settingswindow(this); SettingsWindow settingswindow(this);
connect(&settingswindow, &SettingsWindow::updatesettings, this, &MainWindow::updatesettings);
settingswindow.exec(); settingswindow.exec();
} }
@ -572,15 +632,16 @@ void MainWindow::readSerial(QByteArray data)
void MainWindow::printMsg(QString text) void MainWindow::printMsg(QString text)
{ {
if(supressWait && text.startsWith("wait")) return;
//Get the cursor and set it to the end //Get the cursor and set it to the end
QTextCursor cursor = ui->terminal->textCursor(); terminalCursor.movePosition(QTextCursor::End);
cursor.movePosition(QTextCursor::End);
//Paste the text //Paste the text
cursor.insertText(text); terminalCursor.insertText(text);
//Apply //Scroll to the bottom
ui->terminal->setTextCursor(cursor); ui->terminal->verticalScrollBar()->setValue(
ui->terminal->verticalScrollBar()->maximum());
} }
void MainWindow::checkStatus() void MainWindow::checkStatus()
@ -611,9 +672,8 @@ void MainWindow::updateRecent()
{ {
QAction *action = new QAction(this); QAction *action = new QAction(this);
action->setText(str); //Set filepath as a title action->setText(str); //Set filepath as a title
action->setObjectName(str); //Also set name to the path so we can get it later
recentMenu->addAction(action); //Add action to the menu recentMenu->addAction(action); //Add action to the menu
connect(action, SIGNAL(triggered()), this, SLOT(recentClicked())); connect(action, &QAction::triggered, this, &MainWindow::recentClicked);
} }
} }
} }
@ -640,7 +700,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);
@ -657,38 +717,42 @@ 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;
case QSerialPort::UnsupportedOperationError:
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;
} }
//Spawn the error message //Spawn the error message
ErrorWindow errorwindow(this, errorMsg); ErrorWindow errorwindow(this, errorMsg, SerialPortError);
errorwindow.exec(); errorwindow.exec();
} }
@ -704,7 +768,7 @@ void MainWindow::initSDprinting(QStringList sdFiles)
{ {
SDWindow sdwindow(sdFiles, this); SDWindow sdwindow(sdFiles, this);
connect(&sdwindow, SIGNAL(fileSelected(QString)), this, SLOT(selectSDfile(QString))); connect(&sdwindow, &SDWindow::fileSelected, this, &MainWindow::selectSDfile);
sdwindow.exec(); sdwindow.exec();
} }
@ -719,12 +783,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();
@ -738,7 +802,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;
@ -752,6 +816,13 @@ void MainWindow::checkSDStatus()
emit injectCommand("M27"); emit injectCommand("M27");
} }
void MainWindow::receivedNotSDPrinting()
{
sdprinting = false;
ui->fileBox->setDisabled(true);
ui->filename->setText(tr("Filename: "));
}
void MainWindow::on_stepspin_valueChanged(const QString &arg1) void MainWindow::on_stepspin_valueChanged(const QString &arg1)
{ {
if(arg1.toFloat() < 1) ui->stepspin->setSingleStep(0.1); if(arg1.toFloat() < 1) ui->stepspin->setSingleStep(0.1);
@ -804,8 +875,8 @@ void MainWindow::openEEPROMeditor()
{ {
EEPROMWindow eepromwindow(EEPROMSettings, this); EEPROMWindow eepromwindow(EEPROMSettings, this);
eepromwindow.setWindowModality(Qt::NonModal); //Do not bloct the UI when EEPROM editor is shown eepromwindow.setWindowModality(Qt::NonModal); //Do not block the UI when EEPROM editor is shown
connect(&eepromwindow, SIGNAL(changesComplete(QStringList)), this, SLOT(sendEEPROMsettings(QStringList))); connect(&eepromwindow, &EEPROMWindow::changesComplete, this, &MainWindow::sendEEPROMsettings);
eepromwindow.exec(); eepromwindow.exec();
} }
@ -827,7 +898,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"), 2);
errorwindow.exec(); errorwindow.exec();
} }
@ -835,7 +906,9 @@ void MainWindow::receivedSDDone()
{ {
sdprinting=false; sdprinting=false;
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->filename->setText(""); if(trayIconEnabled && (this->isMinimized() || this->isHidden()))
trayIcon->showMessage(tr("Done"), tr("Finished printing"));
ui->filename->setText(tr("Filename:"));
ui->fileBox->setDisabled(true); ui->fileBox->setDisabled(true);
} }
@ -844,15 +917,17 @@ 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);
if(trayIconEnabled && (this->isMinimized() || this->isHidden()))
trayIcon->showMessage(tr("Done"), tr("Finished printing"));
sending = false; sending = false;
paused = false; paused = false;
emit pause(paused); emit pause(paused);
} }
else else
{ {
ui->sendBtn->setText("Stop"); ui->sendBtn->setText(tr("Stop"));
ui->pauseBtn->setEnabled(true); ui->pauseBtn->setEnabled(true);
sending = true; sending = true;
} }
@ -860,18 +935,31 @@ 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")); tr(" baud"), SerialPortError);
errorwindow.show(); errorwindow.show();
} }
void MainWindow::updatesettings()
{
echo = settings.value("core/echo", 0).toBool();
autolock = settings.value("core/lockcontrols", 0).toBool();
chekingSDStatus = settings.value("core/checksdstatus", 1).toBool();
firmware = settings.value("printer/firmware", OtherFirmware).toInt();
statusTimer->setInterval(settings.value("core/statusinterval", 3000).toInt());
feedrate = settings.value("feedrate", 1500).toInt();
extruderFeedrate = settings.value("extruderfeedrate", 200).toInt();
ui->terminal->document()->setMaximumBlockCount(
settings.value("core/logbuffersize", 1000).toInt());
}
//Needed for keypress handling //Needed for keypress handling
bool MainWindow::eventFilter(QObject *obj, QEvent *event) bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{ {
@ -884,7 +972,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
if (keyEvent->key() == Qt::Key_Up) //Scroll up with up arrow if (keyEvent->key() == Qt::Key_Up) //Scroll up with up arrow
{ {
if(++userHistoryPos <= userHistory.size()-1) if(++userHistoryPos < userHistory.size())
ui->sendtext->setText(userHistory.at(userHistoryPos)); ui->sendtext->setText(userHistory.at(userHistoryPos));
else userHistoryPos--; else userHistoryPos--;
return true; return true;
@ -893,7 +981,11 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{ {
if(--userHistoryPos >= 0) if(--userHistoryPos >= 0)
ui->sendtext->setText(userHistory.at(userHistoryPos)); ui->sendtext->setText(userHistory.at(userHistoryPos));
else userHistoryPos++; else
{
userHistoryPos++;
ui->sendtext->clear();
}
return true; return true;
} }
} }
@ -925,10 +1017,50 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
return QMainWindow::eventFilter(obj, event); return QMainWindow::eventFilter(obj, event);
} }
void MainWindow::closeEvent(QCloseEvent *event)
{
//If connected to printer - show warning dialog
if(opened)
{
//Create dialog
QMessageBox dialog(this);
//Set it up - different text if just connected and if printing
if(sending) dialog.setText(tr("Printer is working!\nAre you shure you want to exit?"));
else dialog.setText(tr("Printer is connected!\nAre you shure you want tot exit?"));
dialog.setIcon(QMessageBox::Warning);
dialog.setWindowTitle(tr("Warning"));
//Save pointer to check what button was clicked
QPushButton *exitButton = dialog.addButton(tr("Exit"), QMessageBox::AcceptRole);
dialog.addButton(QMessageBox::Cancel);
//Show dialog
dialog.exec();
//Process responce
if(dialog.clickedButton() == exitButton) event->accept();
else event->ignore();
}
//Close immediately if not connected
else event->accept();
}
void MainWindow::trayIconClicked(QSystemTrayIcon::ActivationReason reason)
{
if(trayIconEnabled && reason == QSystemTrayIcon::Trigger)
{
if(this->isHidden()) this->show();
else this->hide();
}
else return;
}
void MainWindow::recentClicked() void MainWindow::recentClicked()
{ {
//Actually a dirty hack, but it is fast and simple //Actually a dirty hack, but it is fast and simple
//So this slot is not for anything to trigger, but //So this slot is not for anything to trigger, but
//recent files menu //recent files menu
parseFile(sender()->objectName()); QAction *action = qobject_cast<QAction*>(sender());
if(action) parseFile(action->text());
} }

View File

@ -3,6 +3,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <QFileDialog> #include <QFileDialog>
#include <QSystemTrayIcon>
#include <QtSerialPort/QtSerialPort> #include <QtSerialPort/QtSerialPort>
#include <QFile> #include <QFile>
#include <QThread> #include <QThread>
@ -48,7 +49,9 @@ protected:
QQueue <QString> userCommands; QQueue <QString> userCommands;
QTimer *progressSDTimer; QTimer *progressSDTimer;
QTimer *statusTimer; QTimer *statusTimer;
QSystemTrayIcon *trayIcon;
QMenu *recentMenu; QMenu *recentMenu;
QMenu *trayIconMenu;
QElapsedTimer *sinceLastTemp; QElapsedTimer *sinceLastTemp;
QElapsedTimer *sinceLastSDStatus; QElapsedTimer *sinceLastSDStatus;
QSettings settings; QSettings settings;
@ -56,12 +59,15 @@ protected:
QStringList EEPROMSettings; QStringList EEPROMSettings;
QStringList userHistory; QStringList userHistory;
QSerialPortInfo printerinfo; QSerialPortInfo printerinfo;
QTextCursor terminalCursor;
void closeEvent(QCloseEvent *event);
bool eventFilter(QObject *target, QEvent *event); bool eventFilter(QObject *target, QEvent *event);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
QString lastDir;
bool opened; bool opened;
bool firstrun; bool firstrun;
bool autolock; bool autolock;
@ -72,6 +78,8 @@ private:
bool sdprinting; bool sdprinting;
bool echo; bool echo;
bool chekingSDStatus; bool chekingSDStatus;
bool trayIconEnabled;
bool supressWait;
int firmware; int firmware;
int feedrate; int feedrate;
int extruderFeedrate; int extruderFeedrate;
@ -82,6 +90,7 @@ private slots:
void open(); void open();
void serialconnect(); void serialconnect();
void serialupdate(); void serialupdate();
void updatesettings();
void readSerial(QByteArray data); void readSerial(QByteArray data);
void printMsg(QString text); void printMsg(QString text);
void checkStatus(); void checkStatus();
@ -97,10 +106,12 @@ private slots:
void EEPROMSettingReceived(QString esetting); void EEPROMSettingReceived(QString esetting);
void receivedError(); void receivedError();
void receivedSDDone(); void receivedSDDone();
void receivedNotSDPrinting();
void parseFile(QString filename); void parseFile(QString filename);
void recentClicked(); void recentClicked();
void updateFileProgress(FileProgress); void updateFileProgress(FileProgress);
void baudrateSetFailed(int b); void baudrateSetFailed(int b);
void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
void xplus(); void xplus();
void yplus(); void yplus();
@ -148,8 +159,6 @@ private slots:
signals: signals:
void sdReady(); void sdReady();
void eepromReady();
void receivedData(QByteArray);
void startedReadingEEPROM(); void startedReadingEEPROM();
void openPort(QSerialPortInfo i); void openPort(QSerialPortInfo i);

View File

@ -51,10 +51,17 @@
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="editable">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="baudbox"/> <widget class="QComboBox" name="baudbox">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QPushButton" name="portsBtn"> <widget class="QPushButton" name="portsBtn">
@ -269,6 +276,9 @@
<property name="text"> <property name="text">
<string>100</string> <string>100</string>
</property> </property>
<property name="maxLength">
<number>3</number>
</property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
@ -310,6 +320,9 @@
<property name="text"> <property name="text">
<string>100</string> <string>100</string>
</property> </property>
<property name="maxLength">
<number>3</number>
</property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>

View File

@ -29,7 +29,7 @@ void Parser::parse(QByteArray data)
{ {
if(readingFiles) //SD files list reading mode if(readingFiles) //SD files list reading mode
{ {
if(!data.contains("End file list")) SDFilesList.append(data); if(!data.contains("End file list")) SDFilesList.append(data.remove(data.size()-2, 2));
else else
{ {
readingFiles = false; readingFiles = false;
@ -105,7 +105,7 @@ void Parser::parse(QByteArray data)
emit receivedSDUpdate(p); emit receivedSDUpdate(p);
} }
else if(data.startsWith("Not SD ")); else if(data.startsWith("Not SD ")) emit receivedNotSDPrinting();
else if(data.contains("Begin file list")) else if(data.contains("Begin file list"))
{ {
SDFilesList.clear(); SDFilesList.clear();

View File

@ -28,6 +28,7 @@ protected:
signals: signals:
void receivedTemperature(TemperatureReadings); void receivedTemperature(TemperatureReadings);
void receivedSDUpdate(SDProgress); void receivedSDUpdate(SDProgress);
void receivedNotSDPrinting();
void receivedEEPROMLine(QString); void receivedEEPROMLine(QString);
void recievingEEPROMDone(); void recievingEEPROMDone();
void receivedSDFilesList(QStringList); void receivedSDFilesList(QStringList);

View File

@ -1,8 +1,12 @@
/////////////////////////////////////////////////
//This file contains RepRaptor - specific stuff//
/////////////////////////////////////////////////
#ifndef REPRAPTOR_H #ifndef REPRAPTOR_H
#define REPRAPTOR_H #define REPRAPTOR_H
#ifndef REPRAPTOR_VERSION #ifndef REPRAPTOR_VERSION
#define REPRAPTOR_VERSION "0.3.6" #define REPRAPTOR_VERSION "0.3.9"
#endif #endif
namespace RepRaptor namespace RepRaptor
@ -20,6 +24,13 @@ namespace RepRaptor
OtherFirmware OtherFirmware
}; };
enum ErrorType
{
SerialPortError,
OpenFileError,
HardwareFailure
};
typedef struct typedef struct
{ {
int T, P; int T, P;

View File

@ -7,7 +7,13 @@ SDWindow::SDWindow(QStringList files, QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
ui->fileslist->setSelectionMode(QListView::SingleSelection);
if(!files.isEmpty())
{
ui->fileslist->addItems(files); ui->fileslist->addItems(files);
ui->fileslist->setCurrentItem(ui->fileslist->itemAt(0,0));
}
} }
SDWindow::~SDWindow() SDWindow::~SDWindow()
@ -17,11 +23,11 @@ SDWindow::~SDWindow()
void SDWindow::on_buttonBox_accepted() void SDWindow::on_buttonBox_accepted()
{ {
emit fileSelected(ui->fileslist->currentItem()->text()); if(ui->fileslist->count() > 0) emit fileSelected(ui->fileslist->currentItem()->text());
} }
void SDWindow::on_fileslist_doubleClicked(const QModelIndex &index) void SDWindow::on_fileslist_doubleClicked(const QModelIndex &)
{ {
emit fileSelected(ui->fileslist->currentItem()->text()); if(ui->fileslist->count() > 0) emit fileSelected(ui->fileslist->currentItem()->text());
this->close(); this->close();
} }

View File

@ -21,7 +21,7 @@ signals:
private slots: private slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();
void on_fileslist_doubleClicked(const QModelIndex &index); void on_fileslist_doubleClicked(const QModelIndex &);
private: private:
Ui::SDWindow *ui; Ui::SDWindow *ui;

View File

@ -6,10 +6,16 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>249</width> <width>274</width>
<height>246</height> <height>302</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Print from SD</string> <string>Print from SD</string>
</property> </property>
@ -21,7 +27,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Print file:</string> <string>Select file:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -40,8 +46,14 @@
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QListWidget" name="fileslist"> <widget class="QListWidget" name="fileslist">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoScroll"> <property name="autoScroll">
<bool>false</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -16,7 +16,7 @@ Sender::Sender(QObject *parent) : QObject(parent)
sendTimer = new QTimer(this); sendTimer = new QTimer(this);
//Fetch settings //Fetch settings
QSettings settings; QSettings settings(this);
sendTimer->setInterval(settings.value("core/senderinterval", 2).toInt()); sendTimer->setInterval(settings.value("core/senderinterval", 2).toInt());
sendingChecksum = settings.value("core/checksums", 0).toBool(); sendingChecksum = settings.value("core/checksums", 0).toBool();
dtr = settings.value("core/dtr", 1).toBool(); dtr = settings.value("core/dtr", 1).toBool();
@ -40,6 +40,7 @@ void Sender::sendNext()
{ {
if(printer->isWritable() && readyReceive) if(printer->isWritable() && readyReceive)
{ {
//Checksums
if(sendingChecksum && resending) if(sendingChecksum && resending)
{ {
if(resendNum < sentCommands.size()) if(resendNum < sentCommands.size())

View File

@ -23,11 +23,11 @@ public:
protected: protected:
QSerialPort *printer; QSerialPort *printer;
QTimer *sendTimer; QTimer *sendTimer;
unsigned int currentLine; long int currentLine;
unsigned int totalLineNum; long int totalLineNum;
unsigned int resendNum; long int resendNum;
unsigned int baudrate; long int baudrate;
int flowcontrol; long int flowcontrol;
bool paused; bool paused;
bool sending; bool sending;
bool dtr; bool dtr;

View File

@ -6,15 +6,16 @@ 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!
settings.setParent(this);
ui->flowcontrolbox->setCurrentIndex(settings.value("core/flowcontrol", 0).toInt()); ui->flowcontrolbox->setCurrentIndex(settings.value("core/flowcontrol", 0).toInt());
ui->senderbox->setValue(settings.value("core/senderinterval", 2).toInt()); ui->senderbox->setValue(settings.value("core/senderinterval", 2).toInt());
ui->echobox->setChecked(settings.value("core/echo", 0).toBool()); ui->traybox->setChecked(settings.value("core/trayiconenabled", 1).toBool());
ui->statusbox->setValue(settings.value("core/statusinterval", 2000).toInt()); ui->statusbox->setValue(settings.value("core/statusinterval", 2000).toInt());
ui->bedxbox->setValue(settings.value("printer/bedx", 200).toInt()); ui->bedxbox->setValue(settings.value("printer/bedx", 200).toInt());
ui->bedybox->setValue(settings.value("printer/bedy", 200).toInt()); ui->bedybox->setValue(settings.value("printer/bedy", 200).toInt());
@ -24,6 +25,8 @@ SettingsWindow::SettingsWindow(QWidget *parent) :
ui->checksumbox->setChecked(settings.value("core/checksums", 0).toBool()); ui->checksumbox->setChecked(settings.value("core/checksums", 0).toBool());
ui->sdbox->setChecked(settings.value("core/checksdstatus", 1).toBool()); ui->sdbox->setChecked(settings.value("core/checksdstatus", 1).toBool());
ui->dtrbox->setChecked(settings.value("core/dtr", 1).toBool()); ui->dtrbox->setChecked(settings.value("core/dtr", 1).toBool());
ui->supresswaitbox->setChecked(settings.value("user/supresswait").toBool());
ui->bufferbox->setValue(settings.value("core/logbuffersize", 1000).toInt());
ui->firmwarecombo->addItem("Marlin"); //0 ui->firmwarecombo->addItem("Marlin"); //0
ui->firmwarecombo->addItem("Repetier"); //1 ui->firmwarecombo->addItem("Repetier"); //1
@ -47,16 +50,20 @@ SettingsWindow::~SettingsWindow()
void SettingsWindow::on_buttonBox_accepted() void SettingsWindow::on_buttonBox_accepted()
{ {
settings.setValue("core/flowcontrol", ui->flowcontrolbox->currentIndex()); settings.setValue("core/flowcontrol", ui->flowcontrolbox->currentIndex());
settings.setValue("core/trayiconenabled", ui->traybox->isChecked());
settings.setValue("core/senderinterval", ui->senderbox->value()); settings.setValue("core/senderinterval", ui->senderbox->value());
settings.setValue("core/statusinterval", ui->statusbox->value()); settings.setValue("core/statusinterval", ui->statusbox->value());
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("printer/feedrate", ui->feedrateBox->value()); settings.setValue("printer/feedrate", ui->feedrateBox->value());
settings.setValue("printer/extruderfeedrate", ui->extruderFeedrateBox->value()); settings.setValue("printer/extruderfeedrate", ui->extruderFeedrateBox->value());
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()); settings.setValue("core/checksdstatus", ui->sdbox->isChecked());
settings.setValue("core/dtr", ui->dtrbox->isChecked()); settings.setValue("core/dtr", ui->dtrbox->isChecked());
settings.setValue("printer/firmware", ui->firmwarecombo->currentIndex()); settings.setValue("printer/firmware", ui->firmwarecombo->currentIndex());
settings.setValue("user/supresswait", ui->supresswaitbox->isChecked());
settings.setValue("core/logbuffersize", ui->bufferbox->value());
emit updatesettings();
} }

View File

@ -27,6 +27,10 @@ private slots:
private: private:
Ui::SettingsWindow *ui; Ui::SettingsWindow *ui;
signals:
void updatesettings();
}; };
#endif // SETTINGSWINDOW_H #endif // SETTINGSWINDOW_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>483</width> <width>603</width>
<height>341</height> <height>491</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -18,25 +18,28 @@
<normaloff>:/icons/settings.png</normaloff>:/icons/settings.png</iconset> <normaloff>:/icons/settings.png</normaloff>:/icons/settings.png</iconset>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="minimumSize">
<size>
<width>200</width>
<height>400</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_general">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="internalGroup"> <widget class="QGroupBox" name="internalGroup">
<property name="title"> <property name="title">
<string>Internal</string> <string>Internal</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="echobox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Show every sent command in console</string>
</property>
<property name="text">
<string>Echo commands</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="senderbox"> <widget class="QDoubleSpinBox" name="senderbox">
<property name="toolTip"> <property name="toolTip">
@ -62,20 +65,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>ms</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QSpinBox" name="statusbox"> <widget class="QSpinBox" name="statusbox">
<property name="toolTip"> <property name="toolTip">
@ -92,35 +81,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="2" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>ms</string> <string>Status</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="3"> <item row="10" column="0">
<widget class="QCheckBox" name="lockbox">
<property name="text">
<string>Lock controls when printing</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Sender</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QCheckBox" name="sdbox">
<property name="text">
<string>Check SD printing status</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="checksumbox"> <widget class="QCheckBox" name="checksumbox">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -130,6 +98,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0" colspan="3">
<widget class="QCheckBox" name="sdbox">
<property name="text">
<string>Check SD printing status</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3"> <item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="minimumSize"> <property name="minimumSize">
@ -152,28 +127,115 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="dtrbox">
<property name="text">
<string>DTR</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="label_11">
<property name="text"> <property name="text">
<string>Flow control</string> <string>Flow control</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" colspan="2"> <item row="6" column="0">
<widget class="QComboBox" name="flowcontrolbox"/> <widget class="QCheckBox" name="dtrbox">
<property name="text">
<string>DTR</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>ms</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>ms</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Sender</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QComboBox" name="flowcontrolbox">
<property name="toolTip">
<string/>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3">
<widget class="QCheckBox" name="lockbox">
<property name="text">
<string>Lock controls when printing</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="traybox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Show tray icon</string>
</property>
<property name="text">
<string>Tray icon</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QCheckBox" name="supresswaitbox">
<property name="text">
<string>Supress &quot;wait&quot; responce</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Log buffer</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="bufferbox">
<property name="maximum">
<number>100000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="1"> </layout>
</widget>
<widget class="QWidget" name="tab_network">
<attribute name="title">
<string>Network</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_hardware">
<attribute name="title">
<string>Hardware</string>
</attribute>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>249</width>
<height>171</height>
</rect>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -237,6 +299,9 @@
</item> </item>
<item row="2" column="1" colspan="2"> <item row="2" column="1" colspan="2">
<widget class="QSpinBox" name="feedrateBox"> <widget class="QSpinBox" name="feedrateBox">
<property name="toolTip">
<string>Speed of axis movements (only affect buttons)</string>
</property>
<property name="maximum"> <property name="maximum">
<number>99999</number> <number>99999</number>
</property> </property>
@ -255,6 +320,9 @@ feedrate</string>
</item> </item>
<item row="3" column="1" colspan="2"> <item row="3" column="1" colspan="2">
<widget class="QSpinBox" name="extruderFeedrateBox"> <widget class="QSpinBox" name="extruderFeedrateBox">
<property name="toolTip">
<string>Extruder speed (only affect buttons)</string>
</property>
<property name="maximum"> <property name="maximum">
<number>99999</number> <number>99999</number>
</property> </property>
@ -262,8 +330,10 @@ feedrate</string>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget>
</widget>
</item> </item>
<item row="2" column="1"> <item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>