Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/3dview/viewer3d.cpp
1 | /* Atelier KDE Printer Host for 3D Printing | 1 | /* Atelier KDE Printer Host for 3D Printing | ||
---|---|---|---|---|---|
2 | Copyright (C) <2017> | 2 | Copyright (C) <2017> | ||
3 | Author: Patrick José Pereira - patrickjp@kde.org | 3 | Author: Patrick José Pereira - patrickjp@kde.org | ||
4 | Chris Rizzitello - rizzitello@kde.org | ||||
4 | 5 | | |||
5 | This program is free software; you can redistribute it and/or | 6 | This program is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU General Public License as | 7 | modify it under the terms of the GNU General Public License as | ||
7 | published by the Free Software Foundation; either version 3 of | 8 | published by the Free Software Foundation; either version 3 of | ||
8 | the License or any later version accepted by the membership of | 9 | the License or any later version accepted by the membership of | ||
9 | KDE e.V. (or its successor approved by the membership of KDE | 10 | KDE e.V. (or its successor approved by the membership of KDE | ||
10 | e.V.), which shall act as a proxy defined in Section 14 of | 11 | e.V.), which shall act as a proxy defined in Section 14 of | ||
11 | version 3 of the license. | 12 | version 3 of the license. | ||
Show All 33 Lines | 38 | { | |||
45 | qmlRegisterType<GridMesh>("GridMesh", 1, 0, "GridMesh"); | 46 | qmlRegisterType<GridMesh>("GridMesh", 1, 0, "GridMesh"); | ||
46 | qmlRegisterType<LineMesh>("LineMesh", 1, 0, "LineMesh"); | 47 | qmlRegisterType<LineMesh>("LineMesh", 1, 0, "LineMesh"); | ||
47 | 48 | | |||
48 | _view = new QQuickView(&_engine, nullptr); | 49 | _view = new QQuickView(&_engine, nullptr); | ||
49 | _view->setResizeMode(QQuickView::SizeRootObjectToView); | 50 | _view->setResizeMode(QQuickView::SizeRootObjectToView); | ||
50 | _view->setSource(QUrl(QStringLiteral("qrc:/viewer3d.qml"))); | 51 | _view->setSource(QUrl(QStringLiteral("qrc:/viewer3d.qml"))); | ||
51 | QHBoxLayout *mainLayout = new QHBoxLayout; | 52 | QHBoxLayout *mainLayout = new QHBoxLayout; | ||
52 | mainLayout->addWidget(QWidget::createWindowContainer(_view)); | 53 | mainLayout->addWidget(QWidget::createWindowContainer(_view)); | ||
54 | QObject *item = _view->rootObject(); | ||||
55 | //Connect the drop pass from the QML part. | ||||
patrickelectric: What year is this ? | |||||
the year that this is shown as the qt 5.10 way to connect a qml signal to a c++ slot. rizzitello: the year that this is shown as the qt 5.10 way to connect a qml signal to a c++ slot.
https… | |||||
Looking better in the code now, it's make sense what you did, but this 3D infrastructure is wrong, Viewer3D itself need to be a qtquick component and viewer3d.qml should not be necessary anymore in the future, using the own functions of Viewer3D to proceed with that. patrickelectric: Looking better in the code now, it's make sense what you did, but this 3D infrastructure is… | |||||
56 | connect(item, SIGNAL(droppedUrls(QVariant)), this, SLOT(dropCatch(QVariant))); | ||||
53 | this->setLayout(mainLayout); | 57 | this->setLayout(mainLayout); | ||
54 | } | 58 | } | ||
55 | 59 | | |||
56 | Viewer3D::~Viewer3D() | 60 | Viewer3D::~Viewer3D() | ||
57 | { | 61 | { | ||
58 | } | 62 | } | ||
59 | 63 | | |||
64 | void Viewer3D::dropCatch(const QVariant &var) | ||||
65 | { | ||||
66 | emit droppedUrls(var.value<QList<QUrl> >()); | ||||
67 | } | ||||
68 | | ||||
60 | void Viewer3D::drawModel(QString file) | 69 | void Viewer3D::drawModel(QString file) | ||
61 | { | 70 | { | ||
62 | QObject *object = _view->rootObject(); | 71 | QObject *object = _view->rootObject(); | ||
63 | QObject *fileName = object->findChild<QObject *>(QStringLiteral("fileName")); | 72 | QObject *fileName = object->findChild<QObject *>(QStringLiteral("fileName")); | ||
64 | fileName->setProperty("text", QVariant(file)); | 73 | fileName->setProperty("text", QVariant(file)); | ||
65 | } | 74 | } |
What year is this ?