From 7f8591718db7189c8879746502e8eba8f8732d88 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 4 Feb 2022 14:31:27 +0100 Subject: [PATCH] Remove central messageBox in favour of local box The profile import/export was the only place where it was used, in our code base. Contributes to issue CURA-8687. --- cura/CuraApplication.py | 16 ------------ resources/qml/Cura.qml | 29 ---------------------- resources/qml/Preferences/ProfilesPage.qml | 22 +++++++--------- 3 files changed, 9 insertions(+), 58 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index ca708709aa..9145cd771e 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -675,22 +675,6 @@ class CuraApplication(QtApplication): self._setLoadingHint(self._i18n_catalog.i18nc("@info:progress", "Initializing Active Machine...")) super().setGlobalContainerStack(stack) - showMessageBox = pyqtSignal(str,str, str, str, int, int, - arguments = ["title", "text", "informativeText", "detailedText","buttons", "icon"]) - """A reusable dialogbox""" - - def messageBox(self, title, text, - informativeText = "", - detailedText = "", - buttons = QMessageBox.Ok, - icon = QMessageBox.NoIcon, - callback = None, - callback_arguments = [] - ): - self._message_box_callback = callback - self._message_box_callback_arguments = callback_arguments - self.showMessageBox.emit(title, text, informativeText, detailedText, buttons, icon) - showDiscardOrKeepProfileChanges = pyqtSignal() def discardOrKeepProfileChanges(self) -> bool: diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 7e347df4ee..2a5f733dfb 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -813,35 +813,6 @@ UM.MainWindow } } - MessageDialog - { - id: messageDialog - modality: Qt.ApplicationModal - onAccepted: CuraApplication.messageBoxClosed(clickedButton) - onApply: CuraApplication.messageBoxClosed(clickedButton) - onDiscard: CuraApplication.messageBoxClosed(clickedButton) - onHelp: CuraApplication.messageBoxClosed(clickedButton) - onNo: CuraApplication.messageBoxClosed(clickedButton) - onRejected: CuraApplication.messageBoxClosed(clickedButton) - onReset: CuraApplication.messageBoxClosed(clickedButton) - onYes: CuraApplication.messageBoxClosed(clickedButton) - } - - Connections - { - target: CuraApplication - function onShowMessageBox(title, text, informativeText, detailedText, buttons, icon) - { - messageDialog.title = title - messageDialog.text = text - messageDialog.informativeText = informativeText - messageDialog.detailedText = detailedText - messageDialog.standardButtons = buttons - messageDialog.icon = icon - messageDialog.visible = true - } - } - Component { id: discardOrKeepProfileChangesDialogComponent diff --git a/resources/qml/Preferences/ProfilesPage.qml b/resources/qml/Preferences/ProfilesPage.qml index 3d7ceeda5e..cf380b33cd 100644 --- a/resources/qml/Preferences/ProfilesPage.qml +++ b/resources/qml/Preferences/ProfilesPage.qml @@ -311,19 +311,8 @@ Item onAccepted: { var result = Cura.ContainerManager.importProfile(fileUrl); + messageDialog.title = catalog.i18nc("@title:window", "Import Profile") messageDialog.text = result.message; - if (result.status == "ok") - { - messageDialog.icon = StandardIcon.Information; - } - else if (result.status == "warning" || result.status == "duplicate") - { - messageDialog.icon = StandardIcon.Warning; - } - else - { - messageDialog.icon = StandardIcon.Critical; - } messageDialog.open(); CuraApplication.setDefaultPath("dialog_profile_path", folder); } @@ -344,7 +333,7 @@ Item if (result && result.status == "error") { - messageDialog.icon = StandardIcon.Critical; + messageDialog.title = catalog.i18nc("@title:window", "Export Profile") messageDialog.text = result.message; messageDialog.open(); } @@ -354,6 +343,13 @@ Item } } + //Dialogue box for showing the result of importing or exporting profiles. + UM.MessageDialog + { + id: messageDialog + standardButtons: Dialog.Ok + } + Item { id: contentsItem