summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Project
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2018-09-03 12:54:05 +0300
committerTomi Korpipää <tomi.korpipaa@qt.io>2018-09-03 10:52:15 +0000
commit9b1f6e3261e55a871633f45031fca875135bf56c (patch)
tree698ccc62a566f1c718e5c7456ff4a8114024afac /src/Authoring/Studio/Palettes/Project
parent471339bc8f2fe32fd41f6595478c2488f1cad103 (diff)
Allow creating materials only into the materials folder
Task-number: QT3DS-2217 Change-Id: Ia115d3e2f7923f089d603224881d8550ef86eb7d Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Project')
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp11
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectView.cpp5
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectView.h1
3 files changed, 12 insertions, 5 deletions
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp
index d6e1d534..1b617625 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp
@@ -85,11 +85,12 @@ ProjectContextMenu::ProjectContextMenu(ProjectView *parent, int index)
connect(action, &QAction::triggered, this, &ProjectContextMenu::handleImportAssets);
addAction(action);
- addSeparator();
-
- action = new QAction(tr("Add Material"));
- connect(action, &QAction::triggered, this, &ProjectContextMenu::handleAddMaterial);
- addAction(action);
+ if (m_view->isMaterialFolder(m_index)) {
+ addSeparator();
+ action = new QAction(tr("Add Material"));
+ connect(action, &QAction::triggered, this, &ProjectContextMenu::handleAddMaterial);
+ addAction(action);
+ }
if (m_view->isRefreshable(m_index)) {
addSeparator();
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
index be2d7375..8bcf93f4 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
@@ -377,6 +377,11 @@ bool ProjectView::isQmlStream(int row) const
return strcmp(rootClassName, "Q3DStudio::Q3DSQmlBehavior") != 0;
}
+bool ProjectView::isMaterialFolder(int row) const
+{
+ return m_ProjectModel->filePath(row).endsWith(QLatin1String("/materials"));
+}
+
bool ProjectView::isMaterialData(int row) const
{
return m_ProjectModel->filePath(row).endsWith(QLatin1String(".matdata"));
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.h b/src/Authoring/Studio/Palettes/Project/ProjectView.h
index ae52ad8d..f368756c 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectView.h
+++ b/src/Authoring/Studio/Palettes/Project/ProjectView.h
@@ -86,6 +86,7 @@ public:
bool isPresentation(int row) const;
bool isQmlStream(int row) const;
bool isCurrentPresentation(int row) const;
+ bool isMaterialFolder(int row) const;
bool isMaterialData(int row) const;
void openPresentation(int row);
void editPresentationId(int row);