summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Project
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-01-04 16:45:33 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2019-01-10 08:50:52 +0000
commit37780644b31d49ae9bd86f0025e9c809de960327 (patch)
tree790df9eddf020f52c0345f9681b110b4af312339 /src/Authoring/Studio/Palettes/Project
parent6ab1bba36f7b409cf52123548184aaf7291bc65c (diff)
Implement 'save project as' and 'duplicate presentation'
'Save project as' creates a copy of the existing project and allows optionally opening the copy in the editor. 'Duplicate presentation' copies the active or targeted presentation into the same folder as the original presentation. User must supply the new name, but the id is autogenerated. Task-number: QT3DS-2630 Change-Id: I13e1cffd0b9d2705fbab7ca72b9dd1f5d0691e77 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Antti Määttä <antti.maatta@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/EditPresentationIdDlg.cpp49
-rw-r--r--src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.h7
-rw-r--r--src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.ui8
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp15
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h1
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectView.cpp5
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectView.h1
7 files changed, 75 insertions, 11 deletions
diff --git a/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.cpp b/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.cpp
index 09e1da37..323a6ed1 100644
--- a/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.cpp
+++ b/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.cpp
@@ -57,6 +57,14 @@ EditPresentationIdDlg::EditPresentationIdDlg(const QString &src, DialogType type
m_ui->label->setText(tr("Qml Stream Name"));
setWindowTitle(tr("Rename Qml Stream"));
break;
+ case DuplicatePresentation:
+ m_ui->label->setText(tr("Presentation Name"));
+ setWindowTitle(tr("Duplicate Presentation"));
+ break;
+ case DuplicateQmlStream:
+ m_ui->label->setText(tr("Qml Stream Name"));
+ setWindowTitle(tr("Duplicate Qml Stream"));
+ break;
default:
break;
}
@@ -66,7 +74,10 @@ EditPresentationIdDlg::EditPresentationIdDlg(const QString &src, DialogType type
m_ui->lineEditPresentationId->setText(m_presentationId);
} else {
QFileInfo fi(src);
- m_ui->lineEditPresentationId->setText(fi.fileName());
+ QString initialText = fi.completeBaseName();
+ if (m_dialogType == DuplicatePresentation || m_dialogType == DuplicateQmlStream)
+ initialText = g_StudioApp.GetCore()->getProjectFile().getUniquePresentationName(src);
+ m_ui->lineEditPresentationId->setText(initialText);
}
window()->setFixedSize(size());
@@ -103,7 +114,19 @@ void EditPresentationIdDlg::accept()
newValue.prepend(m_src.left(slashIndex + 1));
if (newValue != m_src) {
- if (g_StudioApp.GetCore()->getProjectFile().renamePresentationFile(m_src, newValue))
+ bool success = false;
+ if (m_dialogType == DuplicatePresentation || m_dialogType == DuplicateQmlStream) {
+ success = g_StudioApp.GetCore()->getProjectFile().duplicatePresentation(
+ m_src, newValue);
+ if (success) {
+ m_duplicateFile = g_StudioApp.GetCore()->getProjectFile()
+ .getAbsoluteFilePathTo(newValue);
+ }
+ } else {
+ success = g_StudioApp.GetCore()->getProjectFile().renamePresentationFile(
+ m_src, newValue);
+ }
+ if (success)
QDialog::accept();
else
displayWarning(UniqueWarning);
@@ -117,6 +140,10 @@ void EditPresentationIdDlg::accept()
void EditPresentationIdDlg::displayWarning(WarningType warningType)
{
QString warning;
+ QString uniqueFileNote;
+ if (warningType == UniqueWarning)
+ uniqueFileNote = tr("The new name must be unique within its folder and a valid filename.");
+
switch (m_dialogType) {
// Presentation Id warnings are also displayed from preferences dialog, so they are handled
// by CStudioApp.
@@ -136,15 +163,25 @@ void EditPresentationIdDlg::displayWarning(WarningType warningType)
if (warningType == EmptyWarning)
warning = tr("Presentation name must not be empty.");
else
- warning = tr("Renaming presentation failed.\n"
- "The new name must be unique within its folder and a valid filename.");
+ warning = tr("Renaming presentation failed.\n") + uniqueFileNote;
break;
case EditQmlStreamName:
if (warningType == EmptyWarning)
warning = tr("Qml stream name must not be empty.");
else
- warning = tr("Renaming Qml stream failed.\n"
- "The new name must be unique within its folder and a valid filename.");
+ warning = tr("Renaming Qml stream failed.\n") + uniqueFileNote;
+ break;
+ case DuplicatePresentation:
+ if (warningType == EmptyWarning)
+ warning = tr("Presentation name must not be empty.");
+ else
+ warning = tr("Duplicating presentation failed.\n") + uniqueFileNote;
+ break;
+ case DuplicateQmlStream:
+ if (warningType == EmptyWarning)
+ warning = tr("Qml stream name must not be empty.");
+ else
+ warning = tr("Duplicating Qml stream failed.\n") + uniqueFileNote;
break;
default:
break;
diff --git a/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.h b/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.h
index 67607710..30bfccbd 100644
--- a/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.h
+++ b/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.h
@@ -50,13 +50,17 @@ public:
EditPresentationId,
EditQmlStreamId,
EditPresentationName,
- EditQmlStreamName
+ EditQmlStreamName,
+ DuplicatePresentation,
+ DuplicateQmlStream
};
explicit EditPresentationIdDlg(const QString &src, DialogType type = EditPresentationId,
QWidget *parent = nullptr);
~EditPresentationIdDlg();
+ QString getDuplicateFile() const { return m_duplicateFile; }
+
public Q_SLOTS:
void accept() override;
@@ -71,6 +75,7 @@ private:
QString m_src; // src attribute value for the current presentation in the project file
QString m_presentationId;
DialogType m_dialogType;
+ QString m_duplicateFile;
};
#endif // EDITPRESENTATIONIDDLG_H
diff --git a/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.ui b/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.ui
index a894710c..5253ccb6 100644
--- a/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.ui
+++ b/src/Authoring/Studio/Palettes/Project/EditPresentationIdDlg.ui
@@ -34,7 +34,7 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="labelEditLayout" native="true">
- <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
+ <layout class="QHBoxLayout" name="horizontalLayout" stretch="0">
<property name="leftMargin">
<number>0</number>
</property>
@@ -54,13 +54,13 @@
</property>
</widget>
</item>
- <item>
- <widget class="QLineEdit" name="lineEditPresentationId"/>
- </item>
</layout>
</widget>
</item>
<item>
+ <widget class="QLineEdit" name="lineEditPresentationId"/>
+ </item>
+ <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp
index c2825718..5c985359 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.cpp
@@ -63,6 +63,11 @@ ProjectContextMenu::ProjectContextMenu(ProjectView *parent, int index)
connect(action, &QAction::triggered, this, &ProjectContextMenu::handleEditPresentationId);
addAction(action);
+ action = new QAction(tr("Duplicate Presentation"));
+ connect(action, &QAction::triggered,
+ this, &ProjectContextMenu::handleDuplicatePresentation);
+ addAction(action);
+
static const QIcon iconInitial = QIcon(QStringLiteral(":/images/initial_notUsed.png"));
if (m_view->isInitialPresentation(m_index)) {
@@ -87,6 +92,11 @@ ProjectContextMenu::ProjectContextMenu(ProjectView *parent, int index)
action = new QAction(tr("Edit Qml Stream Id"));
connect(action, &QAction::triggered, this, &ProjectContextMenu::handleEditQmlStreamId);
addAction(action);
+
+ action = new QAction(tr("Duplicate Qml Stream"));
+ connect(action, &QAction::triggered,
+ this, &ProjectContextMenu::handleDuplicatePresentation);
+ addAction(action);
}
if (m_view->isMaterialData(m_index)) {
@@ -195,6 +205,11 @@ void ProjectContextMenu::handleDuplicate()
m_view->duplicate(m_index);
}
+void ProjectContextMenu::handleDuplicatePresentation()
+{
+ m_view->duplicatePresentation(m_index);
+}
+
void ProjectContextMenu::handleInitialPresentation()
{
m_view->setInitialPresentation(m_index);
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h
index 9ed0e8fd..12cd2367 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h
+++ b/src/Authoring/Studio/Palettes/Project/ProjectContextMenu.h
@@ -51,6 +51,7 @@ private Q_SLOTS:
void handleImportAssets();
void handleAddMaterial();
void handleDuplicate();
+ void handleDuplicatePresentation();
void handleInitialPresentation();
void handleRenamePresentation();
void handleRenameQmlStream();
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
index a32e8f98..c0ba2724 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp
@@ -502,6 +502,11 @@ void ProjectView::duplicate(int row) const
m_ProjectModel->duplicate(row);
}
+void ProjectView::duplicatePresentation(int row) const
+{
+ g_StudioApp.duplicatePresentation(m_ProjectModel->filePath(row));
+}
+
void ProjectView::deleteFile(int row) const
{
if (isReferenced(row)) {
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.h b/src/Authoring/Studio/Palettes/Project/ProjectView.h
index e2055014..7533e677 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectView.h
+++ b/src/Authoring/Studio/Palettes/Project/ProjectView.h
@@ -79,6 +79,7 @@ public:
void addMaterial(int row) const;
void editMaterial(int row) const;
void duplicate(int row) const;
+ void duplicatePresentation(int row) const;
void deleteFile(int row) const;
bool isRefreshable(int row) const;