diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-08-16 13:22:08 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-08-20 08:06:52 +0000 |
commit | 91ed79dc3d59b02ba2834f3c7155b7461607d8d8 (patch) | |
tree | 8799f2bcb81fe4bd17a25850da68bc406089a06e /src/Authoring/Studio/Palettes | |
parent | 6fddac4ca5fdb10d0f3cb7d247ed20bc362c5013 (diff) |
Display sub-presentations in inspector image choosers
Subpresentations can now be selected as images from image chooser.
Selecting a subpresentation will show it also as the image
property value of the material. Manually setting subpresentation
from image properties is disabled, though the value is still shown.
Task-number: QT3DS-2090
Change-Id: Ie02898c0e111c16b2b27368b03901d2adc20fa91
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Janne Kangas <janne.kangas@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes')
10 files changed, 76 insertions, 15 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp index 681c5e5c..f20c3425 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp @@ -136,8 +136,15 @@ QVariant ChooserModelBase::data(const QModelIndex &index, int role) const return path == m_currentFile; } + case QFileSystemModel::FileNameRole: { + QString displayName = specialDisplayName(item); + if (displayName.isEmpty()) + displayName = m_model->data(item.index, QFileSystemModel::FileNameRole).toString(); + return displayName; + } + default: - return m_model->data(item.index, role); + return m_model->data(item.index, role).toString(); } } } @@ -179,8 +186,6 @@ void ChooserModelBase::setCurrentFile(const QString &path) m_currentFile = fullPath; - const int fixedItemCount = fixedItems.count(); - if (previousRow != -1) Q_EMIT dataChanged(index(previousRow), index(previousRow)); @@ -377,6 +382,12 @@ EStudioObjectType ChooserModelBase::getIconType(const QString &path) const return Q3DStudio::ImportUtils::GetObjectFileTypeForFile(Q3DStudio::CFilePath(path)).m_IconType; } +QString ChooserModelBase::specialDisplayName(const ChooserModelBase::TreeItem &item) const +{ + Q_UNUSED(item) + return {}; +} + QString ChooserModelBase::getIconName(const QString &path) const { QString iconName; diff --git a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.h b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.h index cf177870..f20d6456 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.h +++ b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.h @@ -81,7 +81,16 @@ protected: QString name; }; + struct TreeItem { + QPersistentModelIndex index; + int depth; + bool expanded; + TreeItem *parent; + int childCount; + }; + virtual const QVector<FixedItem> getFixedItems() const = 0; + virtual QString specialDisplayName(const TreeItem &item) const; private: void setRootPath(const QString &path); @@ -103,14 +112,6 @@ private: void rebuild(); - struct TreeItem { - QPersistentModelIndex index; - int depth; - bool expanded; - TreeItem *parent; - int childCount; - }; - QFileSystemModel *m_model; QPersistentModelIndex m_rootIndex; QList<TreeItem> m_items; diff --git a/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.cpp b/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.cpp index d70d5837..897c07cd 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "ImageChooserModel.h" +#include "StudioApp.h" ImageChooserModel::ImageChooserModel(QObject *parent) : ChooserModelBase(parent) @@ -39,7 +40,7 @@ ImageChooserModel::~ImageChooserModel() bool ImageChooserModel::isVisible(const QString &path) const { - return getIconType(path) == OBJTYPE_IMAGE; + return getIconType(path) == OBJTYPE_IMAGE || !g_StudioApp.getRenderableId(path).isEmpty(); } const QVector<ChooserModelBase::FixedItem> ImageChooserModel::getFixedItems() const @@ -47,3 +48,10 @@ const QVector<ChooserModelBase::FixedItem> ImageChooserModel::getFixedItems() co static const QVector<FixedItem> items = { { OBJTYPE_IMAGE, "", tr("[None]") } }; return items; } + +QString ImageChooserModel::specialDisplayName(const ChooserModelBase::TreeItem &item) const +{ + // Renderable items display the id instead of file name + const QString path = item.index.data(QFileSystemModel::FilePathRole).toString(); + return g_StudioApp.getRenderableId(path); +} diff --git a/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.h b/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.h index 288846fd..ee5b5806 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.h +++ b/src/Authoring/Studio/Palettes/Inspector/ImageChooserModel.h @@ -42,6 +42,7 @@ public: private: bool isVisible(const QString &path) const override; const QVector<FixedItem> getFixedItems() const override; + QString specialDisplayName(const TreeItem &item) const override; }; #endif // IMAGECHOOSERMODEL_H diff --git a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp index e6bb1a58..b46acdca 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp @@ -108,7 +108,14 @@ void ImageChooserView::showEvent(QShowEvent *event) const auto imageInstance = doc->GetDocumentReader().GetInstanceForGuid(guid); if (imageInstance.Valid()) { const QString path = doc->GetDocumentReader().GetSourcePath(imageInstance).toQString(); - m_model->setCurrentFile(path); + + // If path is renderable id, we need to resolve the actual path + const QString renderablePath = g_StudioApp.getRenderableAbsolutePath(path); + + if (renderablePath.isEmpty()) + m_model->setCurrentFile(path); + else + m_model->setCurrentFile(renderablePath); } else { m_model->setCurrentFile(tr("[None]")); } diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp index e327119e..ba2866f3 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp @@ -1063,6 +1063,17 @@ void InspectorControlModel::setPropertyControlled(long instance, int property) signalSender->SendControlledToggled(instance, property); } +bool InspectorControlModel::isLayer(long instance) const +{ + return g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge() + ->GetObjectType(instance) == EStudioObjectType::OBJTYPE_LAYER; +} + +QString InspectorControlModel::renderableId(const QString &filePath) const +{ + return g_StudioApp.getRenderableId(filePath); +} + void InspectorControlModel::setPropertyAnimated(long instance, int handle, bool animated) { CCmd* cmd = nullptr; diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h index 80f28e29..6b064f78 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h @@ -139,6 +139,8 @@ public: const QStringList &list); Q_INVOKABLE void setPropertyAnimated(long instance, int handle, bool animated); Q_INVOKABLE void setPropertyControlled(long instance, int property); + Q_INVOKABLE bool isLayer(long instance) const; + Q_INVOKABLE QString renderableId(const QString &filePath) const; private: void onSlideRearranged(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inOldIndex, diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index 5ab6cb91..327da9b0 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -121,6 +121,9 @@ void InspectorControlView::OnNewPresentation() void InspectorControlView::OnClosingPresentation() { + // Image chooser model needs to be rebuilt from scratch for each presentation, as different + // presentations count as subpresentations + delete m_imageChooserView; m_fileList.clear(); } @@ -367,7 +370,15 @@ QObject *InspectorControlView::showImageChooser(int handle, int instance, const m_imageChooserView = new ImageChooserView(this); connect(m_imageChooserView, &ImageChooserView::imageSelected, this, [this] (int handle, int instance, const QString &imageName){ - setPropertyValueFromFilename(instance, handle, imageName); + QString renderableId = g_StudioApp.getRenderableId(imageName); + if (renderableId.isEmpty()) { + setPropertyValueFromFilename(instance, handle, imageName); + } else { + Q3DStudio::SCOPED_DOCUMENT_EDITOR(*g_StudioApp.GetCore()->GetDoc(), + QObject::tr("Set Property")) + ->setInstanceImagePropertyValueAsRenderable( + instance, handle, Q3DStudio::CString::fromQString(renderableId)); + } m_imageChooserView->hide(); }); } diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml index be27b47f..c66c7d82 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml @@ -538,7 +538,10 @@ Rectangle { property int instance: parent.modelData.instance property int handle: parent.modelData.handle property variant values: parent.modelData.values - value: parent.modelData.value + value: { + var renderableId = _inspectorModel.renderableId(parent.modelData.value); + renderableId === "" ? parent.modelData.value : renderableId; + } onShowBrowser: { activeBrowser = _parentView.showImageChooser(handle, instance, mapToGlobal(width, 0)) @@ -822,6 +825,10 @@ Rectangle { property var value: parent.modelData.value model: values + // Disable for non-layer + enabled: _inspectorModel.isLayer(instance) + showArrow: enabled + implicitWidth: _valueWidth implicitHeight: _controlBaseHeight diff --git a/src/Authoring/Studio/Palettes/controls/StyledComboBox.qml b/src/Authoring/Studio/Palettes/controls/StyledComboBox.qml index d3140744..a5ba5614 100644 --- a/src/Authoring/Studio/Palettes/controls/StyledComboBox.qml +++ b/src/Authoring/Studio/Palettes/controls/StyledComboBox.qml @@ -40,6 +40,7 @@ ComboBox { bottomPadding: 0 // hack to fix the color after Qt.Quick.Controls2 "optimization" property alias color: backgroundBox.color + property bool showArrow: true delegate: ItemDelegate { id: itemDelegate @@ -89,6 +90,7 @@ ComboBox { y: control.topPadding + (control.availableHeight - height) / 2 source: _resDir + "arrow_down.png" rotation: control.popup.visible ? 180 : 0 + visible: control.showArrow } contentItem: StyledTextField { |