summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-09-18 14:27:19 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-09-19 07:53:07 +0000
commitdb2cc087da3453066180b45df03ca36777670d0a (patch)
treeed171d80669803bb28e53259c348cc556d95a97e
parent8dd70dd8db835816bf919a00bb8d41a76a05220f (diff)
Fix toggle shy/locked for multiple selected objects
Task-number: QT3DS-2354 Change-Id: Ie108b336a24f889607e12d46984dcf686d099ee4 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp23
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h2
-rw-r--r--src/Authoring/Studio/Application/StudioApp.cpp58
-rw-r--r--src/Authoring/Studio/Application/StudioApp.h2
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp18
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h2
6 files changed, 61 insertions, 44 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index 0b9b4d8f..3b2b76cc 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -4286,6 +4286,29 @@ public:
}
}
+ void toggleBoolPropertyOnSelected(TPropertyHandle property) override
+ {
+ qt3dsdm::IPropertySystem *propertySystem = m_Doc.GetStudioSystem()->GetPropertySystem();
+ qt3dsdm::TInstanceHandleList selectedInstances
+ = m_Doc.GetSelectedValue().GetSelectedInstances();
+
+ if (selectedInstances.size() > 0) {
+ bool boolValue = false;
+ SValue value;
+ for (size_t idx = 0, end = selectedInstances.size(); idx < end; ++idx) {
+ qt3dsdm::Qt3DSDMInstanceHandle handle(selectedInstances[idx]);
+ if (handle.Valid()) {
+ if (value.empty()) {
+ // First valid handle selects if all are hidden/unhidden
+ propertySystem->GetInstancePropertyValue(handle, property, value);
+ boolValue = !qt3dsdm::get<bool>(value);
+ }
+ propertySystem->SetInstancePropertyValue(handle, property, boolValue);
+ }
+ }
+ }
+ }
+
void BuildDAEMap(const TFileModificationList &inList)
{
for (size_t fileIdx = 0, fileEnd = inList.size(); fileIdx < fileEnd; ++fileIdx) {
diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h
index 824b80ec..468327a6 100644
--- a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h
+++ b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h
@@ -420,6 +420,8 @@ public:
virtual void ExternalizePath(TInstanceHandle path) = 0;
virtual void InternalizePath(TInstanceHandle path) = 0;
+ virtual void toggleBoolPropertyOnSelected(TPropertyHandle property) = 0;
+
static std::shared_ptr<IDOMReader>
ParseScriptFile(const Q3DStudio::CFilePath &inFullPathToDocument,
std::shared_ptr<qt3dsdm::IStringTable> inStringTable,
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp
index 48cd758c..f7dc7b42 100644
--- a/src/Authoring/Studio/Application/StudioApp.cpp
+++ b/src/Authoring/Studio/Application/StudioApp.cpp
@@ -2011,32 +2011,38 @@ void CStudioApp::OnUndefinedDatainputsFail(
void CStudioApp::toggleEyeball()
{
- CDoc *theDoc = m_core->GetDoc();
- qt3dsdm::IPropertySystem *propertySystem = theDoc->GetStudioSystem()->GetPropertySystem();
- qt3dsdm::TInstanceHandleList selectedInstances
- = theDoc->GetSelectedValue().GetSelectedInstances();
-
- if (selectedInstances.size() > 0) {
- Q3DStudio::ScopedDocumentEditor editor(*theDoc,
- L"Visibility Toggle",
- __FILE__, __LINE__);
- bool boolValue = false;
- SValue value;
- for (size_t idx = 0, end = selectedInstances.size(); idx < end; ++idx) {
- qt3dsdm::Qt3DSDMInstanceHandle handle(selectedInstances[idx]);
-
- if (handle.Valid()) {
- qt3dsdm::Qt3DSDMPropertyHandle property
- = theDoc->GetStudioSystem()->GetClientDataModelBridge()
- ->GetSceneAsset().m_Eyeball;
- if (value.empty()) {
- // First valid handle selects if all are hidden/unhidden
- propertySystem->GetInstancePropertyValue(handle, property, value);
- boolValue = !qt3dsdm::get<bool>(value);
- }
- editor->SetInstancePropertyValue(handle, property, boolValue);
- }
- }
+ CDoc *doc = m_core->GetDoc();
+ if (doc->getSelectedInstancesCount() > 0) {
+ qt3dsdm::Qt3DSDMPropertyHandle property
+ = doc->GetStudioSystem()->GetClientDataModelBridge()->GetSceneAsset().m_Eyeball;
+ SCOPED_DOCUMENT_EDITOR(*doc, tr("Visibility Toggle"))
+ ->toggleBoolPropertyOnSelected(property);
+ }
+}
+
+void CStudioApp::toggleShy()
+{
+ CDoc *doc = m_core->GetDoc();
+ if (doc->getSelectedInstancesCount() > 0) {
+ qt3dsdm::Qt3DSDMPropertyHandle property
+ = doc->GetStudioSystem()->GetClientDataModelBridge()->GetSceneAsset().m_Shy;
+ SCOPED_DOCUMENT_EDITOR(*doc, tr("Shy Toggle"))
+ ->toggleBoolPropertyOnSelected(property);
+ }
+}
+
+void CStudioApp::toggleLocked()
+{
+ CDoc *doc = m_core->GetDoc();
+ if (doc->getSelectedInstancesCount() > 0) {
+ qt3dsdm::Qt3DSDMPropertyHandle property
+ = doc->GetStudioSystem()->GetClientDataModelBridge()->GetSceneAsset().m_Locked;
+ SCOPED_DOCUMENT_EDITOR(*doc, tr("Locked Toggle"))
+ ->toggleBoolPropertyOnSelected(property);
+
+ // Since you are not supposed to be able to select locked objects,
+ // we just assume anything toggled was actually locked and deselect everything
+ doc->DeselectAllItems();
}
}
diff --git a/src/Authoring/Studio/Application/StudioApp.h b/src/Authoring/Studio/Application/StudioApp.h
index a852aaee..c4b10ca9 100644
--- a/src/Authoring/Studio/Application/StudioApp.h
+++ b/src/Authoring/Studio/Application/StudioApp.h
@@ -214,6 +214,8 @@ public:
void SetAutosaveEnabled(bool enabled);
void SetAutosaveInterval(int interval);
void toggleEyeball();
+ void toggleShy();
+ void toggleLocked();
void showPresentationIdUniqueWarning();
void showInvalidFilenameWarning();
void checkDeletedDatainputs();
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
index 506d2484..1d58fd9c 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
@@ -325,13 +325,13 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::ShiftModifier | Qt::Key_H));
action->setShortcutContext(Qt::ApplicationShortcut);
- connect(action, &QAction::triggered, this, &TimelineGraphicsScene::handleShySelected);
+ connect(action, &QAction::triggered, &g_StudioApp, &CStudioApp::toggleShy);
timelineWidget->addAction(action);
action = new QAction(this);
action->setShortcut(QKeySequence(Qt::ControlModifier | Qt::Key_H));
action->setShortcutContext(Qt::ApplicationShortcut);
- connect(action, &QAction::triggered, this, &TimelineGraphicsScene::handleLockSelected);
+ connect(action, &QAction::triggered, &g_StudioApp, &CStudioApp::toggleLocked);
timelineWidget->addAction(action);
}
@@ -1041,20 +1041,6 @@ void TimelineGraphicsScene::handleEditComponent()
}
}
-void TimelineGraphicsScene::handleShySelected()
-{
- RowTree *selectedRow = m_rowManager->selectedRow();
- if (selectedRow)
- selectedRow->toggleShy();
-}
-
-void TimelineGraphicsScene::handleLockSelected()
-{
- RowTree *selectedRow = m_rowManager->selectedRow();
- if (selectedRow)
- selectedRow->toggleLocked();
-}
-
void TimelineGraphicsScene::handleApplicationFocusLoss()
{
// Hide the timebar tooltip if application loses focus
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h
index e452c12b..bf02d3bb 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h
@@ -116,8 +116,6 @@ private:
void handleMakeComponent();
void handleCopyObjectPath();
void handleEditComponent();
- void handleShySelected();
- void handleLockSelected();
void handleApplicationFocusLoss();
QGraphicsLinearLayout *m_layoutRoot;