diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-08-15 16:33:39 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@qt.io> | 2018-08-17 04:54:06 +0000 |
commit | 2bc0f9c2ee2e1702ca85344dca764167680e2899 (patch) | |
tree | c6380f10ffc650de550f4450dcf4ecaa991ed6a2 /src/Authoring/Studio/Palettes | |
parent | 6656ec08f1b7880f171fd234a6f7afab7df1f4ef (diff) |
Allow editing Qml streams presentation Id
Allow editing a qml stream's Id from the project palette context menu.
Also removed the scaling of texture upon DnD a presentation to the
scene.
Task-number: QT3DS-2087
Change-Id: I16e8f35094835c04bb887c99081c7055657091e0
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes')
4 files changed, 33 insertions, 5 deletions
diff --git a/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.cpp b/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.cpp index dfd8bc72..18233edf 100644 --- a/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.cpp +++ b/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.cpp @@ -38,9 +38,16 @@ EditPresentationIdDlg::EditPresentationIdDlg(const QString &src, QWidget *parent { m_ui->setupUi(this); - m_presentationId = g_StudioApp.GetCore()->getProjectFile().getPresentationId(src); + auto *sp = std::find_if(g_StudioApp.m_subpresentations.begin(), + g_StudioApp.m_subpresentations.end(), + [&src](const SubPresentationRecord &spr) -> bool { + return spr.m_argsOrSrc == src; + }); - m_ui->lineEditPresentationId->setText(m_presentationId); + if (sp != g_StudioApp.m_subpresentations.end()) { + m_presentationId = sp->m_id; + m_ui->lineEditPresentationId->setText(m_presentationId); + } connect(m_ui->lineEditPresentationId, &QLineEdit::textEdited, this, &EditPresentationIdDlg::onChangePresentationId); diff --git a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp index 1ff86939..74d209ce 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp @@ -45,6 +45,12 @@ ProjectContextMenu::ProjectContextMenu(ProjectView *parent, int index) addAction(action); addSeparator(); + } else if (m_view->isQmlStream(m_index)) { + QAction *action = new QAction(tr("Edit Qml stream Id")); + connect(action, &QAction::triggered, this, &ProjectContextMenu::handleEditPresentationId); + addAction(action); + + addSeparator(); } QAction *action = new QAction(tr("Show Containing Folder")); diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp index 79782df9..1c26a8f7 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp @@ -50,6 +50,7 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlfile.h> #include <QtQuick/qquickitem.h> +#include <QtQml/qqmlapplicationengine.h> ProjectView::ProjectView(const QSize &preferredSize, QWidget *parent) : QQuickWidget(parent) , m_ProjectModel(new ProjectFileSystemModel(this)) @@ -282,10 +283,10 @@ bool ProjectView::isCurrentPresentation(int row) const void ProjectView::editPresentationId(int row) { - QString relativeUipPath = QDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath()) - .relativeFilePath(m_ProjectModel->filePath(row)); + QString relativePresPath = QDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath()) + .relativeFilePath(m_ProjectModel->filePath(row)); - EditPresentationIdDlg dlg(relativeUipPath, this); + EditPresentationIdDlg dlg(relativePresPath, this); dlg.exec(); } @@ -343,6 +344,19 @@ bool ProjectView::isPresentation(int row) const return m_ProjectModel->filePath(row).endsWith(QLatin1String(".uip")); } +bool ProjectView::isQmlStream(int row) const +{ + const QString filePath = m_ProjectModel->filePath(row); + + if (!filePath.endsWith(QLatin1String(".qml"))) + return false; + + QQmlApplicationEngine qmlEngine(filePath); + const char *rootClassName = qmlEngine.rootObjects().at(0) + ->metaObject()->superClass()->className(); + return strcmp(rootClassName, "Q3DStudio::Q3DSQmlBehavior") != 0; +} + bool ProjectView::isRefreshable(int row) const { return m_ProjectModel->isRefreshable(row); diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.h b/src/Authoring/Studio/Palettes/Project/ProjectView.h index eedd562e..b39ef832 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.h +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.h @@ -77,6 +77,7 @@ public: Q_INVOKABLE void showContextMenu(int x, int y, int index); Q_INVOKABLE bool toolTipsEnabled(); bool isPresentation(int row) const; + bool isQmlStream(int row) const; bool isCurrentPresentation(int row) const; void openPresentation(int row); void editPresentationId(int row); |