[ui] Rework of MessageDialog for CompatibilityManager and SensorDBDialog

This commit is contained in:
Aurore LAFAURIE 2024-09-16 16:20:45 +02:00 committed by Candice Bentéjac
parent 09720f6be1
commit 6515375f19
3 changed files with 55 additions and 19 deletions

View file

@ -13,6 +13,8 @@ Dialog {
property alias icon: iconLabel property alias icon: iconLabel
property alias canCopy: copyButton.visible property alias canCopy: copyButton.visible
property alias preset: presets.state property alias preset: presets.state
property alias content: contentComponent.sourceComponent
property alias textMetrics: textMetrics
default property alias children: layout.children default property alias children: layout.children
@ -48,7 +50,6 @@ Dialog {
} }
RowLayout { RowLayout {
width: parent.width
// Icon // Icon
Label { Label {
id: iconLabel id: iconLabel
@ -59,7 +60,6 @@ Dialog {
Label { Label {
id: titleLabel id: titleLabel
Layout.fillWidth: true
text: title + " - " + Qt.application.name + " " + Qt.application.version text: title + " - " + Qt.application.name + " " + Qt.application.version
font.bold: true font.bold: true
} }
@ -76,7 +76,7 @@ Dialog {
} }
} }
ColumnLayout { contentItem: ColumnLayout {
id: layout id: layout
// Text // Text
spacing: 12 spacing: 12
@ -85,6 +85,9 @@ Dialog {
font.bold: true font.bold: true
visible: text != "" visible: text != ""
onLinkActivated: function(link) { Qt.openUrlExternally(link) } onLinkActivated: function(link) { Qt.openUrlExternally(link) }
Layout.preferredWidth: titleLabel.width
wrapMode: Text.WordWrap
} }
// Detailed text // Detailed text
Label { Label {
@ -92,13 +95,31 @@ Dialog {
text: text text: text
visible: text != "" visible: text != ""
onLinkActivated: function(link) { Qt.openUrlExternally(link) } onLinkActivated: function(link) { Qt.openUrlExternally(link) }
Layout.preferredWidth: titleLabel.width
wrapMode: Text.WordWrap
} }
// Additional helper text // Additional helper text
Label { Label {
id: helperLabel id: helperLabel
visible: text != "" visible: text != ""
onLinkActivated: function(link) { Qt.openUrlExternally(link) } 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 { StateGroup {

View file

@ -57,7 +57,7 @@ MessageDialog {
+ "This operation is undoable and can also be done manually in the Graph Editor." + "This operation is undoable and can also be done manually in the Graph Editor."
: "" : ""
ColumnLayout { content: ColumnLayout {
spacing: 16 spacing: 16
ListView { ListView {
@ -68,6 +68,20 @@ MessageDialog {
clip: true clip: true
model: nodesModel 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 } ScrollBar.vertical: MScrollBar { id: scrollbar }
spacing: 4 spacing: 4
@ -79,9 +93,9 @@ MessageDialog {
background: Rectangle { color: Qt.darker(parent.palette.window, 1.15) } background: Rectangle { color: Qt.darker(parent.palette.window, 1.15) }
RowLayout { RowLayout {
width: parent.width 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: "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 anchors.horizontalCenter: parent != null ? parent.horizontalCenter : undefined
Label { Label {
Layout.preferredWidth: 150 Layout.preferredWidth: listView.longestLabel * root.textMetrics.width
text: compatibilityNodeDelegate.node ? compatibilityNodeDelegate.node.defaultLabel : "" text: compatibilityNodeDelegate.node ? compatibilityNodeDelegate.node.defaultLabel : ""
} }
Label { Label {
@ -102,6 +116,8 @@ MessageDialog {
text: compatibilityNodeDelegate.node ? compatibilityNodeDelegate.node.issueDetails : "" text: compatibilityNodeDelegate.node ? compatibilityNodeDelegate.node.issueDetails : ""
} }
Label { Label {
Layout.preferredWidth: listView.upgradableLabelWidth
horizontalAlignment: Text.AlignHCenter
text: compatibilityNodeDelegate.node && compatibilityNodeDelegate.node.canUpgrade ? MaterialIcons.check : MaterialIcons.clear text: compatibilityNodeDelegate.node && compatibilityNodeDelegate.node.canUpgrade ? MaterialIcons.check : MaterialIcons.clear
color: compatibilityNodeDelegate.node && compatibilityNodeDelegate.node.canUpgrade ? "#4CAF50" : "#F44336" color: compatibilityNodeDelegate.node && compatibilityNodeDelegate.node.canUpgrade ? "#4CAF50" : "#F44336"
font.family: MaterialIcons.fontFamily font.family: MaterialIcons.fontFamily

View file

@ -16,21 +16,19 @@ MessageDialog {
icon.text: MaterialIcons.camera icon.text: MaterialIcons.camera
icon.font.pointSize: 10 icon.font.pointSize: 10
modal: true
parent: Overlay.overlay parent: Overlay.overlay
canCopy: false canCopy: false
title: "Sensor Database" title: "Sensor Database"
text: "Add missing Camera Models to the Sensor Database to improve your results." 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"+ 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."
"can help fix it and improve your reconstruction results."
helperText: 'To update the Sensor Database (<a href="https://github.com/alicevision/meshroom/wiki/Add-Camera-to-database">complete guide</a>):<br>' + helperText: 'To update the Sensor Database (<a href="https://github.com/alicevision/meshroom/wiki/Add-Camera-to-database">complete guide</a>):<br>' +
' - Look for the "sensor width" in millimeters of your Camera Model<br>' + ' - Look for the "sensor width" in millimeters of your Camera Model<br>' +
' - Add a new line in the Database following this pattern: Make;Model;SensorWidthInMM<br>' + ' - Add a new line in the Database following this pattern: Make;Model;SensorWidthInMM<br>' +
' - Click on "' + rebuildIntrinsics.text + '" once the Database has been saved<br>' + ' - Click on "Update Intrinsics" once the Database has been saved<br>' +
' - Contribute to the <a href="https://github.com/alicevision/AliceVision/blob/develop/src/aliceVision/sensorDB/cameraSensors.db">online Database</a>' ' - Contribute to the <a href="https://github.com/alicevision/AliceVision/blob/develop/src/aliceVision/sensorDB/cameraSensors.db">online Database</a>'
ColumnLayout { content: ColumnLayout {
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
spacing: 2 spacing: 2
@ -62,13 +60,14 @@ MessageDialog {
onClicked: Qt.openUrlExternally(sensorDatabase) onClicked: Qt.openUrlExternally(sensorDatabase)
} }
} }
}
Button { Button {
id: rebuildIntrinsics id: rebuildIntrinsics
text: "Update Intrinsics" text: "Update Intrinsics"
enabled: !readOnly enabled: !readOnly
onClicked: updateIntrinsicsRequest() onClicked: updateIntrinsicsRequest()
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
}
} }
standardButtons: Dialog.Close standardButtons: Dialog.Close
onAccepted: close() onAccepted: close()