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 400 Lines • ▼ Show 20 Line(s) | |||||
411 | } | 411 | } | ||
412 | 412 | | |||
413 | void MainWindow::connectPBClicked() | 413 | void MainWindow::connectPBClicked() | ||
414 | { | 414 | { | ||
415 | if (core->state() == AtCore::DISCONNECTED) { | 415 | if (core->state() == AtCore::DISCONNECTED) { | ||
416 | if (core->initSerial(comboPort->currentText(), comboBAUD->currentText().toInt())) { | 416 | if (core->initSerial(comboPort->currentText(), comboBAUD->currentText().toInt())) { | ||
417 | connect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | 417 | connect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | ||
418 | connect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | 418 | connect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | ||
419 | buttonConnect->setText(tr("Disconnect")); | | |||
420 | logWidget->appendLog(tr("Serial connected")); | 419 | logWidget->appendLog(tr("Serial connected")); | ||
421 | if (!comboPlugin->currentText().contains(tr("Autodetect"))) { | 420 | if (!comboPlugin->currentText().contains(tr("Autodetect"))) { | ||
422 | core->loadFirmwarePlugin(comboPlugin->currentText()); | 421 | core->loadFirmwarePlugin(comboPlugin->currentText()); | ||
423 | } | 422 | } | ||
424 | } | 423 | } | ||
425 | } else { | 424 | } else { | ||
426 | disconnect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | 425 | disconnect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | ||
427 | disconnect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | 426 | disconnect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | ||
428 | core->closeConnection(); | 427 | core->closeConnection(); | ||
429 | core->setState(AtCore::DISCONNECTED); | 428 | core->setState(AtCore::DISCONNECTED); | ||
430 | logWidget->appendLog(tr("Disconnected")); | 429 | logWidget->appendLog(tr("Disconnected")); | ||
431 | buttonConnect->setText(tr("Connect")); | | |||
432 | } | 430 | } | ||
433 | } | 431 | } | ||
434 | 432 | | |||
435 | void MainWindow::printPBClicked() | 433 | void MainWindow::printPBClicked() | ||
436 | { | 434 | { | ||
437 | QString fileName; | 435 | QString fileName; | ||
438 | switch (core->state()) { | 436 | switch (core->state()) { | ||
439 | 437 | | |||
Show All 39 Lines | 471 | { | |||
479 | } | 477 | } | ||
480 | } | 478 | } | ||
481 | 479 | | |||
482 | void MainWindow::printerStateChanged(AtCore::STATES state) | 480 | void MainWindow::printerStateChanged(AtCore::STATES state) | ||
483 | { | 481 | { | ||
484 | QString stateString; | 482 | QString stateString; | ||
485 | switch (state) { | 483 | switch (state) { | ||
486 | case AtCore::IDLE: | 484 | case AtCore::IDLE: | ||
485 | buttonConnect->setText(tr("Disconnect")); | ||||
487 | printWidget->setPrintText(tr("Print File")); | 486 | printWidget->setPrintText(tr("Print File")); | ||
488 | stateString = tr("Connected to ") + core->connectedPort(); | 487 | stateString = tr("Connected to ") + core->connectedPort(); | ||
489 | sdDock->setVisible(core->firmwarePlugin()->isSdSupported()); | 488 | sdDock->setVisible(core->firmwarePlugin()->isSdSupported()); | ||
490 | break; | 489 | break; | ||
491 | 490 | | |||
492 | case AtCore::STARTPRINT: | 491 | case AtCore::STARTPRINT: | ||
493 | stateString = tr("START PRINT"); | 492 | stateString = tr("START PRINT"); | ||
494 | printWidget->setPrintText(tr("Pause Print")); | 493 | printWidget->setPrintText(tr("Pause Print")); | ||
Show All 13 Lines | |||||
508 | 507 | | |||
509 | case AtCore::BUSY: | 508 | case AtCore::BUSY: | ||
510 | stateString = tr("Printing"); | 509 | stateString = tr("Printing"); | ||
511 | printWidget->setPrintText(tr("Pause Print")); | 510 | printWidget->setPrintText(tr("Pause Print")); | ||
512 | break; | 511 | break; | ||
513 | 512 | | |||
514 | case AtCore::DISCONNECTED: | 513 | case AtCore::DISCONNECTED: | ||
515 | stateString = QStringLiteral("Not Connected"); | 514 | stateString = QStringLiteral("Not Connected"); | ||
515 | buttonConnect->setText(tr("Connect")); | ||||
516 | setDangeriousDocksDisabled(true); | 516 | setDangeriousDocksDisabled(true); | ||
517 | break; | 517 | break; | ||
518 | 518 | | |||
519 | case AtCore::CONNECTING: | 519 | case AtCore::CONNECTING: | ||
520 | stateString = QStringLiteral("Connecting"); | 520 | stateString = QStringLiteral("Connecting"); | ||
521 | setDangeriousDocksDisabled(false); | 521 | setDangeriousDocksDisabled(false); | ||
522 | break; | 522 | break; | ||
523 | 523 | | |||
Show All 37 Lines | 559 | { | |||
561 | moveDock->widget()->setDisabled(disabled); | 561 | moveDock->widget()->setDisabled(disabled); | ||
562 | tempControlsDock->widget()->setDisabled(disabled); | 562 | tempControlsDock->widget()->setDisabled(disabled); | ||
563 | printDock->widget()->setDisabled(disabled); | 563 | printDock->widget()->setDisabled(disabled); | ||
564 | sdDock->widget()->setDisabled(disabled); | 564 | sdDock->widget()->setDisabled(disabled); | ||
565 | 565 | | |||
566 | if (!disabled) { | 566 | if (!disabled) { | ||
567 | temperatureWidget->updateExtruderCount(core->extruderCount()); | 567 | temperatureWidget->updateExtruderCount(core->extruderCount()); | ||
568 | printWidget->updateFanCount(fanCount); | 568 | printWidget->updateFanCount(fanCount); | ||
569 | } else { | ||||
570 | printWidget->setPrintText(tr("Print File")); | ||||
571 | statusWidget->showPrintArea(false); | ||||
569 | } | 572 | } | ||
570 | } | 573 | } |