From db2cc087da3453066180b45df03ca36777670d0a Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 18 Sep 2018 14:27:19 +0300 Subject: Fix toggle shy/locked for multiple selected objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QT3DS-2354 Change-Id: Ie108b336a24f889607e12d46984dcf686d099ee4 Reviewed-by: Mahmoud Badri Reviewed-by: Janne Kangas Reviewed-by: Tomi Korpipää --- .../Client/Code/Core/Doc/DocumentEditor.cpp | 23 +++++++++ .../Client/Code/Core/Doc/IDocumentEditor.h | 2 + src/Authoring/Studio/Application/StudioApp.cpp | 58 ++++++++++++---------- src/Authoring/Studio/Application/StudioApp.h | 2 + .../TimelineGraphicsView/TimelineGraphicsScene.cpp | 18 +------ .../TimelineGraphicsView/TimelineGraphicsScene.h | 2 - 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(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 ParseScriptFile(const Q3DStudio::CFilePath &inFullPathToDocument, std::shared_ptr 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(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; -- cgit v1.2.3