From 263a97ff76f1c2715cf55e145e97080f892c73e5 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Thu, 31 Jan 2019 13:19:29 +0200 Subject: Enable collapsing inspector groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also divided Layer inspector properties into some groups. Task-number: QT3DS-2972 Change-Id: I17ce5276bb1b6c16432775b2470a468ff6cc46cd Reviewed-by: Miikka Heikkinen Reviewed-by: Janne Kangas Reviewed-by: Antti Määttä --- .../Palettes/Inspector/InspectorControlModel.cpp | 25 +++++ .../Palettes/Inspector/InspectorControlModel.h | 4 + .../Palettes/Inspector/InspectorControlView.qml | 37 +++++++- .../res/DataModelMetadata/en-us/MetaData.xml | 105 +++++++++++---------- 4 files changed, 118 insertions(+), 53 deletions(-) diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp index dec38cea..d4fdc306 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp @@ -623,6 +623,31 @@ QString InspectorControlModel::getDefaultMaterialString() const return QObject::tr("Default"); } +bool InspectorControlModel::isGroupCollapsed(int groupIdx) const +{ + const auto inspectable = dynamic_cast(m_inspectableBase); + if (inspectable && groupIdx > -1 && groupIdx < m_groupElements.size()) { + auto instance = inspectable->GetGroupInstance(0); + + if (m_collapseMap.contains(instance)) + return m_collapseMap[instance].contains(groupIdx); + } + + return false; +} + +void InspectorControlModel::updateGroupCollapseState(int groupIdx, bool isCollapsed) +{ + const auto inspectable = dynamic_cast(m_inspectableBase); + if (inspectable && groupIdx > -1 && groupIdx < m_groupElements.size()) { + auto instance = inspectable->GetGroupInstance(0); + if (isCollapsed) + m_collapseMap[instance][groupIdx] = true; + else + m_collapseMap[instance].remove(groupIdx); + } +} + void InspectorControlModel::updateFontValues(InspectorControlBase *element) const { // Find if there are any font items and update the values of those diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h index 561d8af1..e329dba1 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h @@ -153,6 +153,8 @@ public: Q_INVOKABLE bool isDefaultMaterial() const; Q_INVOKABLE void addMaterial(); Q_INVOKABLE void duplicateMaterial(); + Q_INVOKABLE bool isGroupCollapsed(int groupIdx) const; + Q_INVOKABLE void updateGroupCollapseState(int groupIdx, bool state); private: void onSlideRearranged(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inOldIndex, @@ -197,6 +199,8 @@ private: qt3dsdm::SValue m_previouslyCommittedValue; + QHash > m_collapseMap; + QString getBasicMaterialString() const; QString getAnimatableMaterialString() const; QString getReferencedMaterialString() const; diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml index 9a9c0c01..b2e8b286 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml @@ -205,12 +205,45 @@ Rectangle { width: parent.width - x spacing: 4 - StyledLabel { - text: model.title + Rectangle { // group header + x: -10 + width: delegateItem.width + height: 25 + color: "#111111" + + StyledLabel { + x: 30 + text: model.title + anchors.verticalCenter: parent.verticalCenter + } + + Image { + id: collapseButton + x: 10 + anchors.verticalCenter: parent.verticalCenter + source: { + _resDir + (groupItems.visible ? "arrow_down.png" : "arrow.png") + } + } + + MouseArea { + id: collapseButtonMouseArea + anchors.fill: parent + onClicked: { + if (mouse.button === Qt.LeftButton) { + groupItems.visible = !groupItems.visible; + _inspectorModel.updateGroupCollapseState(indexOfThisDelegate, + !groupItems.visible) + } + } + } } Column { spacing: 4 + id: groupItems + + visible: !_inspectorModel.isGroupCollapsed(indexOfThisDelegate) Repeater { model: delegateItem.values diff --git a/src/Runtime/res/DataModelMetadata/en-us/MetaData.xml b/src/Runtime/res/DataModelMetadata/en-us/MetaData.xml index 992b9164..b376d272 100644 --- a/src/Runtime/res/DataModelMetadata/en-us/MetaData.xml +++ b/src/Runtime/res/DataModelMetadata/en-us/MetaData.xml @@ -84,118 +84,121 @@ -