diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-12-10 15:32:14 +0200 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-12-12 12:45:58 +0000 |
commit | 1858d8a2e09a9432131691daee7da52629413e47 (patch) | |
tree | 4ec1aa568584e6c4dc88f8677be5522984468607 /src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp | |
parent | 1311387fd3c6d6388e028b7471eabcd34641fee8 (diff) |
Improve inspector mesh chooser
- make the inspector mesh chooser a combobox if it only has primitives
- remove the extra space at the left when in combobox size
- remove useless size hints from choosers
- few minor tweaks
Task-number: QT3DS-2838
Change-Id: I9ecc4c4628303ebf00eadb174298c08e0c575389
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp')
-rw-r--r-- | src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index 361ad0e0..a3904d25 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -56,6 +56,7 @@ #include "Dialogs.h" #include "ProjectFile.h" #include "MaterialRefView.h" +#include "BasicObjectsModel.h" #include <QtCore/qtimer.h> #include <QtQml/qqmlcontext.h> @@ -68,6 +69,7 @@ InspectorControlView::InspectorControlView(const QSize &preferredSize, QWidget * : QQuickWidget(parent), TabNavigable(), m_inspectorControlModel(new InspectorControlModel(this)), + m_meshChooserView(new MeshChooserView(this)), m_instance(0), m_handle(0), m_preferredSize(preferredSize) @@ -80,6 +82,16 @@ InspectorControlView::InspectorControlView(const QSize &preferredSize, QWidget * m_selectionChangedConnection = g_StudioApp.GetCore()->GetDispatch()->ConnectSelectionChange( std::bind(&InspectorControlView::OnSelectionSet, this, std::placeholders::_1)); + + connect(m_meshChooserView, &MeshChooserView::meshSelected, this, + [this] (int handle, int instance, const QString &name) { + if (name.startsWith(QLatin1Char('#'))) { + if (m_inspectorControlModel) + m_inspectorControlModel->setPropertyValue(instance, handle, name); + } else { + setPropertyValueFromFilename(instance, handle, name); + } + }); } static bool isInList(const wchar_t **list, const Q3DStudio::CString &inStr) @@ -496,24 +508,18 @@ QObject *InspectorControlView::showFilesChooser(int handle, int instance, const QObject *InspectorControlView::showMeshChooser(int handle, int instance, const QPoint &point) { - if (!m_meshChooserView) { - m_meshChooserView = new MeshChooserView(this); - connect(m_meshChooserView, &MeshChooserView::meshSelected, this, - [this] (int handle, int instance, const QString &name) { - if (name.startsWith(QStringLiteral("#"))) { - if (m_inspectorControlModel) - m_inspectorControlModel->setPropertyValue(instance, handle, name); - } else { - setPropertyValueFromFilename(instance, handle, name); - } - }); - } - m_meshChooserView->setHandle(handle); m_meshChooserView->setInstance(instance); - CDialogs::showWidgetBrowser(this, m_meshChooserView, point); m_activeBrowser.setData(m_meshChooserView, handle, instance); + int numPrimitives = BasicObjectsModel::BasicMeshesModel().count(); + bool combo = numPrimitives == m_meshChooserView->numMeshes(); // make a combobox size popup + int comboH = qMin(m_meshChooserView->numMeshes(), 15) // max popup height: 15 items + * CStudioPreferences::controlBaseHeight(); + + CDialogs::showWidgetBrowser(this, m_meshChooserView, point, + CDialogs::WidgetBrowserAlign::ComboBox, + combo ? QSize(CStudioPreferences::valueWidth(), comboH) : QSize()); return m_meshChooserView; } |