Changeset View
Changeset View
Standalone View
Standalone View
testclient/mainwindow.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 42 | { | |||
---|---|---|---|---|---|
49 | 49 | | |||
50 | connect(core, &AtCore::atcoreMessage, logWidget, &LogWidget::appendLog); | 50 | connect(core, &AtCore::atcoreMessage, logWidget, &LogWidget::appendLog); | ||
51 | logWidget->appendLog(tr("Attempting to locate Serial Ports")); | 51 | logWidget->appendLog(tr("Attempting to locate Serial Ports")); | ||
52 | core->setSerialTimerInterval(1000); | 52 | core->setSerialTimerInterval(1000); | ||
53 | 53 | | |||
54 | connect(core, &AtCore::stateChanged, this, &MainWindow::printerStateChanged); | 54 | connect(core, &AtCore::stateChanged, this, &MainWindow::printerStateChanged); | ||
55 | connect(core, &AtCore::portsChanged, this, &MainWindow::locateSerialPort); | 55 | connect(core, &AtCore::portsChanged, this, &MainWindow::locateSerialPort); | ||
56 | connect(core, &AtCore::sdCardFileListChanged, sdWidget, &SdWidget::updateFilelist); | 56 | connect(core, &AtCore::sdCardFileListChanged, sdWidget, &SdWidget::updateFilelist); | ||
57 | connect(sdWidget, &SdWidget::writeSdFile, this, &MainWindow::writeToSd); | ||||
57 | } | 58 | } | ||
58 | 59 | | |||
59 | void MainWindow::initMenu() | 60 | void MainWindow::initMenu() | ||
60 | { | 61 | { | ||
61 | QMenu *menuFile = new QMenu(tr("File")); | 62 | QMenu *menuFile = new QMenu(tr("File")); | ||
62 | QAction *actionQuit = new QAction(style()->standardIcon(QStyle::SP_DialogCloseButton), tr("Quit")); | 63 | QAction *actionQuit = new QAction(style()->standardIcon(QStyle::SP_DialogCloseButton), tr("Quit")); | ||
63 | connect(actionQuit, &QAction::triggered, this, &MainWindow::close); | 64 | connect(actionQuit, &QAction::triggered, this, &MainWindow::close); | ||
64 | menuFile->addAction(actionQuit); | 65 | menuFile->addAction(actionQuit); | ||
▲ Show 20 Lines • Show All 514 Lines • ▼ Show 20 Line(s) | 573 | { | |||
579 | if (!disabled) { | 580 | if (!disabled) { | ||
580 | temperatureWidget->updateExtruderCount(core->extruderCount()); | 581 | temperatureWidget->updateExtruderCount(core->extruderCount()); | ||
581 | printWidget->updateFanCount(fanCount); | 582 | printWidget->updateFanCount(fanCount); | ||
582 | } else { | 583 | } else { | ||
583 | printWidget->setPrintText(tr("Print File")); | 584 | printWidget->setPrintText(tr("Print File")); | ||
584 | statusWidget->showPrintArea(false); | 585 | statusWidget->showPrintArea(false); | ||
585 | } | 586 | } | ||
586 | } | 587 | } | ||
588 | | ||||
589 | void MainWindow::writeToSd() | ||||
590 | { | ||||
591 | static QString filter = tr("GCode Files(*.gco *.gcode)"); | ||||
592 | QString fileName = QFileDialog::getOpenFileName( | ||||
593 | this | ||||
594 | , tr("Write file to SD") | ||||
595 | , QDir::homePath() | ||||
596 | , tr("All Files(*.*);;GCode Files(*.gco *.gcode)") | ||||
597 | , &filter | ||||
598 | ); | ||||
599 | | ||||
600 | if (!fileName.isEmpty()) { | ||||
patrickelectric: check if file exist | |||||
601 | QProgressDialog *dialog = new QProgressDialog(); | ||||
602 | dialog->setLabelText(tr("Writing to SD...")); | ||||
603 | dialog->setModal(true); | ||||
604 | connect(core, &AtCore::sdWriteProgressChanged, dialog, &QProgressDialog::setValue); | ||||
605 | connect(dialog, &QProgressDialog::canceled, this, [this] { | ||||
606 | core->setState(AtCore::STOP); | ||||
607 | }); | ||||
608 | connect(core, &AtCore::writeFiletoSd, dialog, &QProgressDialog::exec); | ||||
609 | if (!core->writeFiletoSd(fileName)) { | ||||
610 | QMessageBox::warning(this, tr("Write to Sd"), tr("Writing FAILED")); | ||||
611 | dialog->close(); | ||||
tcanabrava: wait, what? | |||||
612 | core->setState(AtCore::IDLE); | ||||
613 | } | ||||
patrickelectric: unnecessary | |||||
614 | } | ||||
615 | } |
check if file exist