From bdae47def031728b27b8634894fdc1a9aa7131de Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Wed, 4 Jul 2018 16:09:31 +0300 Subject: Allow opening a presentation from the project palette context menu Right clicking a presentation file in the project palette shows 'Open Presentation' action to open that presentation. Task-number: QT3DS-1965 Change-Id: Ib5efa6900ab69370551b354715b20b54ecf03ba6 Reviewed-by: Miikka Heikkinen --- .../Studio/Palettes/Project/ProjectContextMenu.cpp | 11 +++++++++++ src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h | 1 + src/Authoring/Studio/Palettes/Project/ProjectView.cpp | 14 ++++++++++++++ src/Authoring/Studio/Palettes/Project/ProjectView.h | 2 ++ 4 files changed, 28 insertions(+) diff --git a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp index ac3095ca..dd10e725 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp @@ -34,6 +34,12 @@ ProjectContextMenu::ProjectContextMenu(ProjectView *parent, int index) , m_view(parent) , m_index(index) { + if (m_view->isPresentation(m_index)) { + QAction *action = new QAction(tr("Open Presentation")); + connect(action, &QAction::triggered, this, &ProjectContextMenu::handleOpenPresentation); + addAction(action); + } + QAction *action = new QAction(tr("Show Containing Folder")); connect(action, &QAction::triggered, this, &ProjectContextMenu::handleShowContainingFolder); addAction(action); @@ -66,6 +72,11 @@ ProjectContextMenu::~ProjectContextMenu() { } +void ProjectContextMenu::handleOpenPresentation() +{ + m_view->openPresentation(m_index); +} + void ProjectContextMenu::handleShowContainingFolder() { m_view->showContainingFolder(m_index); diff --git a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h index d68f9e95..694f6cc9 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h +++ b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h @@ -41,6 +41,7 @@ public: virtual ~ProjectContextMenu(); private Q_SLOTS: + void handleOpenPresentation(); void handleShowContainingFolder(); void handleCopyPath(); void handleCopyFullPath(); diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp index 3bb6b279..ba2bc9a3 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp @@ -254,6 +254,15 @@ void ProjectView::startDrag(QQuickItem *item, int row) QTimer::singleShot(0, item, &QQuickItem::ungrabMouse); } +void ProjectView::openPresentation(int row) +{ + if (g_StudioApp.PerformSavePrompt()) { + const QString path = m_ProjectModel->filePath(row); + const Qt3DSFile file(Q3DStudio::CString::fromQString(path)); + g_StudioApp.OnLoadDocument(file); + } +} + void ProjectView::showContainingFolder(int row) const { if (row == -1) @@ -303,6 +312,11 @@ bool ProjectView::isGroup(int row) const return Q3DStudio::ImportUtils::GetObjectFileTypeForFile(path).m_ObjectType == OBJTYPE_GROUP; } +bool ProjectView::isPresentation(int row) const +{ + return m_ProjectModel->filePath(row).endsWith(QLatin1String(".uip")); +} + 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 aeabfa97..5de0712d 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.h +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.h @@ -75,6 +75,8 @@ public: Q_INVOKABLE bool isRefreshable(int row) const; Q_INVOKABLE void showContextMenu(int x, int y, int index); Q_INVOKABLE bool toolTipsEnabled(); + bool isPresentation(int row) const; + void openPresentation(int row); // CPresentationChangeListener void OnNewPresentation() override; -- cgit v1.2.3