Changeset View
Changeset View
Standalone View
Standalone View
testclient/mainwindow.cpp
Show All 18 Lines | 1 | /* AtCore Test Client | |||
---|---|---|---|---|---|
19 | 19 | | |||
20 | You should have received a copy of the GNU General Public License | 20 | You should have received a copy of the GNU General Public License | ||
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | */ | 22 | */ | ||
23 | #include <QSerialPortInfo> | 23 | #include <QSerialPortInfo> | ||
24 | #include <QMessageBox> | 24 | #include <QMessageBox> | ||
25 | #include <QFileDialog> | 25 | #include <QFileDialog> | ||
26 | #include <QTextStream> | 26 | #include <QTextStream> | ||
27 | #include <QTimer> | ||||
27 | #include <QLoggingCategory> | 28 | #include <QLoggingCategory> | ||
28 | 29 | | |||
29 | #include "mainwindow.h" | 30 | #include "mainwindow.h" | ||
30 | #include "seriallayer.h" | 31 | #include "seriallayer.h" | ||
31 | #include "gcodecommands.h" | 32 | #include "gcodecommands.h" | ||
32 | #include "about.h" | 33 | #include "about.h" | ||
33 | 34 | | |||
34 | Q_LOGGING_CATEGORY(TESTCLIENT_MAINWINDOW, "org.kde.atelier.core") | 35 | Q_LOGGING_CATEGORY(TESTCLIENT_MAINWINDOW, "org.kde.atelier.core") | ||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Line(s) | 216 | { | |||
240 | comboPlugin->addItems(core->availableFirmwarePlugins()); | 241 | comboPlugin->addItems(core->availableFirmwarePlugins()); | ||
241 | connect(comboPlugin, &QComboBox::currentTextChanged, this, &MainWindow::pluginCBChanged); | 242 | connect(comboPlugin, &QComboBox::currentTextChanged, this, &MainWindow::pluginCBChanged); | ||
242 | 243 | | |||
243 | hBoxLayout = new QHBoxLayout; | 244 | hBoxLayout = new QHBoxLayout; | ||
244 | hBoxLayout->addWidget(newLabel); | 245 | hBoxLayout->addWidget(newLabel); | ||
245 | hBoxLayout->addWidget(comboPlugin, 75); | 246 | hBoxLayout->addWidget(comboPlugin, 75); | ||
246 | mainLayout->addLayout(hBoxLayout); | 247 | mainLayout->addLayout(hBoxLayout); | ||
247 | 248 | | |||
249 | cbReset = new QCheckBox(tr("Attempt to stop Reset on connect")); | ||||
250 | cbReset->setHidden(true); | ||||
251 | mainLayout->addWidget(cbReset); | ||||
252 | | ||||
253 | connect(comboPlugin, &QComboBox::currentTextChanged, this, [this](const QString & currentText) { | ||||
254 | cbReset->setHidden(currentText == tr("Autodetect")); | ||||
255 | }); | ||||
256 | | ||||
248 | buttonConnect = new QPushButton(tr("Connect")); | 257 | buttonConnect = new QPushButton(tr("Connect")); | ||
249 | connect(buttonConnect, &QPushButton::clicked, this, &MainWindow::connectPBClicked); | 258 | connect(buttonConnect, &QPushButton::clicked, this, &MainWindow::connectPBClicked); | ||
tcanabrava: cbReset->setHidden(currentText == tr("Autodetect")) | |||||
250 | mainLayout->addWidget(buttonConnect); | 259 | mainLayout->addWidget(buttonConnect); | ||
251 | 260 | | |||
252 | auto *dockContents = new QWidget; | 261 | auto *dockContents = new QWidget; | ||
253 | dockContents->setLayout(mainLayout); | 262 | dockContents->setLayout(mainLayout); | ||
254 | 263 | | |||
255 | connectDock = new QDockWidget(tr("Connect"), this); | 264 | connectDock = new QDockWidget(tr("Connect"), this); | ||
256 | connectDock->setWidget(dockContents); | 265 | connectDock->setWidget(dockContents); | ||
257 | 266 | | |||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Line(s) | 416 | if (! logWidget->endsWith(portError)) { | |||
408 | logWidget->appendLog(portError); | 417 | logWidget->appendLog(portError); | ||
409 | } | 418 | } | ||
410 | } | 419 | } | ||
411 | } | 420 | } | ||
412 | 421 | | |||
413 | void MainWindow::connectPBClicked() | 422 | void MainWindow::connectPBClicked() | ||
414 | { | 423 | { | ||
415 | if (core->state() == AtCore::DISCONNECTED) { | 424 | if (core->state() == AtCore::DISCONNECTED) { | ||
416 | if (core->initSerial(comboPort->currentText(), comboBAUD->currentText().toInt())) { | 425 | if (core->initSerial(comboPort->currentText(), comboBAUD->currentText().toInt(), cbReset->isChecked())) { | ||
417 | connect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | 426 | connect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | ||
418 | connect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | 427 | connect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | ||
419 | buttonConnect->setText(tr("Disconnect")); | 428 | buttonConnect->setText(tr("Disconnect")); | ||
420 | logWidget->appendLog(tr("Serial connected")); | 429 | logWidget->appendLog(tr("Serial connected")); | ||
421 | if (!comboPlugin->currentText().contains(tr("Autodetect"))) { | 430 | if (!comboPlugin->currentText().contains(tr("Autodetect"))) { | ||
422 | core->loadFirmwarePlugin(comboPlugin->currentText()); | 431 | core->loadFirmwarePlugin(comboPlugin->currentText()); | ||
432 | if (cbReset->isChecked()) { | ||||
433 | //Wait a few seconds after connect to avoid the normal errors | ||||
434 | QTimer::singleShot(5000, core, &AtCore::sdCardPrintStatus); | ||||
435 | } | ||||
423 | } | 436 | } | ||
424 | } | 437 | } | ||
425 | } else { | 438 | } else { | ||
426 | disconnect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | 439 | disconnect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog); | ||
427 | disconnect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | 440 | disconnect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); | ||
428 | core->closeConnection(); | 441 | core->closeConnection(); | ||
429 | core->setState(AtCore::DISCONNECTED); | 442 | core->setState(AtCore::DISCONNECTED); | ||
430 | logWidget->appendLog(tr("Disconnected")); | 443 | logWidget->appendLog(tr("Disconnected")); | ||
▲ Show 20 Lines • Show All 140 Lines • Show Last 20 Lines |
cbReset->setHidden(currentText == tr("Autodetect"))