Changeset View
Changeset View
Standalone View
Standalone View
testclient/mainwindow.cpp
1 | /* AtCore Test Client | 1 | /* AtCore Test Client | ||
---|---|---|---|---|---|
2 | Copyright (C) <2016> | 2 | Copyright (C) <2016 - 2018> | ||
3 | 3 | | |||
4 | Authors: | 4 | Authors: | ||
5 | Patrick José Pereira <patrickjp@kde.org> | 5 | Patrick José Pereira <patrickjp@kde.org> | ||
6 | Lays Rodrigues <lays.rodrigues@kde.org> | 6 | Lays Rodrigues <lays.rodrigues@kde.org> | ||
7 | Chris Rizzitello <rizzitello@kde.org> | 7 | Chris Rizzitello <rizzitello@kde.org> | ||
8 | Tomaz Canabrava <tcanabrava@kde.org> | 8 | Tomaz Canabrava <tcanabrava@kde.org> | ||
9 | 9 | | |||
10 | This program is free software: you can redistribute it and/or modify | 10 | This program is free software: you can redistribute it and/or modify | ||
▲ Show 20 Lines • Show All 409 Lines • ▼ Show 20 Line(s) | |||||
420 | } | 420 | } | ||
421 | 421 | | |||
422 | void MainWindow::connectPBClicked() | 422 | void MainWindow::connectPBClicked() | ||
423 | { | 423 | { | ||
424 | if (core->state() == AtCore::DISCONNECTED) { | 424 | if (core->state() == AtCore::DISCONNECTED) { | ||
425 | if (core->initSerial(comboPort->currentText(), comboBAUD->currentText().toInt(), cbReset->isChecked())) { | 425 | if (core->initSerial(comboPort->currentText(), comboBAUD->currentText().toInt(), cbReset->isChecked())) { | ||
426 | connect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | 426 | connect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | ||
427 | connect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | 427 | connect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | ||
428 | buttonConnect->setText(tr("Disconnect")); | | |||
429 | logWidget->appendLog(tr("Serial connected")); | 428 | logWidget->appendLog(tr("Serial connected")); | ||
430 | if (!comboPlugin->currentText().contains(tr("Autodetect"))) { | 429 | if (!comboPlugin->currentText().contains(tr("Autodetect"))) { | ||
431 | core->loadFirmwarePlugin(comboPlugin->currentText()); | 430 | core->loadFirmwarePlugin(comboPlugin->currentText()); | ||
432 | if (cbReset->isChecked()) { | 431 | if (cbReset->isChecked()) { | ||
433 | //Wait a few seconds after connect to avoid the normal errors | 432 | //Wait a few seconds after connect to avoid the normal errors | ||
434 | QTimer::singleShot(5000, core, &AtCore::sdCardPrintStatus); | 433 | QTimer::singleShot(5000, core, &AtCore::sdCardPrintStatus); | ||
435 | } | 434 | } | ||
436 | } | 435 | } | ||
437 | } | 436 | } | ||
438 | } else { | 437 | } else { | ||
439 | disconnect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | 438 | disconnect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | ||
440 | disconnect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | 439 | disconnect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | ||
441 | core->closeConnection(); | 440 | core->closeConnection(); | ||
442 | core->setState(AtCore::DISCONNECTED); | 441 | core->setState(AtCore::DISCONNECTED); | ||
443 | logWidget->appendLog(tr("Disconnected")); | 442 | logWidget->appendLog(tr("Disconnected")); | ||
444 | buttonConnect->setText(tr("Connect")); | | |||
445 | } | 443 | } | ||
446 | } | 444 | } | ||
447 | 445 | | |||
448 | void MainWindow::printPBClicked() | 446 | void MainWindow::printPBClicked() | ||
449 | { | 447 | { | ||
450 | QString fileName; | 448 | QString fileName; | ||
451 | switch (core->state()) { | 449 | switch (core->state()) { | ||
452 | 450 | | |||
Show All 39 Lines | 484 | { | |||
492 | } | 490 | } | ||
493 | } | 491 | } | ||
494 | 492 | | |||
495 | void MainWindow::printerStateChanged(AtCore::STATES state) | 493 | void MainWindow::printerStateChanged(AtCore::STATES state) | ||
496 | { | 494 | { | ||
497 | QString stateString; | 495 | QString stateString; | ||
498 | switch (state) { | 496 | switch (state) { | ||
499 | case AtCore::IDLE: | 497 | case AtCore::IDLE: | ||
498 | buttonConnect->setText(tr("Disconnect")); | ||||
500 | printWidget->setPrintText(tr("Print File")); | 499 | printWidget->setPrintText(tr("Print File")); | ||
501 | stateString = tr("Connected to ") + core->connectedPort(); | 500 | stateString = tr("Connected to ") + core->connectedPort(); | ||
502 | sdDock->setVisible(core->firmwarePlugin()->isSdSupported()); | 501 | sdDock->setVisible(core->firmwarePlugin()->isSdSupported()); | ||
503 | break; | 502 | break; | ||
504 | 503 | | |||
505 | case AtCore::STARTPRINT: | 504 | case AtCore::STARTPRINT: | ||
506 | stateString = tr("START PRINT"); | 505 | stateString = tr("START PRINT"); | ||
507 | printWidget->setPrintText(tr("Pause Print")); | 506 | printWidget->setPrintText(tr("Pause Print")); | ||
Show All 13 Lines | |||||
521 | 520 | | |||
522 | case AtCore::BUSY: | 521 | case AtCore::BUSY: | ||
523 | stateString = tr("Printing"); | 522 | stateString = tr("Printing"); | ||
524 | printWidget->setPrintText(tr("Pause Print")); | 523 | printWidget->setPrintText(tr("Pause Print")); | ||
525 | break; | 524 | break; | ||
526 | 525 | | |||
527 | case AtCore::DISCONNECTED: | 526 | case AtCore::DISCONNECTED: | ||
528 | stateString = QStringLiteral("Not Connected"); | 527 | stateString = QStringLiteral("Not Connected"); | ||
528 | buttonConnect->setText(tr("Connect")); | ||||
529 | setDangeriousDocksDisabled(true); | 529 | setDangeriousDocksDisabled(true); | ||
530 | break; | 530 | break; | ||
531 | 531 | | |||
532 | case AtCore::CONNECTING: | 532 | case AtCore::CONNECTING: | ||
533 | stateString = QStringLiteral("Connecting"); | 533 | stateString = QStringLiteral("Connecting"); | ||
534 | setDangeriousDocksDisabled(false); | 534 | setDangeriousDocksDisabled(false); | ||
535 | break; | 535 | break; | ||
536 | 536 | | |||
Show All 37 Lines | 572 | { | |||
574 | moveDock->widget()->setDisabled(disabled); | 574 | moveDock->widget()->setDisabled(disabled); | ||
575 | tempControlsDock->widget()->setDisabled(disabled); | 575 | tempControlsDock->widget()->setDisabled(disabled); | ||
576 | printDock->widget()->setDisabled(disabled); | 576 | printDock->widget()->setDisabled(disabled); | ||
577 | sdDock->widget()->setDisabled(disabled); | 577 | sdDock->widget()->setDisabled(disabled); | ||
578 | 578 | | |||
579 | if (!disabled) { | 579 | if (!disabled) { | ||
580 | temperatureWidget->updateExtruderCount(core->extruderCount()); | 580 | temperatureWidget->updateExtruderCount(core->extruderCount()); | ||
581 | printWidget->updateFanCount(fanCount); | 581 | printWidget->updateFanCount(fanCount); | ||
582 | } else { | ||||
583 | printWidget->setPrintText(tr("Print File")); | ||||
584 | statusWidget->showPrintArea(false); | ||||
582 | } | 585 | } | ||
583 | } | 586 | } |