diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-04-10 11:11:17 +0300 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-04-11 10:04:47 +0000 |
commit | 0548bdbbd3e18cbb045ed29378487f5690d05e8c (patch) | |
tree | 1bb0272181b916baa26707dfd8d6b9ee0fe84602 /src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp | |
parent | 00b40db9326f0b951b423a97b7302d87280f029b (diff) |
Support variants property on components
Also the following tasks are done in this commit:
- show active root component properties in the inspector.
- fix a crash when opening the light scope drop down.
- remove a lot of dynamic casts and useless code and cleanups, mainly
from the inspector classes. There is still more dynamic casts and memory
leaks that should be tackled in another commit.
- move a method to more appropriate place.
Change-Id: I5bec3858ba34d307ab6236ee665f1474302c1f57
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp')
-rw-r--r-- | src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp | 74 |
1 files changed, 63 insertions, 11 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index 0c04ba55..8ea1ffe5 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -62,6 +62,11 @@ #include "VariantTagDialog.h" #include "SlideView.h" #include "TimelineWidget.h" +#include "SelectedValue.h" +#include "Qt3DSDMInspectable.h" +#include "Qt3DSDMSlides.h" +#include "Qt3DSDMMaterialInspectable.h" +#include "GuideInspectable.h" #include <QtCore/qtimer.h> #include <QtQml/qqmlcontext.h> @@ -262,7 +267,7 @@ QAbstractItemModel *InspectorControlView::inspectorControlModel() const QString InspectorControlView::titleText() const { if (m_inspectableBase) { - Q3DStudio::CString theName = m_inspectableBase->GetName(); + Q3DStudio::CString theName = m_inspectableBase->getName(); if (theName == L"PathAnchorPoint") return tr("Anchor Point"); else @@ -332,7 +337,7 @@ void InspectorControlView::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inIn // which will invalidate the inspectable anyway, so in reality we are only interested in name // property here if (inProperty == bridge->GetNameProperty() && m_inspectableBase - && m_inspectableBase->IsValid()) { + && m_inspectableBase->isValid()) { Q_EMIT titleChanged(); } } @@ -377,7 +382,7 @@ QColor InspectorControlView::titleColor(int instance, int handle) const QString InspectorControlView::titleIcon() const { if (m_inspectableBase) - return CStudioObjectTypes::GetNormalIconName(m_inspectableBase->GetObjectType()); + return CStudioObjectTypes::GetNormalIconName(m_inspectableBase->getObjectType()); return {}; } @@ -391,18 +396,65 @@ bool InspectorControlView::isEditable(int handle) const return true; } -void InspectorControlView::OnSelectionSet(Q3DStudio::SSelectedValue inSelectable) +void InspectorControlView::OnSelectionSet(Q3DStudio::SSelectedValue selectable) { - updateInspectable(g_StudioApp.GetInspectableFromSelectable(inSelectable)); + CInspectableBase *inspectable = createInspectableFromSelectable(selectable); + + if (inspectable && !inspectable->isValid()) + inspectable = nullptr; + + setInspectable(inspectable); } -void InspectorControlView::updateInspectable(CInspectableBase *inInspectable) +CInspectableBase *InspectorControlView::createInspectableFromSelectable( + Q3DStudio::SSelectedValue selectable) { - if (inInspectable != nullptr) { - if (inInspectable->IsValid() == false) - inInspectable = nullptr; + using namespace Q3DStudio; + + CInspectableBase *inspectableBase = nullptr; + if (!selectable.empty()) { + switch (selectable.getType()) { + case SelectedValueTypes::Slide: { + // TODO: seems like slides are not directly selectable, this should be removed. + auto selectableInstance = selectable.getData<SSlideInstanceWrapper>().m_Instance; + inspectableBase = new Qt3DSDMInspectable(selectableInstance); + } break; + + case SelectedValueTypes::MultipleInstances: + case SelectedValueTypes::Instance: { + CDoc *doc = g_StudioApp.GetCore()->GetDoc(); + // Note: Inspector doesn't support multiple selection + qt3dsdm::TInstanceHandleList selectedsInstances = selectable.GetSelectedInstances(); + Qt3DSDMInstanceHandle selectedInstance = selectedsInstances[0]; + if (selectedsInstances.size() == 1 + && doc->GetDocumentReader().IsInstance(selectedInstance)) { + CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); + qt3dsdm::Qt3DSDMSlideHandle activeSlide = doc->GetActiveSlide(); + + // Scene or Component (when being edited) + if (selectedInstance == bridge->GetOwningComponentInstance(activeSlide)) { + Qt3DSDMInstanceHandle activeSlideInstance = doc->GetStudioSystem() + ->GetSlideSystem()->GetSlideInstance(activeSlide); + inspectableBase = new Qt3DSDMInspectable(selectedInstance, activeSlideInstance); + } else if (bridge->IsMaterialBaseInstance(selectedInstance)) { + inspectableBase = new Qt3DSDMMaterialInspectable(selectedInstance); + } else { + inspectableBase = new Qt3DSDMInspectable(selectedInstance); + } + } + } break; + + case SelectedValueTypes::Guide: { + qt3dsdm::Qt3DSDMGuideHandle guide = selectable.getData<qt3dsdm::Qt3DSDMGuideHandle>(); + inspectableBase = new GuideInspectable(guide); + } break; + + default: + break; // Ignore slide insertion and unknown selectable types + }; } - setInspectable(inInspectable); + + return inspectableBase; } void InspectorControlView::setInspectable(CInspectableBase *inInspectable) @@ -810,7 +862,7 @@ void InspectorControlView::OnBeginDataModelNotifications() void InspectorControlView::OnEndDataModelNotifications() { CInspectableBase *inspectable = m_inspectorControlModel->inspectable(); - if (inspectable && !inspectable->IsValid()) + if (inspectable && !inspectable->isValid()) OnSelectionSet(Q3DStudio::SSelectedValue()); m_inspectorControlModel->refresh(); |