From 0ef171504394c2f074b6bab4908e3bd167fe2a1c Mon Sep 17 00:00:00 2001 From: Aurore LAFAURIE Date: Mon, 16 Sep 2024 16:20:45 +0200 Subject: [PATCH] [ui] Rework of MessageDialog for CompatibilityManager and SensorDBDialog --- meshroom/ui/qml/Controls/MessageDialog.qml | 27 ++++++++++++++++--- .../qml/GraphEditor/CompatibilityManager.qml | 24 ++++++++++++++--- .../ui/qml/ImageGallery/SensorDBDialog.qml | 23 ++++++++-------- 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/meshroom/ui/qml/Controls/MessageDialog.qml b/meshroom/ui/qml/Controls/MessageDialog.qml index 0213854f0b..6efebdb935 100644 --- a/meshroom/ui/qml/Controls/MessageDialog.qml +++ b/meshroom/ui/qml/Controls/MessageDialog.qml @@ -13,6 +13,8 @@ Dialog { property alias icon: iconLabel property alias canCopy: copyButton.visible property alias preset: presets.state + property alias content: contentComponent.sourceComponent + property alias textMetrics: textMetrics default property alias children: layout.children @@ -48,7 +50,6 @@ Dialog { } RowLayout { - width: parent.width // Icon Label { id: iconLabel @@ -59,7 +60,6 @@ Dialog { Label { id: titleLabel - Layout.fillWidth: true text: title + " - " + Qt.application.name + " " + Qt.application.version font.bold: true } @@ -76,7 +76,7 @@ Dialog { } } - ColumnLayout { + contentItem: ColumnLayout { id: layout // Text spacing: 12 @@ -85,6 +85,9 @@ Dialog { font.bold: true visible: text != "" onLinkActivated: function(link) { Qt.openUrlExternally(link) } + + Layout.preferredWidth: titleLabel.width + wrapMode: Text.WordWrap } // Detailed text Label { @@ -92,13 +95,31 @@ Dialog { text: text visible: text != "" onLinkActivated: function(link) { Qt.openUrlExternally(link) } + + Layout.preferredWidth: titleLabel.width + wrapMode: Text.WordWrap } // Additional helper text Label { id: helperLabel visible: text != "" onLinkActivated: function(link) { Qt.openUrlExternally(link) } + + Layout.preferredWidth: titleLabel.width + wrapMode: Text.WordWrap } + + Loader { + id: contentComponent + + Layout.fillWidth: true + } + } + + TextMetrics { + id: textMetrics + + text: "A" } StateGroup { diff --git a/meshroom/ui/qml/GraphEditor/CompatibilityManager.qml b/meshroom/ui/qml/GraphEditor/CompatibilityManager.qml index 3bc955b091..8c03c63ed8 100644 --- a/meshroom/ui/qml/GraphEditor/CompatibilityManager.qml +++ b/meshroom/ui/qml/GraphEditor/CompatibilityManager.qml @@ -57,7 +57,7 @@ MessageDialog { + "This operation is undoable and can also be done manually in the Graph Editor." : "" - ColumnLayout { + content: ColumnLayout { spacing: 16 ListView { @@ -68,6 +68,20 @@ MessageDialog { clip: true model: nodesModel + property int longestLabel: { + var longest = 0 + for (var i = 0; i < issueCount; ++i) { + var n = nodesModel.at(i) + if (n.defaultLabel.length > longest) + longest = n.defaultLabel.length + } + return longest + } + + property int upgradableLabelWidth: { + return "Upgradable".length * root.textMetrics.width + } + ScrollBar.vertical: MScrollBar { id: scrollbar } spacing: 4 @@ -79,9 +93,9 @@ MessageDialog { background: Rectangle { color: Qt.darker(parent.palette.window, 1.15) } RowLayout { width: parent.width - Label { text: "Node"; Layout.preferredWidth: 150; font.bold: true } + Label { text: "Node"; Layout.preferredWidth: listView.longestLabel * root.textMetrics.width; font.bold: true } Label { text: "Issue"; Layout.fillWidth: true; font.bold: true } - Label { text: "Upgradable"; font.bold: true } + Label { text: "Upgradable"; Layout.preferredWidth: listView.upgradableLabelWidth; font.bold: true } } } @@ -94,7 +108,7 @@ MessageDialog { anchors.horizontalCenter: parent != null ? parent.horizontalCenter : undefined Label { - Layout.preferredWidth: 150 + Layout.preferredWidth: listView.longestLabel * root.textMetrics.width text: compatibilityNodeDelegate.node ? compatibilityNodeDelegate.node.defaultLabel : "" } Label { @@ -102,6 +116,8 @@ MessageDialog { text: compatibilityNodeDelegate.node ? compatibilityNodeDelegate.node.issueDetails : "" } Label { + Layout.preferredWidth: listView.upgradableLabelWidth + horizontalAlignment: Text.AlignHCenter text: compatibilityNodeDelegate.node && compatibilityNodeDelegate.node.canUpgrade ? MaterialIcons.check : MaterialIcons.clear color: compatibilityNodeDelegate.node && compatibilityNodeDelegate.node.canUpgrade ? "#4CAF50" : "#F44336" font.family: MaterialIcons.fontFamily diff --git a/meshroom/ui/qml/ImageGallery/SensorDBDialog.qml b/meshroom/ui/qml/ImageGallery/SensorDBDialog.qml index c61a5e5f47..2252b1dc70 100644 --- a/meshroom/ui/qml/ImageGallery/SensorDBDialog.qml +++ b/meshroom/ui/qml/ImageGallery/SensorDBDialog.qml @@ -16,21 +16,19 @@ MessageDialog { icon.text: MaterialIcons.camera icon.font.pointSize: 10 - modal: true parent: Overlay.overlay canCopy: false title: "Sensor Database" text: "Add missing Camera Models to the Sensor Database to improve your results." - detailedText: "If a warning is displayed on your images, adding your Camera Model to the Sensor Database\n"+ - "can help fix it and improve your reconstruction results." + detailedText: "If a warning is displayed on your images, adding your Camera Model to the Sensor Database can help fix it and improve your reconstruction results." helperText: 'To update the Sensor Database (complete guide):
' + ' - Look for the "sensor width" in millimeters of your Camera Model
' + ' - Add a new line in the Database following this pattern: Make;Model;SensorWidthInMM
' + - ' - Click on "' + rebuildIntrinsics.text + '" once the Database has been saved
' + + ' - Click on "Update Intrinsics" once the Database has been saved
' + ' - Contribute to the online Database' - ColumnLayout { + content: ColumnLayout { RowLayout { Layout.fillWidth: true spacing: 2 @@ -62,13 +60,14 @@ MessageDialog { onClicked: Qt.openUrlExternally(sensorDatabase) } } - } - Button { - id: rebuildIntrinsics - text: "Update Intrinsics" - enabled: !readOnly - onClicked: updateIntrinsicsRequest() - Layout.alignment: Qt.AlignCenter + + Button { + id: rebuildIntrinsics + text: "Update Intrinsics" + enabled: !readOnly + onClicked: updateIntrinsicsRequest() + Layout.alignment: Qt.AlignCenter + } } standardButtons: Dialog.Close onAccepted: close()