diff options
author | Janne Kangas <janne.kangas@qt.io> | 2019-08-21 13:02:14 +0300 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2019-09-02 11:55:49 +0300 |
commit | 5449c65bd84b3bd9d1bd9905c4aad8287eb4a572 (patch) | |
tree | 5e5def92157b0afae40c3a58bd4d0df8a3d174ca | |
parent | 9ecb622c57f4b7262f5ee72b40fd1d297b86646a (diff) |
Indicate invalid import file paths in inspector panel
Highlight a non-existing file with color and tooltip in inspector panel.
Also adds m_valid flag to inspector items.
Task-id QT3DS-3384
Change-Id: I348c388ff2b36158f341b44572aa4022873770bf
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
8 files changed, 55 insertions, 9 deletions
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp index 4ff2e5e7..bde1da0c 100644 --- a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp +++ b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp @@ -84,7 +84,7 @@ static QColor s_timelineFilterButtonSelectedColor; static QColor s_timelineFilterButtonHoveredColor; static QColor s_timelineRowCommentBgColor; static QColor s_timelinePressedKeyframeColor; // pressed keyframe from multiple selection -static QColor s_invalidDataInputIndicatorColor; +static QColor s_invalidDataIndicatorColor; static int s_fontSize; static int s_controlBaseHeight; @@ -159,7 +159,7 @@ void CStudioPreferences::loadPreferences() s_timelineRowCommentBgColor = QColor("#d0000000"); s_timelinePressedKeyframeColor = QColor("#ffff00"); - s_invalidDataInputIndicatorColor = QColor("#ff2121"); + s_invalidDataIndicatorColor = QColor("#ff2121"); s_fontSize = 12; s_controlBaseHeight = 22; @@ -615,6 +615,8 @@ void CStudioPreferences::setQmlContextProperties(QQmlContext *qml) qml->setContextProperty(QStringLiteral("_yAxisColor"), s_yAxisColor); qml->setContextProperty(QStringLiteral("_zAxisColor"), s_zAxisColor); qml->setContextProperty(QStringLiteral("_wAxisColor"), s_wAxisColor); + qml->setContextProperty(QStringLiteral("_invalidDataIndicatorColor"), + s_invalidDataIndicatorColor); qml->setContextProperty(QStringLiteral("_fontSize"), s_fontSize); qml->setContextProperty(QStringLiteral("_controlBaseHeight"), s_controlBaseHeight); qml->setContextProperty(QStringLiteral("_idWidth"), s_idWidth); @@ -910,9 +912,9 @@ QColor CStudioPreferences::timelinePressedKeyframeColor() return s_timelinePressedKeyframeColor; } -QColor CStudioPreferences::invalidDataInputIndicatorColor() +QColor CStudioPreferences::invalidDataIndicatorColor() { - return s_invalidDataInputIndicatorColor; + return s_invalidDataIndicatorColor; } int CStudioPreferences::fontSize() diff --git a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h index 95cd90d5..490a48cc 100644 --- a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h +++ b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h @@ -246,7 +246,7 @@ public: static QColor timelineRowCommentBgColor(); static QColor timelinePressedKeyframeColor(); - static QColor invalidDataInputIndicatorColor(); + static QColor invalidDataIndicatorColor(); static int fontSize(); static int controlBaseHeight(); diff --git a/src/Authoring/Qt3DStudio/Application/DataInputListDlg.cpp b/src/Authoring/Qt3DStudio/Application/DataInputListDlg.cpp index 1572ad2c..5a053778 100644 --- a/src/Authoring/Qt3DStudio/Application/DataInputListDlg.cpp +++ b/src/Authoring/Qt3DStudio/Application/DataInputListDlg.cpp @@ -355,7 +355,7 @@ void CDataInputListDlg::updateInfo() // Highlight the entire property name item if a non-match was found. if (typeNotMatching) { item3->setForeground( - QBrush(CStudioPreferences::invalidDataInputIndicatorColor())); + QBrush(CStudioPreferences::invalidDataIndicatorColor())); static QString warning(tr("\n\nData Input type is not matching with one or " "several bound properties")); item3->setToolTip(propNames + warning); diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/HandlerFilesChooser.qml b/src/Authoring/Qt3DStudio/Palettes/Inspector/HandlerFilesChooser.qml index b1514d03..25d40173 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Inspector/HandlerFilesChooser.qml +++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/HandlerFilesChooser.qml @@ -37,12 +37,28 @@ RowLayout { signal showBrowser property string value: "" property alias activeBrowser: browser.activeBrowser + property var validData: parent.modelData.validData BrowserCombo { id: browser Layout.preferredWidth: _valueWidth + validData: root.validData Layout.fillWidth: true value: root.value === "" ? qsTr("Select...") : root.value onShowBrowser: root.showBrowser() + StyledTooltip { + text: qsTr("Invalid path") + enabled: browserMouseArea.containsMouse && !root.validData + } + + MouseArea { + id: browserMouseArea + anchors.fill: parent + hoverEnabled: true + // pass through mouse click to Combobox + onPressed: { + mouse.accepted = false; + } + } } } diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp index b23a1f0f..cc093626 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp +++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp @@ -789,12 +789,17 @@ InspectorControlBase* InspectorControlModel::createItem(Qt3DSDMInspectable *insp // Update UI icon state and tooltip updateControlledToggleState(item); item->m_connections.push_back(signalProvider->ConnectControlledToggled( - std::bind(&InspectorControlModel::updateControlledToggleState, - this, item))); + std::bind(&InspectorControlModel::updateControlledToggleState, this, item))); + } + + if (item->m_propertyType == qt3dsdm::AdditionalMetaDataType::Import) { + item->m_connections.push_back(signalProvider->ConnectControlledToggled( + std::bind(&InspectorControlModel::updateValidState, this, item))); } // synchronize the value itself updatePropertyValue(item); + updateValidState(item); return item; } @@ -875,6 +880,20 @@ void InspectorControlModel::updateAnimateToggleState(InspectorControlBase* inIte } } +void InspectorControlModel::updateValidState(InspectorControlBase *inItem) +{ + const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() + ->GetClientDataModelBridge(); + if (bridge->GetSourcePathProperty() == inItem->m_property) { + QFileInfo fileinfo(g_StudioApp.GetCore()->GetDoc()->GetResolvedPathToDoc( + bridge->GetSourcePath(inItem->m_instance))); + if (fileinfo.exists() != inItem->m_valid) { + inItem->m_valid = !inItem->m_valid; + Q_EMIT inItem->validDataChanged(); + } + } +} + bool InspectorControlModel::isTreeRebuildRequired(CInspectableBase* inspectBase) { if (inspectBase != m_inspectableBase || !inspectBase) @@ -1444,6 +1463,7 @@ void InspectorControlModel::refresh() if (property->m_property.Valid()) { updatePropertyValue(property); updateControlledToggleState(property); + updateValidState(property); } } } diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h index 7c3be20e..b1c13240 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h +++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h @@ -70,6 +70,7 @@ class InspectorControlBase : public QObject Q_PROPERTY(bool animated MEMBER m_animated NOTIFY animatedChanged) Q_PROPERTY(bool controlled MEMBER m_controlled NOTIFY controlledChanged) Q_PROPERTY(bool controllable MEMBER m_controllable CONSTANT) + Q_PROPERTY(bool validData MEMBER m_valid NOTIFY validDataChanged) Q_PROPERTY(QString controller MEMBER m_controller NOTIFY controlledChanged) public: @@ -81,6 +82,7 @@ Q_SIGNALS: void animatedChanged(); void controlledChanged(); void tooltipChanged(); + void validDataChanged(); public: qt3dsdm::DataModelDataType::Value m_dataType; @@ -99,6 +101,7 @@ public: bool m_animated = false; bool m_controlled = false; bool m_controllable = false; + bool m_valid = true; QString m_controller; std::vector<qt3dsdm::TSignalConnectionPtr> m_connections; }; @@ -140,6 +143,7 @@ public: bool controlled); void notifyPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, qt3dsdm::Qt3DSDMPropertyHandle inProperty); + void updateValidState(InspectorControlBase *inItem); Q_INVOKABLE void setMaterialTypeValue(long instance, int handle, const QVariant &value); Q_INVOKABLE void setShaderValue(long instance, int handle, const QVariant &value); diff --git a/src/Authoring/Qt3DStudio/Palettes/controls/BrowserCombo.qml b/src/Authoring/Qt3DStudio/Palettes/controls/BrowserCombo.qml index 727488f4..c6b50832 100644 --- a/src/Authoring/Qt3DStudio/Palettes/controls/BrowserCombo.qml +++ b/src/Authoring/Qt3DStudio/Palettes/controls/BrowserCombo.qml @@ -36,6 +36,7 @@ MouseArea { property alias value: value.text property var activeBrowser property bool blockShow: false + property bool validData signal showBrowser @@ -64,6 +65,7 @@ MouseArea { StyledLabel { id: value + validData: root.validData anchors.fill: parent horizontalAlignment: Text.AlignLeft rightPadding: 6 + img.width diff --git a/src/Authoring/Qt3DStudio/Palettes/controls/StyledLabel.qml b/src/Authoring/Qt3DStudio/Palettes/controls/StyledLabel.qml index 5185b2ad..4f101f05 100644 --- a/src/Authoring/Qt3DStudio/Palettes/controls/StyledLabel.qml +++ b/src/Authoring/Qt3DStudio/Palettes/controls/StyledLabel.qml @@ -32,8 +32,10 @@ import QtQuick.Layouts 1.3 Label { id: styledLabelId + property bool validData: true + font.pixelSize: _fontSize - color: _textColor + color: validData ? _textColor : _invalidDataIndicatorColor Layout.preferredHeight: _controlBaseHeight Layout.preferredWidth: _idWidth verticalAlignment: Text.AlignVCenter |