summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-07-06 16:25:55 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-07-06 13:33:51 +0000
commit49266118cbedae8060c689550a46a1d7bb9fdcd9 (patch)
treec79394b789dae44b603731191be3cc53a58890ee
parent927ba6e8e93b6bc5bff143222a55f7ec9577cd46 (diff)
Disable new layer button when editing a component
Task-number: QT3DS-1981 Change-Id: Ibcb473d55d00097d69135ad45c471a014c731efc Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp9
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h1
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp1
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp15
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h2
5 files changed, 23 insertions, 5 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp
index 0c85f225..6c4437b2 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp
@@ -366,6 +366,15 @@ RowTree *RowManager::selectedRow() const
return nullptr;
}
+bool RowManager::isComponentRoot() const
+{
+ if (m_layoutTree->count() > 1) {
+ RowTree *root = static_cast<RowTree *>(m_layoutTree->itemAt(1)->graphicsItem());
+ return root->rowType() == OBJTYPE_COMPONENT;
+ }
+ return false;
+}
+
bool RowManager::isRowSelected(RowTree *row) const
{
return m_selectedRows.contains(row);
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h
index 9a469d8e..ceedf147 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h
@@ -69,6 +69,7 @@ public:
int index = -1);
RowTree *getRowAtPos(const QPointF &scenePos) const;
RowTree *selectedRow() const;
+ bool isComponentRoot() const;
bool isRowSelected(RowTree *row) const;
QVector<RowTree *> selectedRows() const;
void ensureRowExpandedAndVisible(RowTree *row, bool forceChildUpdate) const;
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
index f71105eb..6abfa20c 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
@@ -725,6 +725,7 @@ void TimelineWidget::onAsyncUpdate()
m_graphicsScene->rowManager()->updateFiltering();
m_graphicsScene->updateController();
onSelectionChange(doc->GetSelectedValue());
+ m_toolbar->setNewLayerEnabled(!m_graphicsScene->rowManager()->isComponentRoot());
} else {
if (!m_moveMap.isEmpty()) {
// Flip the hash around so that we collect moves by parent.
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
index 5b505c11..44938466 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
@@ -69,7 +69,7 @@ TimelineToolbar::TimelineToolbar() : QToolBar()
altKey = "⌥";
#endif
QString newLayerString = tr("Add New Layer (%1L)").arg(ctrlKey);
- QAction *actionNewLayer = new QAction(iconLayer, newLayerString, this);
+ m_actionNewLayer = new QAction(iconLayer, newLayerString, this);
QAction *actionFirst = new QAction(iconFirst, tr("Go to Timeline Start"), this);
QAction *actionLast = new QAction(iconLast, tr("Go to Timeline End"), this);
m_actionDataInput = new QAction(m_iconDiInactive, "");
@@ -103,7 +103,7 @@ TimelineToolbar::TimelineToolbar() : QToolBar()
updatePlayButtonState(false);
// connections
- connect(actionNewLayer, &QAction::triggered, this, &TimelineToolbar::newLayerTriggered);
+ connect(m_actionNewLayer, &QAction::triggered, this, &TimelineToolbar::newLayerTriggered);
connect(m_actionDeleteRow, &QAction::triggered, this, &TimelineToolbar::deleteLayerTriggered);
connect(m_timeLabel, &TimelineToolbarLabel::clicked, this, &TimelineToolbar::gotoTimeTriggered);
connect(actionFirst, &QAction::triggered, this, &TimelineToolbar::firstFrameTriggered);
@@ -116,7 +116,7 @@ TimelineToolbar::TimelineToolbar() : QToolBar()
connect(actionGoToTime, &QAction::triggered, this, &TimelineToolbar::gotoTimeTriggered);
// add actions
- addAction(actionNewLayer);
+ addAction(m_actionNewLayer);
addAction(m_actionDeleteRow);
addAction(m_actionDataInput);
addWidget(m_diLabel);
@@ -141,8 +141,8 @@ TimelineToolbar::TimelineToolbar() : QToolBar()
m_actionZoomIn->setShortcutContext(Qt::ApplicationShortcut);
actionGoToTime->setShortcut(QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::Key_T));
actionGoToTime->setShortcutContext(Qt::ApplicationShortcut);
- actionNewLayer->setShortcut(QKeySequence(Qt::ControlModifier | Qt::Key_L));
- actionNewLayer->setShortcutContext(Qt::ApplicationShortcut);
+ m_actionNewLayer->setShortcut(QKeySequence(Qt::ControlModifier | Qt::Key_L));
+ m_actionNewLayer->setShortcutContext(Qt::ApplicationShortcut);
m_connectSelectionChange = g_StudioApp.GetCore()->GetDispatch()->ConnectSelectionChange(
std::bind(&TimelineToolbar::onSelectionChange, this, std::placeholders::_1));
@@ -199,6 +199,11 @@ QString TimelineToolbar::getCurrentController() const
return m_currController;
}
+void TimelineToolbar::setNewLayerEnabled(bool enable)
+{
+ m_actionNewLayer->setEnabled(enable);
+}
+
void TimelineToolbar::updatePlayButtonState(bool started)
{
if (started) {
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h
index ebd0c7bb..0bd37377 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.h
@@ -63,6 +63,7 @@ public:
virtual ~TimelineToolbar();
void setTime(long totalMillis);
QString getCurrentController() const;
+ void setNewLayerEnabled(bool enable);
// IDataModelListener
void OnBeginDataModelNotifications() override;
@@ -96,6 +97,7 @@ private:
QAction *m_actionZoomIn;
QAction *m_actionZoomOut;
QAction *m_actionDataInput;
+ QAction *m_actionNewLayer;
qt3dsdm::TSignalConnectionPtr m_connectSelectionChange;
QSlider *m_scaleSlider;
QIcon m_iconStop;