diff --git a/src/dialogs/profilesdialog.cpp b/src/dialogs/profilesdialog.cpp --- a/src/dialogs/profilesdialog.cpp +++ b/src/dialogs/profilesdialog.cpp @@ -220,9 +220,10 @@ QStringList firmwares; QStringList paths = AtCoreDirectories::pluginDir; //Add our runtime paths - paths.prepend(qApp->applicationDirPath() + QStringLiteral("/../Plugins/AtCore")); - paths.prepend(qApp->applicationDirPath() + QStringLiteral("/AtCore")); - paths.prepend(qApp->applicationDirPath() + QStringLiteral("/plugins")); + QString path = qApp->applicationDirPath(); + paths.prepend(path + QStringLiteral("/../Plugins/AtCore")); + paths.prepend(path + QStringLiteral("/AtCore")); + paths.prepend(path + QStringLiteral("/plugins")); for (const QString &path : paths) { firmwares = firmwaresInPath(path); if (!firmwares.isEmpty()) { diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -65,7 +65,7 @@ aboutData.setOtherText(i18n("Using AtCore:%1", QString(ATCORE_VERSION_STRING))); KAboutData::setApplicationData(aboutData); - MainWindow *m = new MainWindow(); + auto m = new MainWindow(); m->setWindowIcon(QIcon(":/icon/atelier")); m->show(); return app.exec(); diff --git a/src/mainwindow.h b/src/mainwindow.h --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -59,7 +59,7 @@ void dropEvent(QDropEvent *event); private: - GCodeEditorWidget *m_gcodeEditor; + GCodeEditorWidget *m_gcodeEditor = nullptr; KTextEditor::View *m_currEditorView; int m_currInstance; LateralArea m_lateral; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -70,7 +70,7 @@ bool closePrompt = false; for (int i = 0; i < m_instances->count(); i++) { - AtCoreInstanceWidget *instance = qobject_cast(m_instances->widget(i)); + auto instance = qobject_cast(m_instances->widget(i)); if (instance->isPrinting()) { closePrompt = true; break; @@ -182,7 +182,8 @@ ); if (result == QMessageBox::Cancel) { return; - } else if (result == QMessageBox::Save) { + } + if (result == QMessageBox::Save) { m_gcodeEditor->saveFile(file); } } diff --git a/src/widgets/3dview/axisgnomonentity.h b/src/widgets/3dview/axisgnomonentity.h --- a/src/widgets/3dview/axisgnomonentity.h +++ b/src/widgets/3dview/axisgnomonentity.h @@ -36,7 +36,7 @@ Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged) public: explicit AxisGnomonEntity(Qt3DCore::QNode *parent = nullptr); - ~AxisGnomonEntity(); + ~AxisGnomonEntity() = default; QVector2D position() const; float scale() const; diff --git a/src/widgets/3dview/axisgnomonentity.cpp b/src/widgets/3dview/axisgnomonentity.cpp --- a/src/widgets/3dview/axisgnomonentity.cpp +++ b/src/widgets/3dview/axisgnomonentity.cpp @@ -85,10 +85,6 @@ addComponent(material); } -AxisGnomonEntity::~AxisGnomonEntity() -{ -} - QVector2D AxisGnomonEntity::position() const { return _position; diff --git a/src/widgets/3dview/bedproperties.h b/src/widgets/3dview/bedproperties.h --- a/src/widgets/3dview/bedproperties.h +++ b/src/widgets/3dview/bedproperties.h @@ -30,7 +30,7 @@ Q_PROPERTY(int depth READ depth NOTIFY depthChanged) public: explicit BedProperties(QObject *parent = nullptr); - ~BedProperties(); + ~BedProperties() = default; int width() const; int depth() const; diff --git a/src/widgets/3dview/bedproperties.cpp b/src/widgets/3dview/bedproperties.cpp --- a/src/widgets/3dview/bedproperties.cpp +++ b/src/widgets/3dview/bedproperties.cpp @@ -50,10 +50,6 @@ }); } -BedProperties::~BedProperties() -{ -} - int BedProperties::width() const { return m_width; diff --git a/src/widgets/3dview/cameracontroller.h b/src/widgets/3dview/cameracontroller.h --- a/src/widgets/3dview/cameracontroller.h +++ b/src/widgets/3dview/cameracontroller.h @@ -28,7 +28,7 @@ Q_OBJECT public: explicit CameraController(Qt3DCore::QNode *parent = nullptr); - ~CameraController(); + ~CameraController() = default; private: void moveCamera(const QAbstractCameraController::InputState &state, float dt) override; diff --git a/src/widgets/3dview/cameracontroller.cpp b/src/widgets/3dview/cameracontroller.cpp --- a/src/widgets/3dview/cameracontroller.cpp +++ b/src/widgets/3dview/cameracontroller.cpp @@ -42,10 +42,6 @@ { } -CameraController::~CameraController() -{ -} - void CameraController::moveCamera(const Qt3DExtras::QAbstractCameraController::InputState &state, float dt) { auto cam = camera(); diff --git a/src/widgets/3dview/fileloader.h b/src/widgets/3dview/fileloader.h --- a/src/widgets/3dview/fileloader.h +++ b/src/widgets/3dview/fileloader.h @@ -34,7 +34,7 @@ public: FileLoader(QString &fileName, QObject *parent = nullptr); - ~FileLoader(); + ~FileLoader() = default; private: QFile _file; diff --git a/src/widgets/3dview/fileloader.cpp b/src/widgets/3dview/fileloader.cpp --- a/src/widgets/3dview/fileloader.cpp +++ b/src/widgets/3dview/fileloader.cpp @@ -26,7 +26,7 @@ #include #include "fileloader.h" -namespace +namespace ns { const static QString _commentChar = QStringLiteral(";"); const static QStringList _moveCommands = {QStringLiteral("G0"), QStringLiteral("G1")}; @@ -43,10 +43,6 @@ { } -FileLoader::~FileLoader() -{ -} - void FileLoader::run() { QVector pos; @@ -71,51 +67,51 @@ continue; } //Remove comment in the end of command - if (line.indexOf(_commentChar) != -1) { - line.resize(line.indexOf(_commentChar)); + if (line.indexOf(ns::_commentChar) != -1) { + line.resize(line.indexOf(ns::_commentChar)); //Remove trailing spaces line = line.simplified(); } //Split command and args - QStringList commAndArgs = line.split(_space); + QStringList commAndArgs = line.split(ns::_space); - if (_moveCommands.contains(commAndArgs[0])) { + if (ns::_moveCommands.contains(commAndArgs[0])) { QVector4D actualPos; //Compute args commAndArgs.removeFirst(); for (QString element : commAndArgs) { - if (element.contains(_X)) { + if (element.contains(ns::_X)) { actualPos.setX(element.remove(0, 1).toFloat() / 10); } - if (element.contains(_Y)) { + if (element.contains(ns::_Y)) { actualPos.setY(element.remove(0, 1).toFloat() / 10); } - if (element.contains(_Z)) { + if (element.contains(ns::_Z)) { actualPos.setZ(element.remove(0, 1).toFloat() / 10); } - if (element.contains(_E)) { + if (element.contains(ns::_E)) { actualPos.setW(element.remove(0, 1).toFloat() / 10); } } if (!pos.isEmpty()) { - if (!line.contains(_X)) { + if (!line.contains(ns::_X)) { actualPos.setX(pos.last().x()); } - if (!line.contains(_Y)) { + if (!line.contains(ns::_Y)) { actualPos.setY(pos.last().y()); } - if (!line.contains(_Z)) { + if (!line.contains(ns::_Z)) { actualPos.setZ(pos.last().z()); } - if (!line.contains(_E)) { + if (!line.contains(ns::_E)) { actualPos.setW(pos.last().w()); } } diff --git a/src/widgets/3dview/gcodeto4d.h b/src/widgets/3dview/gcodeto4d.h --- a/src/widgets/3dview/gcodeto4d.h +++ b/src/widgets/3dview/gcodeto4d.h @@ -28,7 +28,7 @@ public: explicit GcodeTo4D(QObject *parent = 0); - ~GcodeTo4D(); + ~GcodeTo4D() = default; public: void read(const QString &url); @@ -38,6 +38,6 @@ void posFinished(const QVector &pos); private: - QThread *_thread; - bool _wait; + QThread *_thread = nullptr; + bool _wait = false; }; diff --git a/src/widgets/3dview/gcodeto4d.cpp b/src/widgets/3dview/gcodeto4d.cpp --- a/src/widgets/3dview/gcodeto4d.cpp +++ b/src/widgets/3dview/gcodeto4d.cpp @@ -30,10 +30,6 @@ { } -GcodeTo4D::~GcodeTo4D() -{ -} - void GcodeTo4D::read(const QString &url) { _thread = new QThread; diff --git a/src/widgets/3dview/gridmesh.h b/src/widgets/3dview/gridmesh.h --- a/src/widgets/3dview/gridmesh.h +++ b/src/widgets/3dview/gridmesh.h @@ -33,7 +33,7 @@ Q_PROPERTY(QSize meshResolution READ meshResolution WRITE setMeshResolution NOTIFY meshResolutionChanged) public: explicit GridMesh(Qt3DCore::QNode *parent = nullptr); - ~GridMesh(); + ~GridMesh() = default; QSize meshResolution() const; diff --git a/src/widgets/3dview/gridmesh.cpp b/src/widgets/3dview/gridmesh.cpp --- a/src/widgets/3dview/gridmesh.cpp +++ b/src/widgets/3dview/gridmesh.cpp @@ -36,10 +36,6 @@ setMeshResolution(QSize(20, 20)); } -GridMesh::~GridMesh() -{ -} - QSize GridMesh::meshResolution() const { return m_meshResolution; diff --git a/src/widgets/3dview/linemesh.h b/src/widgets/3dview/linemesh.h --- a/src/widgets/3dview/linemesh.h +++ b/src/widgets/3dview/linemesh.h @@ -37,7 +37,7 @@ public: explicit LineMesh(Qt3DCore::QNode *parent = Q_NULLPTR); - ~LineMesh(); + ~LineMesh() = default; void read(const QString &path); Q_INVOKABLE void readAndRun(const QString &path); void posUpdate(const QVector &pos); diff --git a/src/widgets/3dview/linemesh.cpp b/src/widgets/3dview/linemesh.cpp --- a/src/widgets/3dview/linemesh.cpp +++ b/src/widgets/3dview/linemesh.cpp @@ -40,10 +40,6 @@ connect(&_gcode, &GcodeTo4D::posFinished, this, &LineMesh::posUpdate); } -LineMesh::~LineMesh() -{ -} - void LineMesh::readAndRun(const QString &path) { _gcode.read(path); diff --git a/src/widgets/3dview/linemeshgeometry.h b/src/widgets/3dview/linemeshgeometry.h --- a/src/widgets/3dview/linemeshgeometry.h +++ b/src/widgets/3dview/linemeshgeometry.h @@ -32,7 +32,7 @@ public: LineMeshGeometry(const QVector &vertices, Qt3DCore::QNode *parent = Q_NULLPTR); - ~LineMeshGeometry(); + ~LineMeshGeometry() = default; int vertexCount(); private: diff --git a/src/widgets/3dview/linemeshgeometry.cpp b/src/widgets/3dview/linemeshgeometry.cpp --- a/src/widgets/3dview/linemeshgeometry.cpp +++ b/src/widgets/3dview/linemeshgeometry.cpp @@ -43,10 +43,6 @@ addAttribute(_positionAttribute); } -LineMeshGeometry::~LineMeshGeometry() -{ -} - int LineMeshGeometry::vertexCount() { return _vertexBuffer->data().size() / static_cast(sizeof(QVector3D)); diff --git a/src/widgets/3dview/viewer3d.h b/src/widgets/3dview/viewer3d.h --- a/src/widgets/3dview/viewer3d.h +++ b/src/widgets/3dview/viewer3d.h @@ -39,9 +39,9 @@ public: explicit Viewer3D(QWidget *parent = nullptr); - ~Viewer3D() override; + ~Viewer3D() override = default; QSize bedSize(); - void drawModel(QString file); + void drawModel(const QString &file); private: LineMesh *_lineMesh; diff --git a/src/widgets/3dview/viewer3d.cpp b/src/widgets/3dview/viewer3d.cpp --- a/src/widgets/3dview/viewer3d.cpp +++ b/src/widgets/3dview/viewer3d.cpp @@ -58,24 +58,20 @@ _view->rootContext()->setContextProperty("viewer3d", this); _view->setResizeMode(QQuickView::SizeRootObjectToView); _view->setSource(QUrl(QStringLiteral("qrc:/viewer3d.qml"))); - QHBoxLayout *mainLayout = new QHBoxLayout; + auto mainLayout = new QHBoxLayout; mainLayout->addWidget(QWidget::createWindowContainer(_view)); QObject *item = _view->rootObject(); //Connect the drop pass from the QML part. connect(item, SIGNAL(droppedUrls(QVariant)), this, SLOT(dropCatch(QVariant))); this->setLayout(mainLayout); } -Viewer3D::~Viewer3D() -{ -} - void Viewer3D::dropCatch(const QVariant &var) { emit droppedUrls(var.value >()); } -void Viewer3D::drawModel(QString file) +void Viewer3D::drawModel(const QString &file) { QObject *object = _view->rootObject(); QObject *fileName = object->findChild(QStringLiteral("fileName")); diff --git a/src/widgets/atcoreinstancewidget.h b/src/widgets/atcoreinstancewidget.h --- a/src/widgets/atcoreinstancewidget.h +++ b/src/widgets/atcoreinstancewidget.h @@ -68,18 +68,18 @@ StatusWidget *m_statusWidget; QAction *m_printAction; QAction *m_stopAction; - QComboBox *m_comboPort; - QComboBox *m_comboProfile; + QComboBox *m_comboPort = nullptr; + QComboBox *m_comboProfile = nullptr; QMap m_profileData; - QPushButton *m_connectButton; + QPushButton *m_connectButton = nullptr; QSettings m_settings; QSize m_iconSize; QString m_theme; QTabWidget *m_tabWidget; - QToolBar *m_connectToolBar; + QToolBar *m_connectToolBar = nullptr; QToolBar *m_toolBar; QWidget *m_advancedTab; - QWidget *m_connectWidget; + QWidget *m_connectWidget = nullptr; QSize m_bedSize; void buildConnectionToolbar(); void buildToolbar(); diff --git a/src/widgets/atcoreinstancewidget.cpp b/src/widgets/atcoreinstancewidget.cpp --- a/src/widgets/atcoreinstancewidget.cpp +++ b/src/widgets/atcoreinstancewidget.cpp @@ -33,15 +33,15 @@ { m_theme = palette().text().color().value() >= QColor(Qt::lightGray).value() ? QString("dark") : QString("light") ; m_iconSize = QSize(fontMetrics().lineSpacing(), fontMetrics().lineSpacing()); - QHBoxLayout *HLayout = new QHBoxLayout; + auto HLayout = new QHBoxLayout; m_bedExtWidget = new BedExtruderWidget; HLayout->addWidget(m_bedExtWidget); m_movementWidget = new MovementWidget(false); m_movementWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); HLayout->addWidget(m_movementWidget); - QVBoxLayout *VLayout = new QVBoxLayout; + auto VLayout = new QVBoxLayout; VLayout->addLayout(HLayout); m_plotWidget = new PlotWidget(); @@ -168,18 +168,18 @@ m_comboPort = new QComboBox; m_comboPort->setEditable(true); QLabel *deviceLabel = new QLabel(i18n("Device")); - QHBoxLayout *deviceLayout = new QHBoxLayout; + auto deviceLayout = new QHBoxLayout; deviceLayout->addWidget(deviceLabel); deviceLayout->addWidget(m_comboPort, 100); m_comboProfile = new QComboBox; m_comboProfile->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - QHBoxLayout *profileLayout = new QHBoxLayout; + auto profileLayout = new QHBoxLayout; QLabel *profileLabel = new QLabel(i18n("Profile")); profileLayout->addWidget(profileLabel); profileLayout->addWidget(m_comboProfile, 100); - QHBoxLayout *connectLayout = new QHBoxLayout; + auto connectLayout = new QHBoxLayout; connectLayout->addLayout(deviceLayout, 50); connectLayout->addLayout(profileLayout, 50); @@ -336,7 +336,8 @@ , i18n("No filename sent from calling method, please check and try again.") ); return; - } else if (!QFileInfo(fileName.toLocalFile()).isReadable()) { + } + if (!QFileInfo(fileName.toLocalFile()).isReadable()) { QMessageBox::critical( this , i18n("File not found") @@ -485,8 +486,8 @@ } msg.append(QString::fromLatin1("[%1] : %2")); - msg = msg.arg(QString::number(number)) - .arg(QString::number(double(temp), 'f', 2)); + msg = msg.arg(QString::number(number) + , QString::number(double(temp), 'f', 2)); m_logWidget->appendLog(msg); } diff --git a/src/widgets/bedextruderwidget.cpp b/src/widgets/bedextruderwidget.cpp --- a/src/widgets/bedextruderwidget.cpp +++ b/src/widgets/bedextruderwidget.cpp @@ -63,7 +63,9 @@ value > 1 ? m_extruderBox->setVisible(true) : m_extruderBox->setVisible(false); if (value == m_extruderCount) { return; - } else if (m_extruderCount < value) { + } + + if (m_extruderCount < value) { //loop for the new buttons for (int i = m_extruderCount; i < value; i++) { auto *rb = new QRadioButton(QString::number(i + 1)); diff --git a/src/widgets/gcodeeditorwidget.h b/src/widgets/gcodeeditorwidget.h --- a/src/widgets/gcodeeditorwidget.h +++ b/src/widgets/gcodeeditorwidget.h @@ -37,7 +37,7 @@ private: QMap urlDoc; QMap urlTab; - KTextEditor::ConfigInterface *m_interface; + KTextEditor::ConfigInterface *m_interface = nullptr; KTextEditor::Document *newDoc(const QUrl &file); KTextEditor::Editor *m_editor; KTextEditor::View *newView(KTextEditor::Document *doc); diff --git a/src/widgets/gcodeeditorwidget.cpp b/src/widgets/gcodeeditorwidget.cpp --- a/src/widgets/gcodeeditorwidget.cpp +++ b/src/widgets/gcodeeditorwidget.cpp @@ -30,7 +30,7 @@ setAcceptDrops(true); m_editor = KTextEditor::Editor::instance(); setupTabWidget(); - QVBoxLayout *layout = new QVBoxLayout(); + auto layout = new QVBoxLayout(); layout->addWidget(m_tabwidget); setLayout(layout); } diff --git a/src/widgets/thermowidget.h b/src/widgets/thermowidget.h --- a/src/widgets/thermowidget.h +++ b/src/widgets/thermowidget.h @@ -32,7 +32,7 @@ Q_OBJECT public: - ThermoWidget(QWidget *parent, QString name); + ThermoWidget(QWidget *parent, const QString &name); void drawNeedle(QPainter *painter, const QPointF ¢er, double radius, double dir, QPalette::ColorGroup colorGroup) const; diff --git a/src/widgets/thermowidget.cpp b/src/widgets/thermowidget.cpp --- a/src/widgets/thermowidget.cpp +++ b/src/widgets/thermowidget.cpp @@ -27,7 +27,7 @@ #include #include "thermowidget.h" -ThermoWidget::ThermoWidget(QWidget *parent, QString name) : +ThermoWidget::ThermoWidget(QWidget *parent, const QString &name) : QwtDial(parent) , m_targetTemperatureNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, false, Qt::red, Qt::darkRed)) , m_name(name) diff --git a/src/widgets/videomonitorwidget.cpp b/src/widgets/videomonitorwidget.cpp --- a/src/widgets/videomonitorwidget.cpp +++ b/src/widgets/videomonitorwidget.cpp @@ -77,8 +77,7 @@ } _videoWidget->setVisible(b); }); - - typedef void (QMediaPlayer::*ErrorSignal)(QMediaPlayer::Error); + using ErrorSignal = void (QMediaPlayer::*)(QMediaPlayer::Error); connect(&_mediaplayer, static_cast(&QMediaPlayer::error), this, &VideoMonitorWidget::handleError); } diff --git a/src/widgets/welcomewidget.h b/src/widgets/welcomewidget.h --- a/src/widgets/welcomewidget.h +++ b/src/widgets/welcomewidget.h @@ -36,7 +36,7 @@ public: WelcomeWidget(QWidget *parent = nullptr); - ~WelcomeWidget(); + ~WelcomeWidget() = default; private: QWidget *m_newsFeedWidget; diff --git a/src/widgets/welcomewidget.cpp b/src/widgets/welcomewidget.cpp --- a/src/widgets/welcomewidget.cpp +++ b/src/widgets/welcomewidget.cpp @@ -111,11 +111,6 @@ setLayout(layout); } -WelcomeWidget::~WelcomeWidget() -{ - -} - void WelcomeWidget::retrieveRssFeed() { auto manager = new QNetworkAccessManager(); @@ -129,20 +124,20 @@ connect(manager, &QNetworkAccessManager::finished, this, [&](QNetworkReply * reply) { if (reply->error()) { return; - } else { - QDomDocument document; - if (document.setContent(reply->readAll())) { - parseRss(document); - } + } + + QDomDocument document; + if (document.setContent(reply->readAll())) { + parseRss(document); } }); } } void WelcomeWidget::parseRss(const QDomDocument &document) { auto itemList = document.elementsByTagName("item"); - QRegularExpression dateRegex("(?\\d{2} \\w{3} \\d{4})"); + QRegularExpression dateRegex(QStringLiteral(R"((?\d{2} \w{3} \d{4}))")); for (int i = 0; i < itemList.count(); ++i) { auto node = itemList.at(i);