Changeset View
Changeset View
Standalone View
Standalone View
testclient/mainwindow.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 41 | { | |||
---|---|---|---|---|---|
48 | 48 | | |||
49 | connect(core, &AtCore::atcoreMessage, logWidget, &LogWidget::appendLog); | 49 | connect(core, &AtCore::atcoreMessage, logWidget, &LogWidget::appendLog); | ||
50 | logWidget->appendLog(tr("Attempting to locate Serial Ports")); | 50 | logWidget->appendLog(tr("Attempting to locate Serial Ports")); | ||
51 | core->setSerialTimerInterval(1000); | 51 | core->setSerialTimerInterval(1000); | ||
52 | 52 | | |||
53 | connect(core, &AtCore::stateChanged, this, &MainWindow::printerStateChanged); | 53 | connect(core, &AtCore::stateChanged, this, &MainWindow::printerStateChanged); | ||
54 | connect(core, &AtCore::portsChanged, this, &MainWindow::locateSerialPort); | 54 | connect(core, &AtCore::portsChanged, this, &MainWindow::locateSerialPort); | ||
55 | connect(core, &AtCore::sdCardFileListChanged, sdWidget, &SdWidget::updateFilelist); | 55 | connect(core, &AtCore::sdCardFileListChanged, sdWidget, &SdWidget::updateFilelist); | ||
56 | connect(sdWidget, &SdWidget::writeSdFile, this, &MainWindow::writeToSd); | ||||
56 | } | 57 | } | ||
57 | 58 | | |||
58 | void MainWindow::initMenu() | 59 | void MainWindow::initMenu() | ||
59 | { | 60 | { | ||
60 | QMenu *menuFile = new QMenu(tr("File")); | 61 | QMenu *menuFile = new QMenu(tr("File")); | ||
61 | QAction *actionQuit = new QAction(style()->standardIcon(QStyle::SP_DialogCloseButton), tr("Quit")); | 62 | QAction *actionQuit = new QAction(style()->standardIcon(QStyle::SP_DialogCloseButton), tr("Quit")); | ||
62 | connect(actionQuit, &QAction::triggered, this, &MainWindow::close); | 63 | connect(actionQuit, &QAction::triggered, this, &MainWindow::close); | ||
63 | menuFile->addAction(actionQuit); | 64 | menuFile->addAction(actionQuit); | ||
▲ Show 20 Lines • Show All 499 Lines • ▼ Show 20 Line(s) | 560 | { | |||
563 | printDock->widget()->setDisabled(disabled); | 564 | printDock->widget()->setDisabled(disabled); | ||
564 | sdDock->widget()->setDisabled(disabled); | 565 | sdDock->widget()->setDisabled(disabled); | ||
565 | 566 | | |||
566 | if (!disabled) { | 567 | if (!disabled) { | ||
567 | temperatureWidget->updateExtruderCount(core->extruderCount()); | 568 | temperatureWidget->updateExtruderCount(core->extruderCount()); | ||
568 | printWidget->updateFanCount(fanCount); | 569 | printWidget->updateFanCount(fanCount); | ||
569 | } | 570 | } | ||
570 | } | 571 | } | ||
572 | | ||||
573 | void MainWindow::writeToSd() | ||||
574 | { | ||||
575 | static QString filter = tr("GCode Files(*.gco *.gcode)"); | ||||
576 | QString fileName = QFileDialog::getOpenFileName( | ||||
577 | this | ||||
578 | , tr("Write file to SD") | ||||
579 | , QDir::homePath() | ||||
580 | , tr("All Files(*.*);;GCode Files(*.gco *.gcode)") | ||||
581 | , &filter | ||||
582 | ); | ||||
583 | | ||||
584 | if (!fileName.isEmpty()) { | ||||
patrickelectric: check if file exist | |||||
585 | QProgressDialog *dialog = new QProgressDialog(); | ||||
586 | dialog->setLabelText(tr("Writing to SD...")); | ||||
587 | dialog->setModal(true); | ||||
588 | connect(core, &AtCore::sdWriteProgressChanged, dialog, &QProgressDialog::setValue); | ||||
589 | connect(dialog, &QProgressDialog::canceled, this, [this] { | ||||
590 | core->setState(AtCore::STOP); | ||||
591 | }); | ||||
592 | connect(core, &AtCore::writeFiletoSd, dialog, &QProgressDialog::exec); | ||||
593 | if (!core->writeFiletoSd(fileName)) { | ||||
594 | QMessageBox::warning(this, tr("Write to Sd"), tr("Writing FAILED")); | ||||
595 | dialog->close(); | ||||
tcanabrava: wait, what? | |||||
596 | core->setState(AtCore::IDLE); | ||||
597 | return; | ||||
patrickelectric: unnecessary | |||||
598 | } | ||||
599 | } | ||||
600 | } |
check if file exist