diff --git a/src/core/atcore.h b/src/core/atcore.h --- a/src/core/atcore.h +++ b/src/core/atcore.h @@ -243,6 +243,17 @@ signals: + /** + * @brief Message emit from atcore these should be displayed to the user for debug. + * + * Possable Messages Are: + * - Waiting for firmware detect. + * - No Plugin found for (detected FW) + * - Failed to open device in Read / Write mode. + * @param msg: the message. + */ + void atcoreMessage(const QString &msg); + /** * @brief New number of extruders * @sa extruderCount(), setExtruderCount(int newCount) diff --git a/src/core/atcore.cpp b/src/core/atcore.cpp --- a/src/core/atcore.cpp +++ b/src/core/atcore.cpp @@ -82,18 +82,15 @@ d->tempTimer->setInterval(5000); d->tempTimer->setSingleShot(false); //Attempt to find our plugins + qCDebug(ATCORE_PLUGIN) << "Detecting Plugin path"; for (const auto &path : AtCoreDirectories::pluginDir) { - qCDebug(ATCORE_PLUGIN) << "Lookin for plugins in " << path; + qCDebug(ATCORE_PLUGIN) << "Checking: " << path; if (QDir(path).exists()) { d->pluginsDir = QDir(path); - qCDebug(ATCORE_PLUGIN) << "Valid path for plugins found !"; break; } } - if (!d->pluginsDir.exists()) { - qCritical() << "No valid path for plugin !"; - } - qCDebug(ATCORE_PLUGIN) << d->pluginsDir; + qCDebug(ATCORE_PLUGIN) << "PluginDir" << d->pluginsDir; findFirmwarePlugins(); setState(AtCore::DISCONNECTED); } @@ -132,7 +129,7 @@ void AtCore::findFirmware(const QByteArray &message) { if (state() == AtCore::DISCONNECTED) { - qWarning() << "Cant find firwmware, serial not connected !"; + qCWarning(ATCORE_CORE) << tr("Cant find firwmware, serial not connected!"); return; } @@ -150,9 +147,10 @@ return; } - qCDebug(ATCORE_CORE) << "Waiting for printer..."; + qCDebug(ATCORE_CORE) << "Waiting for firmware detect."; + emit atcoreMessage(tr("Waiting for firmware detect.")); } - qCDebug(ATCORE_CORE) << "Find Firmware Called" << message; + qCDebug(ATCORE_CORE) << "Find Firmware: " << message; if (!message.contains("FIRMWARE_NAME:")) { qCDebug(ATCORE_CORE) << "No firmware yet."; return; @@ -185,19 +183,18 @@ void AtCore::loadFirmwarePlugin(const QString &fwName) { - qCDebug(ATCORE_PLUGIN) << "Looking for Plugin:" << fwName; + qCDebug(ATCORE_CORE) << "Loading plugin: " << fwName; if (d->plugins.contains(fwName)) { d->pluginLoader.setFileName(d->plugins[fwName]); if (!d->pluginLoader.load()) { //Plugin was not loaded, Provide some debug info. - qCDebug(ATCORE_PLUGIN) << "Plugin Loading: Failed."; - qCDebug(ATCORE_PLUGIN) << d->pluginLoader.errorString(); + qCDebug(ATCORE_CORE) << "Plugin Loading: Failed."; + qCDebug(ATCORE_CORE) << d->pluginLoader.errorString(); setState(AtCore::CONNECTING); } else { //Plugin was loaded successfully. d->firmwarePlugin = qobject_cast(d->pluginLoader.instance()); firmwarePlugin()->init(this); - qCDebug(ATCORE_PLUGIN) << "Plugin Loading: Successful"; disconnect(serial(), &SerialLayer::receivedCommand, this, &AtCore::findFirmware); connect(serial(), &SerialLayer::receivedCommand, this, &AtCore::newMessage); connect(firmwarePlugin(), &IFirmware::readyForCommand, this, &AtCore::processQueue); @@ -210,6 +207,7 @@ } } else { qCDebug(ATCORE_CORE) << "Plugin:" << fwName << ": Not found."; + emit atcoreMessage(tr("No plugin found for %1.").arg(fwName)); } } @@ -222,6 +220,7 @@ return true; } else { qCDebug(ATCORE_CORE) << "Failed to open device for Read / Write."; + emit atcoreMessage(tr("Failed to open device in read/write mode.")); return false; } } @@ -244,7 +243,7 @@ QStringList ports; QList serialPortInfoList = QSerialPortInfo::availablePorts(); if (!serialPortInfoList.isEmpty()) { - foreach (const QSerialPortInfo &serialPortInfo, serialPortInfoList) { + for (const QSerialPortInfo &serialPortInfo : serialPortInfoList) { #ifdef Q_OS_MAC //Mac OS has callout serial ports starting with cu these devices are read only. //It is necessary to filter them out to help prevent user error. @@ -385,8 +384,8 @@ } //Attempt to unload the firmware plugin. QString name = firmwarePlugin()->name(); - QString msg = d->pluginLoader.unload() ? QStringLiteral("success") : QStringLiteral("FAIL"); - qCDebug(ATCORE_PLUGIN) << QStringLiteral("Firmware plugin %1 unload: %2").arg(name, msg); + QString msg = d->pluginLoader.unload() ? QStringLiteral("closed.") : QStringLiteral("Failed to close."); + qCDebug(ATCORE_CORE) << QStringLiteral("Firmware plugin %1 %2").arg(name, msg); } serial()->close(); //Clear our copy of the sdcard filelist @@ -403,8 +402,9 @@ void AtCore::setState(AtCore::STATES state) { if (state != d->printerState) { - qCDebug(ATCORE_CORE) << "Atcore state changed from [" \ - << d->printerState << "] to [" << state << "]"; + qCDebug(ATCORE_CORE) << QStringLiteral("Atcore state changed from [%1] to [%2]") + .arg(QVariant::fromValue(d->printerState).value()) + .arg(QVariant::fromValue(state).value()); d->printerState = state; if (state == AtCore::FINISHEDPRINT && d->sdCardPrinting) { //Clean up the sd card print @@ -477,9 +477,8 @@ void AtCore::findFirmwarePlugins() { d->plugins.clear(); - qCDebug(ATCORE_PLUGIN) << "plugin dir:" << d->pluginsDir; QStringList files = d->pluginsDir.entryList(QDir::Files); - foreach (const QString &f, files) { + for (const QString &f : files) { QString file = f; #if defined(Q_OS_WIN) if (file.endsWith(QStringLiteral(".dll"))) @@ -490,20 +489,17 @@ #endif file = file.split(QChar::fromLatin1('.')).at(0); else { - qCDebug(ATCORE_PLUGIN) << "File" << file << "not plugin."; continue; } - qCDebug(ATCORE_CORE) << "Found plugin file" << f; if (file.startsWith(QStringLiteral("lib"))) { file = file.remove(QStringLiteral("lib")); } file = file.toLower().simplified(); - QString pluginString; - pluginString.append(d->pluginsDir.path()); + QString pluginString = d->pluginsDir.absolutePath(); pluginString.append(QChar::fromLatin1('/')); pluginString.append(f); d->plugins[file] = pluginString; - qCDebug(ATCORE_CORE) << tr("plugins[%1]=%2").arg(file, pluginString); + qCDebug(ATCORE_PLUGIN) << QStringLiteral("Plugin:[%1]=%2").arg(file, pluginString); } } diff --git a/src/core/printthread.cpp b/src/core/printthread.cpp --- a/src/core/printthread.cpp +++ b/src/core/printthread.cpp @@ -175,7 +175,9 @@ return; } if (newState != d->state) { - qCDebug(PRINT_THREAD) << "State Changed from [" << d->state << "] to [" << newState << ']'; + qCDebug(PRINT_THREAD) << QStringLiteral("State changed from [%1] to [%2]") + .arg(QVariant::fromValue(d->state).value()) + .arg(QVariant::fromValue(newState).value()); disconnect(d->core, &AtCore::stateChanged, this, &PrintThread::setState); d->state = newState; emit(stateChanged(d->state)); diff --git a/src/core/seriallayer.cpp b/src/core/seriallayer.cpp --- a/src/core/seriallayer.cpp +++ b/src/core/seriallayer.cpp @@ -133,7 +133,7 @@ qCDebug(SERIAL_LAYER) << "Serial not connected !"; return; } - foreach (const auto &comm, d->_sByteCommands) { + for (const auto &comm : d->_sByteCommands) { write(comm); emit(pushedCommand(comm)); } diff --git a/src/widgets/about.cpp b/src/widgets/about.cpp --- a/src/widgets/about.cpp +++ b/src/widgets/about.cpp @@ -32,21 +32,21 @@ setWindowTitle(QStringLiteral("About Atcore")); setWindowIcon(QIcon::fromTheme(QStringLiteral("help-about"), style()->standardIcon(QStyle::SP_MessageBoxInformation))); - QLabel *lbl_version = new QLabel(QString::fromLatin1("Version: %1").arg(QCoreApplication::applicationVersion())); - QLabel *lbl_qt_version = new QLabel(QString::fromLatin1("Using Qt: %1").arg(QString::fromLatin1(qVersion()))); - QLabel *lbl_authors = new QLabel(QStringLiteral("Authors:\n" - " Chris Rizzitello \n" - " Patrick José Pereira \n" - " Lays Rodrigues \n" - " Tomaz Canabrava " - "")); + QLabel *lbl_version = new QLabel(tr("Version: %1").arg(QCoreApplication::applicationVersion())); + QLabel *lbl_qt_version = new QLabel(tr("Using Qt: %1").arg(QString::fromLatin1(qVersion()))); + QLabel *lbl_authors = new QLabel(tr("Authors:\n" + " Chris Rizzitello \n" + " Patrick José Pereira \n" + " Lays Rodrigues \n" + " Tomaz Canabrava " + "")); QLabel *lbl_icon = new QLabel(); lbl_icon->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); lbl_icon->setScaledContents(true); lbl_icon->setPixmap(QPixmap(QStringLiteral(":/icon/atcore"))); - QPushButton *btn_close = new QPushButton(QStringLiteral("&Close")); + QPushButton *btn_close = new QPushButton(tr("Close")); connect(btn_close, &QPushButton::clicked, this, &QDialog::close); QVBoxLayout *versionInfo = new QVBoxLayout; diff --git a/src/widgets/axiscontrol.cpp b/src/widgets/axiscontrol.cpp --- a/src/widgets/axiscontrol.cpp +++ b/src/widgets/axiscontrol.cpp @@ -28,7 +28,7 @@ setRect(QRect(QPoint(size * -1, size * -1), QPoint(size, size))); setZValue(size * -1); setAcceptHoverEvents(true); - setToolTip(QStringLiteral("Move the hotend to the %1 by %2 units").arg(axis).arg(value)); + setToolTip(tr("Move the hotend to the %1 by %2 units").arg(axis).arg(value)); } void PieButton::setPalette(QPalette palette) @@ -58,9 +58,9 @@ setAcceptHoverEvents(true); setZValue(size * -1); if (axis != QLatin1Char('E')) { - setToolTip(QStringLiteral("Move the hotend to the %1 by %2 units").arg(axis).arg(value)); + setToolTip(tr("Move the hotend to the %1 by %2 units").arg(axis).arg(value)); } else { - setToolTip(QStringLiteral("Extrude %1 Units").arg(value)); + setToolTip(tr("Extrude %1 Units").arg(value)); } } diff --git a/testclient/mainwindow.cpp b/testclient/mainwindow.cpp --- a/testclient/mainwindow.cpp +++ b/testclient/mainwindow.cpp @@ -46,6 +46,7 @@ initStatusBar(); initWidgets(); + connect(core, &AtCore::atcoreMessage, logWidget, &LogWidget::appendLog); logWidget->appendLog(tr("Attempting to locate Serial Ports")); core->setSerialTimerInterval(1000); @@ -414,14 +415,9 @@ connect(core->serial(), &SerialLayer::pushedCommand, logWidget, &LogWidget::appendSLog); buttonConnect->setText(tr("Disconnect")); logWidget->appendLog(tr("Serial connected")); - if (comboPlugin->currentText().contains(tr("Autodetect"))) { - logWidget->appendLog(tr("No plugin loaded !")); - logWidget->appendLog(tr("Requesting Firmware...")); - } else { + if (!comboPlugin->currentText().contains(tr("Autodetect"))) { core->loadFirmwarePlugin(comboPlugin->currentText()); } - } else { - logWidget->appendLog(tr("Failed to open serial in r/w mode")); } } else { disconnect(core, &AtCore::receivedMessage, logWidget, &LogWidget::appendRLog);