diff options
Diffstat (limited to 'src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp')
-rw-r--r-- | src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp | 90 |
1 files changed, 62 insertions, 28 deletions
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp index e4e0379f..f991f467 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp @@ -65,7 +65,6 @@ #include "SelectedValue.h" #include "Qt3DSDMInspectable.h" #include "Qt3DSDMSlides.h" -#include "Qt3DSDMMaterialInspectable.h" #include "GuideInspectable.h" #include <QtCore/qtimer.h> @@ -89,6 +88,13 @@ InspectorControlView::InspectorControlView(const QSize &preferredSize, QWidget * dispatch->AddPresentationChangeListener(this); dispatch->AddDataModelListener(this); + m_shaderStatusUpdateTimer.setSingleShot(true); + m_shaderStatusUpdateTimer.setInterval(3000); + + connect(&m_shaderStatusUpdateTimer, &QTimer::timeout, [&](){ + m_inspectorControlModel->refresh(); + }); + connect(m_meshChooserView, &MeshChooserView::meshSelected, this, [this] (int handle, int instance, const QString &name) { if (name.startsWith(QLatin1Char('#'))) { @@ -171,6 +177,9 @@ void InspectorControlView::onFilesChanged( L"material", L"shader", L"materialdef", nullptr }; + static const wchar_t *effectExtensions[] = { + L"effect", nullptr + }; static const wchar_t *fontExtensions[] = { L"ttf", L"otf", nullptr @@ -190,6 +199,8 @@ void InspectorControlView::onFilesChanged( qt3dsdm::binary_sort_insert_unique(m_fileList, relativePath); else if (record.m_ModificationType == Q3DStudio::FileModificationType::Destroyed) qt3dsdm::binary_sort_erase(m_fileList, relativePath); + else + m_shaderStatusUpdateTimer.start(); } else if (isInList(fontExtensions, record.m_File.GetExtension())) { if (record.m_ModificationType == Q3DStudio::FileModificationType::Created || record.m_ModificationType == Q3DStudio::FileModificationType::Destroyed) { @@ -201,6 +212,8 @@ void InspectorControlView::onFilesChanged( g_StudioApp.GetCore()->getProjectFile().loadSubpresentationsAndDatainputs( g_StudioApp.m_subpresentations, g_StudioApp.m_dataInputDialogItems); m_inspectorControlModel->refreshRenderables(); + } else if (isInList(effectExtensions, record.m_File.GetExtension())) { + m_shaderStatusUpdateTimer.start(); } } } @@ -278,8 +291,7 @@ QString InspectorControlView::titleText() const bool InspectorControlView::isRefMaterial(int instance) const { - auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); - return bridge->IsReferencedMaterialInstance(instance); + return getBridge()->IsReferencedMaterialInstance(instance); } QString InspectorControlView::noneString() const @@ -289,16 +301,21 @@ QString InspectorControlView::noneString() const bool InspectorControlView::canLinkProperty(int instance, int handle) const { - CDoc *doc = g_StudioApp.GetCore()->GetDoc(); - const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); + if (!instance || !handle) + return false; - if (bridge->isInsideMaterialContainer(instance)) + if (getBridge()->isInsideMaterialContainer(instance)) return false; - if (bridge->IsMaterialBaseInstance(instance)) // all material types are unlinkable + if (handle == getBridge()->GetSceneAsset().m_Eyeball.m_Property) // eyeball is unlinkable return false; - if (handle == bridge->GetSceneAsset().m_Eyeball.m_Property) // eyeball is unlinkable + CDoc *doc = g_StudioApp.GetCore()->GetDoc(); + + // Disallow linking of properties that refer to images as unlinking them is not trivial at all. + qt3dsdm::AdditionalMetaDataType::Value thePropertyMetaData = + doc->GetStudioSystem()->GetPropertySystem()->GetAdditionalMetaDataType(instance, handle); + if (thePropertyMetaData == qt3dsdm::AdditionalMetaDataType::Image) return false; return doc->GetDocumentReader().CanPropertyBeLinked(instance, handle); @@ -307,6 +324,7 @@ bool InspectorControlView::canLinkProperty(int instance, int handle) const bool InspectorControlView::canOpenInInspector(int instance, int handle) const { const auto doc = g_StudioApp.GetCore()->GetDoc(); + qt3dsdm::SValue value; doc->GetPropertySystem()->GetInstancePropertyValue(instance, handle, value); if (!value.empty() && value.getType() == qt3dsdm::DataModelDataType::Long4) { @@ -319,12 +337,12 @@ bool InspectorControlView::canOpenInInspector(int instance, int handle) const void InspectorControlView::openInInspector() { const auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); + qt3dsdm::SValue value; doc->GetPropertySystem()->GetInstancePropertyValue(m_contextMenuInstance, m_contextMenuHandle, value); qt3dsdm::SLong4 guid = qt3dsdm::get<qt3dsdm::SLong4>(value); - const auto instance = bridge->GetInstanceByGUID(guid); + const auto instance = getBridge()->GetInstanceByGUID(guid); doc->SelectDataModelObject(instance); } @@ -333,11 +351,10 @@ void InspectorControlView::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inIn { m_inspectorControlModel->notifyPropertyChanged(inInstance, inProperty); - auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); // titleChanged implies icon change too, but that will only occur if inspectable type changes, // which will invalidate the inspectable anyway, so in reality we are only interested in name // property here - if (inProperty == bridge->GetNameProperty() && m_inspectableBase + if (inProperty == getBridge()->GetNameProperty() && m_inspectableBase && m_inspectableBase->isValid()) { Q_EMIT titleChanged(); } @@ -349,13 +366,12 @@ void InspectorControlView::onChildAdded(int inChild) if (m_activeBrowser.isActive() && m_activeBrowser.m_browser == m_objectReferenceView) m_activeBrowser.clear(); - const auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); - if (bridge->IsCustomMaterialInstance(inChild)) { + if (getBridge()->IsCustomMaterialInstance(inChild)) { QVector<qt3dsdm::Qt3DSDMInstanceHandle> refMats; + auto doc = g_StudioApp.GetCore()->GetDoc(); doc->getSceneReferencedMaterials(doc->GetSceneInstance(), refMats); for (auto &refMat : qAsConst(refMats)) { - if ((int)bridge->getMaterialReference(refMat) == inChild) + if (int(getBridge()->getMaterialReference(refMat)) == inChild) g_StudioApp.GetCore()->GetDispatch()->FireImmediateRefreshInstance(refMat); } } @@ -401,8 +417,10 @@ void InspectorControlView::OnSelectionSet(Q3DStudio::SSelectedValue selectable) { CInspectableBase *inspectable = createInspectableFromSelectable(selectable); - if (inspectable && !inspectable->isValid()) + if (inspectable && !inspectable->isValid()) { + delete inspectable; inspectable = nullptr; + } setInspectable(inspectable); } @@ -429,17 +447,14 @@ CInspectableBase *InspectorControlView::createInspectableFromSelectable( if (selectedsInstances.size() == 1) { Qt3DSDMInstanceHandle selectedInstance = selectedsInstances[0]; if (doc->GetDocumentReader().IsInstance(selectedInstance)) { - auto *bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); qt3dsdm::Qt3DSDMSlideHandle activeSlide = doc->GetActiveSlide(); // Scene or Component (when being edited) - if (selectedInstance == bridge->GetOwningComponentInstance(activeSlide)) { + if (selectedInstance == getBridge()->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); } @@ -464,9 +479,16 @@ void InspectorControlView::setInspectable(CInspectableBase *inInspectable) { if (m_inspectableBase != inInspectable) { m_activeBrowser.clear(); + + CInspectableBase *oldInspectableBase = m_inspectableBase; + m_inspectableBase = inInspectable; m_inspectorControlModel->setInspectable(inInspectable); + // Delete old inspectable base only after setting the new inspectable is completed, + // as model may still need it to commit pending transaction + delete oldInspectableBase; + Q_EMIT titleChanged(); m_variantsGroupModel->refresh(); @@ -480,7 +502,6 @@ void InspectorControlView::showContextMenu(int x, int y, int handle, int instanc QMenu theContextMenu; - auto doc = g_StudioApp.GetCore()->GetDoc(); if (canOpenInInspector(instance, handle)) { auto action = theContextMenu.addAction(tr("Open in Inspector")); @@ -488,6 +509,7 @@ void InspectorControlView::showContextMenu(int x, int y, int handle, int instanc } if (canLinkProperty(instance, handle)) { + auto doc = g_StudioApp.GetCore()->GetDoc(); bool isLinked = doc->GetDocumentReader().IsPropertyLinked(instance, handle); auto action = theContextMenu.addAction(isLinked ? tr("Unlink Property from Master Slide") : tr("Link Property from Master Slide")); @@ -634,6 +656,14 @@ QObject *InspectorControlView::showImageChooser(int handle, int instance, const }); } + // For basic materials edit IBL Override of the referenced material. This applies only for basic + // materials as IBL Override is disabled for referenced (and default basic) materials. + if (handle == getBridge()->GetObjectDefinitions().m_MaterialBase.m_IblProbe.m_Property) { + int refInstance = getBridge()->getMaterialReference(instance); + if (refInstance) + instance = refInstance; + } + m_imageChooserView->setHandle(handle); m_imageChooserView->setInstance(instance); @@ -838,10 +868,9 @@ QColor InspectorControlView::showColorDialog(const QColor &color, int instance, { bool showAlpha = false; if (instance && handle) { - auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() - ->GetClientDataModelBridge(); - showAlpha = bridge->getBGColorProperty(instance).GetHandleValue() == handle - || bridge->getTextColorProperty(instance).GetHandleValue() == handle; + showAlpha = getBridge()->getBGColorProperty(instance).GetHandleValue() == handle + || getBridge()->getTextColorProperty(instance).GetHandleValue() == handle + || getBridge()->IsCustomMaterialInstance(instance); } m_currentColor = color; @@ -854,9 +883,9 @@ QColor InspectorControlView::showColorDialog(const QColor &color, int instance, return currentColor; } -bool InspectorControlView::toolTipsEnabled() +bool InspectorControlView::toolTipsEnabled() const { - return CStudioPreferences::ShouldShowTooltips(); + return CStudioPreferences::isTooltipsOn(); } // Converts a path that is relative to the current presentation to be relative to @@ -919,6 +948,11 @@ void InspectorControlView::OnEndDataModelNotifications() } } +CClientDataModelBridge *InspectorControlView::getBridge() const +{ + return g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); +} + void InspectorControlView::OnImmediateRefreshInstanceSingle(qt3dsdm::Qt3DSDMInstanceHandle inInstance) { m_inspectorControlModel->refresh(); |