summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Inspector
diff options
context:
space:
mode:
Diffstat (limited to 'src/Authoring/Studio/Palettes/Inspector')
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp16
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h2
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp14
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h29
4 files changed, 52 insertions, 9 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
index 3ee2a01c..2335ba2d 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
@@ -201,18 +201,18 @@ void InspectorControlModel::notifyInstancePropertyValue(qt3dsdm::Qt3DSDMInstance
Q_EMIT dataChanged(index(0), index(rowCount() - 1));
}
-QVariant InspectorControlModel::getPropertyValue(long instance, int handle)
+bool InspectorControlModel::hasInstanceProperty(long instance, int handle)
{
- for (int row = 0; row < m_groupElements.count(); ++row) {
- auto group = m_groupElements[row];
- for (int p = 0; p < group.controlElements.count(); ++p) {
- QVariant& element = group.controlElements[p];
+ for (const auto &group : qAsConst(m_groupElements)) {
+ for (const auto &element : qAsConst(group.controlElements)) {
InspectorControlBase *property = element.value<InspectorControlBase *>();
- if (property->m_property == qt3dsdm::CDataModelHandle(handle))
- return property->m_value;
+ if (property->m_property == qt3dsdm::CDataModelHandle(handle)
+ && property->m_instance == qt3dsdm::CDataModelHandle(instance)) {
+ return true;
+ }
}
}
- return {};
+ return false;
}
bool InspectorControlModel::isInsideMaterialContainer() const
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
index a3140b3e..630689ae 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
@@ -130,7 +130,7 @@ public:
void refresh();
void saveIfMaterial(qt3dsdm::Qt3DSDMInstanceHandle instance);
- QVariant getPropertyValue(long instance, int handle);
+ bool hasInstanceProperty(long instance, int handle);
qt3dsdm::SValue currentPropertyValue(long instance, int handle) const;
QString currentControllerValue(long instance, int handle) const;
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index 10d79c02..e427c2de 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -362,6 +362,7 @@ void InspectorControlView::updateInspectable(CInspectableBase *inInspectable)
void InspectorControlView::setInspectable(CInspectableBase *inInspectable)
{
if (m_inspectableBase != inInspectable) {
+ m_activeBrowser.clear();
m_inspectableBase = inInspectable;
m_inspectorControlModel->setInspectable(inInspectable);
@@ -469,6 +470,7 @@ QObject *InspectorControlView::showImageChooser(int handle, int instance, const
m_imageChooserView->setInstance(instance);
CDialogs::showWidgetBrowser(this, m_imageChooserView, point);
+ m_activeBrowser.setData(m_imageChooserView, handle, instance);
return m_imageChooserView;
}
@@ -487,6 +489,7 @@ QObject *InspectorControlView::showFilesChooser(int handle, int instance, const
m_fileChooserView->setInstance(instance);
CDialogs::showWidgetBrowser(this, m_fileChooserView, point);
+ m_activeBrowser.setData(m_fileChooserView, handle, instance);
return m_fileChooserView;
}
@@ -510,6 +513,7 @@ QObject *InspectorControlView::showMeshChooser(int handle, int instance, const Q
m_meshChooserView->setInstance(instance);
CDialogs::showWidgetBrowser(this, m_meshChooserView, point);
+ m_activeBrowser.setData(m_meshChooserView, handle, instance);
return m_meshChooserView;
}
@@ -529,6 +533,7 @@ QObject *InspectorControlView::showTextureChooser(int handle, int instance, cons
m_textureChooserView->setInstance(instance);
CDialogs::showWidgetBrowser(this, m_textureChooserView, point);
+ m_activeBrowser.setData(m_textureChooserView, handle, instance);
return m_textureChooserView;
}
@@ -570,6 +575,7 @@ QObject *InspectorControlView::showObjectReference(int handle, int instance, con
}
CDialogs::showWidgetBrowser(this, m_objectReferenceView, point);
+ m_activeBrowser.setData(m_objectReferenceView, handle, instance);
connect(m_objectReferenceView, &ObjectBrowserView::selectionChanged,
this, [this, doc, handle, instance] {
@@ -606,6 +612,7 @@ QObject *InspectorControlView::showMaterialReference(int handle, int instance, c
CDialogs::showWidgetBrowser(this, m_matRefListWidget, point,
CDialogs::WidgetBrowserAlign::ComboBox,
QSize(CStudioPreferences::valueWidth(), popupHeight));
+ m_activeBrowser.setData(m_matRefListWidget, handle, instance);
connect(m_matRefListWidget, &QListWidget::itemClicked, this,
[doc, propertySystem, instance, handle](QListWidgetItem *item) {
@@ -660,6 +667,7 @@ void InspectorControlView::showDataInputChooser(int handle, int instance, const
handle, instance);
CDialogs::showWidgetBrowser(this, m_dataInputChooserView, point,
CDialogs::WidgetBrowserAlign::ToolButton);
+ m_activeBrowser.setData(m_dataInputChooserView, handle, instance);
}
QColor InspectorControlView::showColorDialog(const QColor &color)
@@ -702,6 +710,12 @@ void InspectorControlView::OnEndDataModelNotifications()
if (inspectable && !inspectable->IsValid())
OnSelectionSet(Q3DStudio::SSelectedValue());
m_inspectorControlModel->refresh();
+
+ // Check if the instance/handle pair still has an active UI control. If not, close browser.
+ if (m_activeBrowser.isActive() && !m_inspectorControlModel->hasInstanceProperty(
+ m_activeBrowser.m_instance, m_activeBrowser.m_handle)) {
+ m_activeBrowser.clear();
+ }
}
void InspectorControlView::OnImmediateRefreshInstanceSingle(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
index a5661d74..400a26b4 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
@@ -144,6 +144,35 @@ private:
QSize m_preferredSize;
QColor m_currentColor;
+
+ class ActiveBrowserData
+ {
+ public:
+ void setData(QWidget *browser, int handle, int instance)
+ {
+ m_activeBrowser = browser;
+ m_handle = handle;
+ m_instance = instance;
+ }
+ void clear()
+ {
+ if (isActive())
+ m_activeBrowser->close();
+ m_activeBrowser.clear();
+ m_handle = -1;
+ m_instance = -1;
+ }
+ bool isActive() const
+ {
+ return !m_activeBrowser.isNull() && m_activeBrowser->isVisible();
+ }
+
+ QPointer<QWidget> m_activeBrowser = nullptr;
+ int m_handle = -1;
+ int m_instance = -1;
+ };
+
+ ActiveBrowserData m_activeBrowser;
};
#endif // INSPECTORCONTROLVIEW_H