diff --git a/src/widgets/3dview/viewer3d.cpp b/src/widgets/3dview/viewer3d.cpp index 96e5a28..ba0c5ef 100644 --- a/src/widgets/3dview/viewer3d.cpp +++ b/src/widgets/3dview/viewer3d.cpp @@ -1,96 +1,92 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017> Author: Patrick José Pereira - patrickjp@kde.org Chris Rizzitello - rizzitello@kde.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include "axisgnomonentity.h" #include "bedproperties.h" #include "cameracontroller.h" #include "gridmesh.h" #include "viewer3d.h" #include "linemesh.h" Viewer3D::Viewer3D(QWidget *parent) : QWidget(parent) , _lineMesh(new LineMesh) { Q_INIT_RESOURCE(viewer3d); qmlRegisterType("Atelier", 1, 0, "AxisGnomonEntity"); qmlRegisterType("Atelier", 1, 0, "CameraController"); qmlRegisterType("Atelier", 1, 0, "GridMesh"); qmlRegisterType("Atelier", 1, 0, "LineMesh"); qmlRegisterType("Atelier", 1, 0, "BedProperties"); _view = new QQuickView(&_engine, nullptr); auto format = QSurfaceFormat(); format.setVersion(3, 1); format.setProfile(QSurfaceFormat::CoreProfile); _view->setFormat(format); _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")); + auto fileName = object->findChild(QStringLiteral("fileName")); fileName->setProperty("text", QVariant(file)); } void Viewer3D::setBedSize(const QSize &newBedSize) { if (newBedSize != _bedSize) { _bedSize = newBedSize; emit bedSizeChanged(_bedSize); } } QSize Viewer3D::bedSize() { return _bedSize; } diff --git a/src/widgets/3dview/viewer3d.h b/src/widgets/3dview/viewer3d.h index 2b68f13..6d0a57e 100644 --- a/src/widgets/3dview/viewer3d.h +++ b/src/widgets/3dview/viewer3d.h @@ -1,55 +1,55 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017> Author: Patrick José Pereira - patrickjp@kde.org Chris Rizzitello - rizzitello@kde.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #pragma once #include #include #include class LineMesh; class QString; class Viewer3D : public QWidget { Q_OBJECT Q_PROPERTY(QSize bedSize READ bedSize WRITE setBedSize NOTIFY bedSizeChanged) public slots: void dropCatch(const QVariant &var); void setBedSize(const QSize &newBedSize); 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; QQmlApplicationEngine _engine; QQuickView *_view; QSize _bedSize = QSize(50, 50); signals: void droppedUrls(QList fileList); void bedSizeChanged(QSize bedSize); };