Initial SD printing support
This commit is contained in:
parent
3fb77294f3
commit
8a43041ed6
@ -18,18 +18,21 @@ SOURCES += main.cpp\
|
|||||||
settingswindow.cpp \
|
settingswindow.cpp \
|
||||||
aboutwindow.cpp \
|
aboutwindow.cpp \
|
||||||
errorwindow.cpp \
|
errorwindow.cpp \
|
||||||
erroricon.cpp
|
erroricon.cpp \
|
||||||
|
sdwindow.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
settingswindow.h \
|
settingswindow.h \
|
||||||
aboutwindow.h \
|
aboutwindow.h \
|
||||||
errorwindow.h \
|
errorwindow.h \
|
||||||
erroricon.h
|
erroricon.h \
|
||||||
|
sdwindow.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
settingswindow.ui \
|
settingswindow.ui \
|
||||||
aboutwindow.ui \
|
aboutwindow.ui \
|
||||||
errorwindow.ui
|
errorwindow.ui \
|
||||||
|
sdwindow.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
graphics.qrc
|
graphics.qrc
|
||||||
|
|||||||
@ -36,6 +36,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
paused = false;
|
paused = false;
|
||||||
commandDone = false;
|
commandDone = false;
|
||||||
injectingCommand = false;
|
injectingCommand = false;
|
||||||
|
readingFiles = false;
|
||||||
userCommand = "";
|
userCommand = "";
|
||||||
currentLine = 0;
|
currentLine = 0;
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(&statusTimer, SIGNAL(timeout()), this, SLOT(checkStatus()));
|
connect(&statusTimer, SIGNAL(timeout()), this, SLOT(checkStatus()));
|
||||||
connect(&sendTimer, SIGNAL(timeout()), this, SLOT(sendNext()));
|
connect(&sendTimer, SIGNAL(timeout()), this, SLOT(sendNext()));
|
||||||
connect(&statusWatcher, SIGNAL(finished()), this, SLOT(updateStatus()));
|
connect(&statusWatcher, SIGNAL(finished()), this, SLOT(updateStatus()));
|
||||||
|
connect(this, SIGNAL(sdReady()), this, SLOT(initSDprinting()));
|
||||||
|
|
||||||
if(settings.value("core/statusinterval").toInt()) statusTimer.setInterval(settings.value("core/statusinterval").toInt());
|
if(settings.value("core/statusinterval").toInt()) statusTimer.setInterval(settings.value("core/statusinterval").toInt());
|
||||||
else statusTimer.setInterval(3000);
|
else statusTimer.setInterval(3000);
|
||||||
@ -354,6 +356,17 @@ void MainWindow::readSerial()
|
|||||||
if(printer.canReadLine())
|
if(printer.canReadLine())
|
||||||
{
|
{
|
||||||
QByteArray data = printer.readLine();
|
QByteArray data = printer.readLine();
|
||||||
|
|
||||||
|
if(readingFiles)
|
||||||
|
{
|
||||||
|
if(!data.contains("End file list")) sdFiles.append(data);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
readingFiles = false;
|
||||||
|
emit sdReady();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(data.startsWith("ok") || data.startsWith("wait")) commandDone = true; //Can send next command
|
if(data.startsWith("ok") || data.startsWith("wait")) commandDone = true; //Can send next command
|
||||||
else if(checkingTemperature && data.startsWith("T:"))
|
else if(checkingTemperature && data.startsWith("T:"))
|
||||||
{
|
{
|
||||||
@ -366,6 +379,11 @@ void MainWindow::readSerial()
|
|||||||
if(currentLine < 0) currentLine = 0;
|
if(currentLine < 0) currentLine = 0;
|
||||||
commandDone = true;
|
commandDone = true;
|
||||||
}
|
}
|
||||||
|
else if(data.contains("Begin file list"))
|
||||||
|
{
|
||||||
|
sdFiles.clear();
|
||||||
|
readingFiles = true; //start reading files from SD
|
||||||
|
}
|
||||||
|
|
||||||
printMsg(QString(data)); //echo
|
printMsg(QString(data)); //echo
|
||||||
}
|
}
|
||||||
@ -601,5 +619,19 @@ void MainWindow::updateStatus()
|
|||||||
|
|
||||||
void MainWindow::on_actionPrint_from_SD_triggered()
|
void MainWindow::on_actionPrint_from_SD_triggered()
|
||||||
{
|
{
|
||||||
//TODO
|
sendLine("M20");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::initSDprinting()
|
||||||
|
{
|
||||||
|
SDWindow sdwindow(sdFiles, this);
|
||||||
|
|
||||||
|
connect(&sdwindow, SIGNAL(fileSelected(QString)), this, SLOT(startSDprinting(QString)));
|
||||||
|
|
||||||
|
sdwindow.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::startSDprinting(QString file)
|
||||||
|
{
|
||||||
|
sendLine("M23 " + file.split(" ")[0] + '\nM24');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#include "settingswindow.h"
|
#include "settingswindow.h"
|
||||||
#include "aboutwindow.h"
|
#include "aboutwindow.h"
|
||||||
#include "errorwindow.h"
|
#include "errorwindow.h"
|
||||||
|
#include "sdwindow.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@ -43,6 +44,7 @@ public:
|
|||||||
QElapsedTimer sinceLastTemp;
|
QElapsedTimer sinceLastTemp;
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QStringList recentFiles;
|
QStringList recentFiles;
|
||||||
|
QStringList sdFiles;
|
||||||
QFutureWatcher<TemperatureReadings> statusWatcher;
|
QFutureWatcher<TemperatureReadings> statusWatcher;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -56,6 +58,7 @@ private:
|
|||||||
bool commandDone;
|
bool commandDone;
|
||||||
bool checkingTemperature;
|
bool checkingTemperature;
|
||||||
bool injectingCommand;
|
bool injectingCommand;
|
||||||
|
bool readingFiles;
|
||||||
int currentLine;
|
int currentLine;
|
||||||
QString userCommand;
|
QString userCommand;
|
||||||
|
|
||||||
@ -107,6 +110,11 @@ private slots:
|
|||||||
void on_actionPrint_from_SD_triggered();
|
void on_actionPrint_from_SD_triggered();
|
||||||
void updateStatus(TemperatureReadings r);
|
void updateStatus(TemperatureReadings r);
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
|
void initSDprinting();
|
||||||
|
void startSDprinting(QString file);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sdReady();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
@ -541,7 +541,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuTools">
|
<widget class="QMenu" name="menuTools">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Tools</string>
|
<string>Tools</string>
|
||||||
@ -592,7 +592,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionPrint_from_SD">
|
<action name="actionPrint_from_SD">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Print from SD...</string>
|
<string>Print from SD...</string>
|
||||||
|
|||||||
27
sdwindow.cpp
Normal file
27
sdwindow.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include "sdwindow.h"
|
||||||
|
#include "ui_sdwindow.h"
|
||||||
|
|
||||||
|
SDWindow::SDWindow(QStringList files, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::SDWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->fileslist->addItems(files);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDWindow::~SDWindow()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDWindow::on_buttonBox_accepted()
|
||||||
|
{
|
||||||
|
emit fileSelected(ui->fileslist->currentItem()->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDWindow::on_fileslist_doubleClicked(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
emit fileSelected(ui->fileslist->currentItem()->text());
|
||||||
|
this->close();
|
||||||
|
}
|
||||||
30
sdwindow.h
Normal file
30
sdwindow.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef SDWINDOW_H
|
||||||
|
#define SDWINDOW_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class SDWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SDWindow : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SDWindow(QStringList files, QWidget *parent = 0);
|
||||||
|
~SDWindow();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fileSelected(QString filename);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_buttonBox_accepted();
|
||||||
|
|
||||||
|
void on_fileslist_doubleClicked(const QModelIndex &index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::SDWindow *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SDWINDOW_H
|
||||||
77
sdwindow.ui
Normal file
77
sdwindow.ui
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SDWindow</class>
|
||||||
|
<widget class="QDialog" name="SDWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>199</width>
|
||||||
|
<height>246</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Print file:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
<property name="centerButtons">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QListWidget" name="fileslist"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>SDWindow</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>SDWindow</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
Loading…
x
Reference in New Issue
Block a user