Skip to content

Commit

Permalink
Clean up error details in notification dialog properly
Browse files Browse the repository at this point in the history
  • Loading branch information
uglide committed May 20, 2021
1 parent 78455de commit cb2245c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 10 deletions.
38 changes: 32 additions & 6 deletions src/qml/app.qml
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,48 @@ ApplicationWindow {
}
}

OkDialog {
Loader {
id: notification
objectName: "rdm_qml_error_dialog"
visible: false

property var icon
property string text
property string details

function showError(msg, details="") {
icon = StandardIcon.Warning
text = msg
detailedText = details
open()
notification.details = details
sourceComponent = notificationTemplate
}

function showMsg(msg) {
icon = StandardIcon.Information
text = msg
open()
details = ""
sourceComponent = notificationTemplate
}

onLoaded: {
item.open()
}

Component {
id: notificationTemplate

OkDialog {
objectName: "rdm_qml_error_dialog"
visible: false

icon: notification.icon
text: notification.text
detailedText: notification.details

onVisibleChanged: {
if (!visible) {
notification.sourceComponent = undefined
}
}
}
}
}

Expand Down
40 changes: 36 additions & 4 deletions src/qml/bulk-operations/BulkOperationsDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ Dialog {
bulkErrorNotification.text = text
if (details) {
bulkErrorNotification.detailedText = details
} else {
bulkErrorNotification.detailedText = ""
}

bulkErrorNotification.open()
}

Expand Down Expand Up @@ -363,7 +366,7 @@ Dialog {
bulkSuccessNotification.open()
}

function onError(e) {
function onError(e, details) {
showError(qsTranslate("RDM","Bulk Operation finished with errors"), e, details)
}
}
Expand Down Expand Up @@ -428,10 +431,39 @@ Dialog {
MouseArea { anchors.fill: parent }
}

OkDialog {
Loader {
id: bulkErrorNotification
modality: Qt.NonModal
visible: false

property var icon: StandardIcon.Warning
property string title
property string text
property string detailedText

Component {
id: bulkNotificationTemplate

OkDialog {
modality: Qt.NonModal
title: bulkErrorNotification.title
icon: bulkErrorNotification.icon
text: bulkErrorNotification.text
detailedText: bulkErrorNotification.detailedText

onVisibleChanged: {
if (!visible) {
bulkErrorNotification.sourceComponent = undefined
}
}
}
}

onLoaded: {
item.open()
}

function open() {
sourceComponent = bulkNotificationTemplate
}
}

OkDialog {
Expand Down

0 comments on commit cb2245c

Please sign in to comment.