mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-04 09:18:27 +02:00
[ui] high-level log system to prompt message dialogs in UI
* add 'info', 'warning', 'error' Signals on root object Reconstruction * create MessageDialogs when those signals are emitted
This commit is contained in:
parent
0adc4d8cc6
commit
f2089108aa
5 changed files with 132 additions and 0 deletions
53
meshroom/ui/qml/Controls/MessageDialog.qml
Normal file
53
meshroom/ui/qml/Controls/MessageDialog.qml
Normal file
|
@ -0,0 +1,53 @@
|
|||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Layouts 1.3
|
||||
import MaterialIcons 2.2
|
||||
|
||||
Dialog {
|
||||
id: root
|
||||
|
||||
property alias text: textLabel.text
|
||||
property alias detailedText: detailedLabel.text
|
||||
property alias helperText: helperLabel.text
|
||||
property alias icon: iconLabel
|
||||
|
||||
x: parent.width/2 - width/2
|
||||
y: parent.height/2 - height/2
|
||||
modal: true
|
||||
|
||||
padding: 15
|
||||
standardButtons: Dialog.Ok
|
||||
|
||||
RowLayout {
|
||||
spacing: 12
|
||||
|
||||
// Icon
|
||||
Label {
|
||||
id: iconLabel
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||
font.family: MaterialIcons.fontFamily
|
||||
font.pointSize: 14
|
||||
visible: text != ""
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
// Text
|
||||
spacing: 12
|
||||
Label {
|
||||
id: textLabel
|
||||
font.bold: true
|
||||
visible: text != ""
|
||||
}
|
||||
// Detailed text
|
||||
Label {
|
||||
id: detailedLabel
|
||||
text: text
|
||||
visible: text != ""
|
||||
}
|
||||
// Additional helper text
|
||||
Label {
|
||||
id: helperLabel
|
||||
visible: text != ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
module Controls
|
||||
|
||||
FloatingPane 1.0 FloatingPane.qml
|
||||
MessageDialog 1.0 MessageDialog.qml
|
||||
|
|
53
meshroom/ui/qml/DialogsFactory.qml
Normal file
53
meshroom/ui/qml/DialogsFactory.qml
Normal file
|
@ -0,0 +1,53 @@
|
|||
import QtQuick 2.9
|
||||
import MaterialIcons 2.2
|
||||
import Controls 1.0
|
||||
|
||||
/**
|
||||
* DialogsFactory is utility object to instantiate generic purpose Dialogs.
|
||||
*/
|
||||
QtObject {
|
||||
|
||||
readonly property string defaultErrorText: "An unexpected error has occured"
|
||||
|
||||
property Component infoDialog: Component {
|
||||
MessageDialog {
|
||||
title: "Info"
|
||||
icon.text: MaterialIcons.info
|
||||
visible: true
|
||||
}
|
||||
}
|
||||
property Component warningDialog: Component {
|
||||
MessageDialog {
|
||||
title: "Warning"
|
||||
icon {
|
||||
text: MaterialIcons.warning
|
||||
color: "#FF9800"
|
||||
}
|
||||
visible: true
|
||||
}
|
||||
}
|
||||
property Component errorDialog: Component {
|
||||
id: errorDialog
|
||||
MessageDialog {
|
||||
title: "Error"
|
||||
icon {
|
||||
text: MaterialIcons.error
|
||||
color: "#F44336"
|
||||
}
|
||||
text: defaultErrorText
|
||||
visible: true
|
||||
}
|
||||
}
|
||||
|
||||
function info(window) {
|
||||
return infoDialog.createObject(window)
|
||||
}
|
||||
|
||||
function warning(window) {
|
||||
return warningDialog.createObject(window)
|
||||
}
|
||||
|
||||
function error(window) {
|
||||
return errorDialog.createObject(window)
|
||||
}
|
||||
}
|
|
@ -191,6 +191,26 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
DialogsFactory {
|
||||
id: dialogsFactory
|
||||
}
|
||||
|
||||
// Bind log messages to DialogsFactory
|
||||
Connections {
|
||||
target: _reconstruction
|
||||
function createDialog(func, args)
|
||||
{
|
||||
var dialog = func(_window)
|
||||
// Set text afterwards to avoid dialog sizing issues
|
||||
dialog.title = args[0]
|
||||
dialog.text = args[1]
|
||||
dialog.detailedText = args[2]
|
||||
}
|
||||
onInfo: createDialog(dialogsFactory.info, arguments)
|
||||
onWarning: createDialog(dialogsFactory.warning, arguments)
|
||||
onError: createDialog(dialogsFactory.error, arguments)
|
||||
}
|
||||
|
||||
Action {
|
||||
id: undoAction
|
||||
|
||||
|
|
|
@ -452,3 +452,8 @@ class Reconstruction(UIGraph):
|
|||
sfmReport = Property(bool, lambda self: len(self._poses) > 0, notify=sfmReportChanged)
|
||||
sfmAugmented = Signal(graph.Node, graph.Node)
|
||||
|
||||
# Signals to propagate high-level log messages
|
||||
# Signal(title, text, detailedText)
|
||||
error = Signal(str, str, str)
|
||||
warning = Signal(str, str, str)
|
||||
info = Signal(str, str, str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue