summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-03-15 11:25:57 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2019-03-15 11:05:47 +0000
commita08bb2007ba3965a875801955b9fa122c19e8255 (patch)
treeb2428399e80801db39d74a76d76de5f28dfe4979
parentcb5beeb75b9a169e140277fdb66aa9c578ff0f69 (diff)
Show warning instead of empty popup when there are no valid refmats
Task-number: QT3DS-3141 Change-Id: I4f3c87af213199bd4b743b79b36b79e2d5c4d09f Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp29
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/MaterialRefView.cpp21
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/MaterialRefView.h2
3 files changed, 33 insertions, 19 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index f842a9ca..eb1ece18 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -723,27 +723,26 @@ QObject *InspectorControlView::showMaterialReference(int handle, int instance, c
disconnect(m_matRefListWidget, &QListWidget::itemClicked, nullptr, nullptr);
disconnect(m_matRefListWidget, &QListWidget::itemDoubleClicked, nullptr, nullptr);
- const int numMats = m_matRefListWidget->refreshMaterials(instance, handle);
- const int popupHeight = qMin(numMats, 10) * CStudioPreferences::controlBaseHeight();
-
+ const QSize popupSize = m_matRefListWidget->refreshMaterials(instance, handle);
CDialogs::showWidgetBrowser(this, m_matRefListWidget, point,
- CDialogs::WidgetBrowserAlign::ComboBox,
- QSize(CStudioPreferences::valueWidth(), popupHeight));
+ CDialogs::WidgetBrowserAlign::ComboBox, popupSize);
m_activeBrowser.setData(m_matRefListWidget, handle, instance);
connect(m_matRefListWidget, &QListWidget::itemClicked, this,
[instance, handle](QListWidgetItem *item) {
auto selectedInstance = item->data(Qt::UserRole).toInt();
- qt3dsdm::SValue value;
- CDoc *doc = g_StudioApp.GetCore()->GetDoc();
- const auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
- propertySystem->GetInstancePropertyValue(instance, handle, value);
- auto refInstance = doc->GetDataModelObjectReferenceHelper()->Resolve(value, instance);
- if (selectedInstance != refInstance) {
- auto objRef = doc->GetDataModelObjectReferenceHelper()->GetAssetRefValue(
- selectedInstance, instance, CRelativePathTools::EPATHTYPE_GUID);
- Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QObject::tr("Set Property"))
- ->SetInstancePropertyValue(instance, handle, objRef);
+ if (selectedInstance > 0) {
+ qt3dsdm::SValue value;
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ const auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
+ propertySystem->GetInstancePropertyValue(instance, handle, value);
+ auto refInstance = doc->GetDataModelObjectReferenceHelper()->Resolve(value, instance);
+ if (selectedInstance != refInstance) {
+ auto objRef = doc->GetDataModelObjectReferenceHelper()->GetAssetRefValue(
+ selectedInstance, instance, CRelativePathTools::EPATHTYPE_GUID);
+ Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QObject::tr("Set Property"))
+ ->SetInstancePropertyValue(instance, handle, objRef);
+ }
}
});
connect(m_matRefListWidget, &QListWidget::itemDoubleClicked, this, [this]() {
diff --git a/src/Authoring/Studio/Palettes/Inspector/MaterialRefView.cpp b/src/Authoring/Studio/Palettes/Inspector/MaterialRefView.cpp
index 10fdedd5..b2d1a595 100644
--- a/src/Authoring/Studio/Palettes/Inspector/MaterialRefView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/MaterialRefView.cpp
@@ -51,9 +51,9 @@ MaterialRefView::MaterialRefView(QWidget *parent)
* @param instance The instance that owns the property handle
* @param handle The property handle this materials list is for
*
- * @return number of items in the list
+ * @return necessary size for the dialog
*/
-int MaterialRefView::refreshMaterials(int instance, int handle)
+QSize MaterialRefView::refreshMaterials(int instance, int handle)
{
clear(); // clear old material list
@@ -93,7 +93,22 @@ int MaterialRefView::refreshMaterials(int instance, int handle)
setCurrentItem(matItem);
}
- return (int)mats.size();
+ if (count() == 0) {
+ // Show an unselectable dummy item
+ static const QPixmap pixWarning = QPixmap(":/images/warning.png");
+ QListWidgetItem *matItem = new QListWidgetItem(this);
+ matItem->setData(Qt::DisplayRole, tr("No animatable materials found"));
+ matItem->setData(Qt::DecorationRole, pixWarning);
+ matItem->setData(Qt::UserRole, -1);
+ setSelectionMode(QAbstractItemView::NoSelection);
+ } else {
+ setSelectionMode(QAbstractItemView::SingleSelection);
+ }
+
+ QSize widgetSize(CStudioPreferences::valueWidth(),
+ qMin(10, count()) * CStudioPreferences::controlBaseHeight());
+
+ return widgetSize;
}
void MaterialRefView::updateSelection()
diff --git a/src/Authoring/Studio/Palettes/Inspector/MaterialRefView.h b/src/Authoring/Studio/Palettes/Inspector/MaterialRefView.h
index 157b9a6b..d4131cda 100644
--- a/src/Authoring/Studio/Palettes/Inspector/MaterialRefView.h
+++ b/src/Authoring/Studio/Palettes/Inspector/MaterialRefView.h
@@ -40,7 +40,7 @@ class MaterialRefView : public QListWidget
public:
explicit MaterialRefView(QWidget *parent = nullptr);
- int refreshMaterials(int instance, int handle);
+ QSize refreshMaterials(int instance, int handle);
void updateSelection();
protected: