Update messages to use the message_types

CURA-8418
This commit is contained in:
Jaime van Kessel 2021-07-27 11:54:43 +02:00
parent f11079adcf
commit 900db57f0f
No known key found for this signature in database
GPG key ID: 3710727397403C91
23 changed files with 81 additions and 39 deletions

View file

@ -178,7 +178,9 @@ class Account(QObject):
if self._error_message: if self._error_message:
self._error_message.hide() self._error_message.hide()
Logger.log("w", "Failed to login: %s", error_message) Logger.log("w", "Failed to login: %s", error_message)
self._error_message = Message(error_message, title = i18n_catalog.i18nc("@info:title", "Login failed")) self._error_message = Message(error_message,
title = i18n_catalog.i18nc("@info:title", "Login failed"),
message_type = Message.MessageType.ERROR)
self._error_message.show() self._error_message.show()
self._logged_in = False self._logged_in = False
self.loginStateChanged.emit(False) self.loginStateChanged.emit(False)

View file

@ -40,6 +40,6 @@ class ArrangeObjectsJob(Job):
i18n_catalog.i18nc("@info:status", i18n_catalog.i18nc("@info:status",
"Unable to find a location within the build volume for all objects"), "Unable to find a location within the build volume for all objects"),
title = i18n_catalog.i18nc("@info:title", "Can't Find Location"), title = i18n_catalog.i18nc("@info:title", "Can't Find Location"),
message_type = Message.MessageType.ERROR) message_type = Message.MessageType.WARNING)
no_full_solution_message.show() no_full_solution_message.show()
self.finished.emit(self) self.finished.emit(self)

View file

@ -119,7 +119,7 @@ class Backup:
def _showMessage(self, message: str) -> None: def _showMessage(self, message: str) -> None:
"""Show a UI message.""" """Show a UI message."""
Message(message, title=self.catalog.i18nc("@info:title", "Backup"), lifetime=30).show() Message(message, title=self.catalog.i18nc("@info:title", "Backup")).show()
def restore(self) -> bool: def restore(self) -> bool:
"""Restore this back-up. """Restore this back-up.
@ -154,7 +154,10 @@ class Backup:
archive = ZipFile(io.BytesIO(self.zip_file), "r") archive = ZipFile(io.BytesIO(self.zip_file), "r")
except LookupError as e: except LookupError as e:
Logger.log("d", f"The following error occurred while trying to restore a Cura backup: {str(e)}") Logger.log("d", f"The following error occurred while trying to restore a Cura backup: {str(e)}")
self._showMessage(self.catalog.i18nc("@info:backup_failed", "The following error occurred while trying to restore a Cura backup:") + str(e)) Message(self.catalog.i18nc("@info:backup_failed", "The following error occurred while trying to restore a Cura backup:") + str(e),
title = self.catalog.i18nc("@info:title", "Backup"),
message_type = Message.MessageType.ERROR).show()
return False return False
extracted = self._extractArchive(archive, version_data_dir) extracted = self._extractArchive(archive, version_data_dir)

View file

@ -1798,8 +1798,9 @@ class CuraApplication(QtApplication):
if extension in self._non_sliceable_extensions: if extension in self._non_sliceable_extensions:
message = Message( message = Message(
self._i18n_catalog.i18nc("@info:status", self._i18n_catalog.i18nc("@info:status",
"Only one G-code file can be loaded at a time. Skipped importing {0}", "Only one G-code file can be loaded at a time. Skipped importing {0}", filename),
filename), title = self._i18n_catalog.i18nc("@info:title", "Warning")) title = self._i18n_catalog.i18nc("@info:title", "Warning"),
message_type = Message.MessageType.WARNING)
message.show() message.show()
return return
# If file being loaded is non-slicable file, then prevent loading of any other files # If file being loaded is non-slicable file, then prevent loading of any other files
@ -1808,8 +1809,9 @@ class CuraApplication(QtApplication):
if extension in self._non_sliceable_extensions: if extension in self._non_sliceable_extensions:
message = Message( message = Message(
self._i18n_catalog.i18nc("@info:status", self._i18n_catalog.i18nc("@info:status",
"Can't open any other file if G-code is loading. Skipped importing {0}", "Can't open any other file if G-code is loading. Skipped importing {0}", filename),
filename), title = self._i18n_catalog.i18nc("@info:title", "Error")) title = self._i18n_catalog.i18nc("@info:title", "Error"),
message_type = Message.MessageType.ERROR)
message.show() message.show()
return return

View file

@ -74,5 +74,6 @@ class MultiplyObjectsJob(Job):
if not found_solution_for_all: if not found_solution_for_all:
no_full_solution_message = Message( no_full_solution_message = Message(
i18n_catalog.i18nc("@info:status", "Unable to find a location within the build volume for all objects"), i18n_catalog.i18nc("@info:status", "Unable to find a location within the build volume for all objects"),
title = i18n_catalog.i18nc("@info:title", "Placing Object")) title = i18n_catalog.i18nc("@info:title", "Placing Object"),
message_type = Message.MessageType.WARNING)
no_full_solution_message.show() no_full_solution_message.show()

View file

@ -187,7 +187,8 @@ class AuthorizationService:
except OSError: except OSError:
Logger.logException("w", "Unable to create authorization request server") Logger.logException("w", "Unable to create authorization request server")
Message(i18n_catalog.i18nc("@info", "Unable to start a new sign in process. Check if another sign in attempt is still active."), Message(i18n_catalog.i18nc("@info", "Unable to start a new sign in process. Check if another sign in attempt is still active."),
title=i18n_catalog.i18nc("@info:title", "Warning")).show() title=i18n_catalog.i18nc("@info:title", "Warning"),
message_type = Message.MessageType.WARNING).show()
return return
auth_url = self._generate_auth_url(query_parameters_dict, force_browser_logout) auth_url = self._generate_auth_url(query_parameters_dict, force_browser_logout)

View file

@ -150,11 +150,13 @@ class CuraContainerRegistry(ContainerRegistry):
Logger.log("w", "Failed to export profile to %s: Writer plugin reported failure.", file_name) Logger.log("w", "Failed to export profile to %s: Writer plugin reported failure.", file_name)
m = Message(catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Failed to export profile to <filename>{0}</filename>: Writer plugin reported failure.", file_name), m = Message(catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Failed to export profile to <filename>{0}</filename>: Writer plugin reported failure.", file_name),
lifetime = 0, lifetime = 0,
title = catalog.i18nc("@info:title", "Error")) title = catalog.i18nc("@info:title", "Error"),
message_type = Message.MessageType.ERROR)
m.show() m.show()
return False return False
m = Message(catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Exported profile to <filename>{0}</filename>", file_name), m = Message(catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Exported profile to <filename>{0}</filename>", file_name),
title = catalog.i18nc("@info:title", "Export succeeded")) title = catalog.i18nc("@info:title", "Export succeeded"),
message_type = Message.MessageType.POSITIVE)
m.show() m.show()
return True return True

View file

@ -540,7 +540,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
"Project file <filename>{0}</filename> contains an unknown machine type" "Project file <filename>{0}</filename> contains an unknown machine type"
" <message>{1}</message>. Cannot import the machine." " <message>{1}</message>. Cannot import the machine."
" Models will be imported instead.", file_name, machine_definition_id), " Models will be imported instead.", file_name, machine_definition_id),
title = i18n_catalog.i18nc("@info:title", "Open Project File")) title = i18n_catalog.i18nc("@info:title", "Open Project File"),
message_type = Message.MessageType.WARNING)
message.show() message.show()
Logger.log("i", "Could unknown machine definition %s in project file %s, cannot import it.", Logger.log("i", "Could unknown machine definition %s in project file %s, cannot import it.",
@ -637,14 +638,16 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
except EnvironmentError as e: except EnvironmentError as e:
message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tags <filename> or <message>!", message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tags <filename> or <message>!",
"Project file <filename>{0}</filename> is suddenly inaccessible: <message>{1}</message>.", file_name, str(e)), "Project file <filename>{0}</filename> is suddenly inaccessible: <message>{1}</message>.", file_name, str(e)),
title = i18n_catalog.i18nc("@info:title", "Can't Open Project File")) title = i18n_catalog.i18nc("@info:title", "Can't Open Project File"),
message_type = Message.MessageType.ERROR)
message.show() message.show()
self.setWorkspaceName("") self.setWorkspaceName("")
return [], {} return [], {}
except zipfile.BadZipFile as e: except zipfile.BadZipFile as e:
message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tags <filename> or <message>!", message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tags <filename> or <message>!",
"Project file <filename>{0}</filename> is corrupt: <message>{1}</message>.", file_name, str(e)), "Project file <filename>{0}</filename> is corrupt: <message>{1}</message>.", file_name, str(e)),
title = i18n_catalog.i18nc("@info:title", "Can't Open Project File")) title = i18n_catalog.i18nc("@info:title", "Can't Open Project File"),
message_type = Message.MessageType.ERROR)
message.show() message.show()
self.setWorkspaceName("") self.setWorkspaceName("")
return [], {} return [], {}
@ -696,7 +699,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
if not global_stacks: if not global_stacks:
message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tag <filename>!", message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tag <filename>!",
"Project file <filename>{0}</filename> is made using profiles that" "Project file <filename>{0}</filename> is made using profiles that"
" are unknown to this version of Ultimaker Cura.", file_name)) " are unknown to this version of Ultimaker Cura.", file_name),
message_type = Message.MessageType.ERROR)
message.show() message.show()
self.setWorkspaceName("") self.setWorkspaceName("")
return [], {} return [], {}

View file

@ -114,13 +114,17 @@ class DrivePluginExtension(QObject, Extension):
self.restoringStateChanged.emit() self.restoringStateChanged.emit()
if error_message: if error_message:
self.backupIdBeingRestored = "" self.backupIdBeingRestored = ""
Message(error_message, title = catalog.i18nc("@info:title", "Backup")).show() Message(error_message,
title = catalog.i18nc("@info:title", "Backup"),
message_type = Message.MessageType.ERROR).show()
def _onCreatingStateChanged(self, is_creating: bool = False, error_message: str = None) -> None: def _onCreatingStateChanged(self, is_creating: bool = False, error_message: str = None) -> None:
self._is_creating_backup = is_creating self._is_creating_backup = is_creating
self.creatingStateChanged.emit() self.creatingStateChanged.emit()
if error_message: if error_message:
Message(error_message, title = catalog.i18nc("@info:title", "Backup")).show() Message(error_message,
title = catalog.i18nc("@info:title", "Backup"),
message_type = Message.MessageType.ERROR).show()
else: else:
self._storeBackupDate() self._storeBackupDate()
if not is_creating and not error_message: if not is_creating and not error_message:

View file

@ -73,6 +73,7 @@ class DFFileExportAndUploadManager:
text = "Your {} uploaded to '{}'.".format("file was" if len(self._file_upload_job_metadata) <= 1 else "files were", self._library_project_name), text = "Your {} uploaded to '{}'.".format("file was" if len(self._file_upload_job_metadata) <= 1 else "files were", self._library_project_name),
title = "Upload successful", title = "Upload successful",
lifetime = 0, lifetime = 0,
message_type=Message.MessageType.POSITIVE
) )
self._generic_success_message.addAction( self._generic_success_message.addAction(
"open_df_project", "open_df_project",
@ -81,8 +82,6 @@ class DFFileExportAndUploadManager:
) )
self._generic_success_message.actionTriggered.connect(self._onMessageActionTriggered) self._generic_success_message.actionTriggered.connect(self._onMessageActionTriggered)
def _onCuraProjectFileExported(self, job: ExportFileJob) -> None: def _onCuraProjectFileExported(self, job: ExportFileJob) -> None:
"""Handler for when the DF Library workspace file (3MF) has been created locally. """Handler for when the DF Library workspace file (3MF) has been created locally.

View file

@ -530,7 +530,8 @@ class DigitalFactoryController(QObject):
Message( Message(
text = "Failed to write to temporary file for '{}'.".format(file_name), text = "Failed to write to temporary file for '{}'.".format(file_name),
title = "File-system error", title = "File-system error",
lifetime = 10 lifetime = 10,
message_type=Message.MessageType.ERROR
).show() ).show()
return return
@ -544,7 +545,8 @@ class DigitalFactoryController(QObject):
Message( Message(
text = "Failed Digital Library download for '{}'.".format(f), text = "Failed Digital Library download for '{}'.".format(f),
title = "Network error {}".format(error), title = "Network error {}".format(error),
lifetime = 10 lifetime = 10,
message_type=Message.MessageType.ERROR
).show() ).show()
download_manager = HttpRequestManager.getInstance() download_manager = HttpRequestManager.getInstance()
@ -589,7 +591,10 @@ class DigitalFactoryController(QObject):
if filename == "": if filename == "":
Logger.log("w", "The file name cannot be empty.") Logger.log("w", "The file name cannot be empty.")
Message(text = "Cannot upload file with an empty name to the Digital Library", title = "Empty file name provided", lifetime = 0).show() Message(text = "Cannot upload file with an empty name to the Digital Library",
title = "Empty file name provided",
lifetime = 0,
message_type = Message.MessageType.ERROR).show()
return return
self._saveFileToSelectedProjectHelper(filename, formats) self._saveFileToSelectedProjectHelper(filename, formats)

View file

@ -28,7 +28,8 @@ class ModelChecker(QObject, Extension):
self._caution_message = Message("", #Message text gets set when the message gets shown, to display the models in question. self._caution_message = Message("", #Message text gets set when the message gets shown, to display the models in question.
lifetime = 0, lifetime = 0,
title = catalog.i18nc("@info:title", "3D Model Assistant")) title = catalog.i18nc("@info:title", "3D Model Assistant"),
message_type = Message.MessageType.WARNING)
self._change_timer = QTimer() self._change_timer = QTimer()
self._change_timer.setInterval(200) self._change_timer.setInterval(200)

View file

@ -136,7 +136,8 @@ class RemovableDriveOutputDevice(OutputDevice):
except: except:
Logger.logException("w", "An execption occured while trying to write to removable drive.") Logger.logException("w", "An execption occured while trying to write to removable drive.")
message = Message(catalog.i18nc("@info:status", "Could not save to removable drive {0}: {1}").format(self.getName(),str(job.getError())), message = Message(catalog.i18nc("@info:status", "Could not save to removable drive {0}: {1}").format(self.getName(),str(job.getError())),
title = catalog.i18nc("@info:title", "Error")) title = catalog.i18nc("@info:title", "Error"),
message_type = Message.MessageType.ERROR)
message.show() message.show()
self.writeError.emit(self) self.writeError.emit(self)
return return
@ -144,13 +145,17 @@ class RemovableDriveOutputDevice(OutputDevice):
self._writing = False self._writing = False
self.writeFinished.emit(self) self.writeFinished.emit(self)
if job.getResult(): if job.getResult():
message = Message(catalog.i18nc("@info:status", "Saved to Removable Drive {0} as {1}").format(self.getName(), os.path.basename(job.getFileName())), title = catalog.i18nc("@info:title", "File Saved")) message = Message(catalog.i18nc("@info:status", "Saved to Removable Drive {0} as {1}").format(self.getName(), os.path.basename(job.getFileName())),
title = catalog.i18nc("@info:title", "File Saved"),
message_type = Message.MessageType.POSITIVE)
message.addAction("eject", catalog.i18nc("@action:button", "Eject"), "eject", catalog.i18nc("@action", "Eject removable device {0}").format(self.getName())) message.addAction("eject", catalog.i18nc("@action:button", "Eject"), "eject", catalog.i18nc("@action", "Eject removable device {0}").format(self.getName()))
message.actionTriggered.connect(self._onActionTriggered) message.actionTriggered.connect(self._onActionTriggered)
message.show() message.show()
self.writeSuccess.emit(self) self.writeSuccess.emit(self)
else: else:
message = Message(catalog.i18nc("@info:status", "Could not save to removable drive {0}: {1}").format(self.getName(), str(job.getError())), title = catalog.i18nc("@info:title", "Warning")) message = Message(catalog.i18nc("@info:status", "Could not save to removable drive {0}: {1}").format(self.getName(), str(job.getError())),
title = catalog.i18nc("@info:title", "Error"),
message_type = Message.MessageType.ERROR)
message.show() message.show()
self.writeError.emit(self) self.writeError.emit(self)
job.getStream().close() job.getStream().close()

View file

@ -126,9 +126,13 @@ class SimulationView(CuraView):
self._compatibility_mode = self._evaluateCompatibilityMode() self._compatibility_mode = self._evaluateCompatibilityMode()
self._wireprint_warning_message = Message(catalog.i18nc("@info:status", "Cura does not accurately display layers when Wire Printing is enabled."), self._wireprint_warning_message = Message(catalog.i18nc("@info:status", "Cura does not accurately display layers when Wire Printing is enabled."),
title = catalog.i18nc("@info:title", "Simulation View")) title = catalog.i18nc("@info:title", "Simulation View"),
self._slice_first_warning_message = Message(catalog.i18nc("@info:status", "Nothing is shown because you need to slice first."), title = catalog.i18nc("@info:title", "No layers to show"), message_type = Message.MessageType.WARNING)
option_text = catalog.i18nc("@info:option_text", "Do not show this message again"), option_state = False) self._slice_first_warning_message = Message(catalog.i18nc("@info:status", "Nothing is shown because you need to slice first."),
title = catalog.i18nc("@info:title", "No layers to show"),
option_text = catalog.i18nc("@info:option_text", "Do not show this message again"),
option_state = False,
message_type = Message.MessageType.WARNING)
self._slice_first_warning_message.optionToggled.connect(self._onDontAskMeAgain) self._slice_first_warning_message.optionToggled.connect(self._onDontAskMeAgain)
CuraApplication.getInstance().getPreferences().addPreference(self._no_layers_warning_preference, True) CuraApplication.getInstance().getPreferences().addPreference(self._no_layers_warning_preference, True)

View file

@ -72,7 +72,8 @@ class SolidView(View):
lifetime = 60 * 5, # leave message for 5 minutes lifetime = 60 * 5, # leave message for 5 minutes
title = catalog.i18nc("@info:title", "Model Errors"), title = catalog.i18nc("@info:title", "Model Errors"),
option_text = catalog.i18nc("@info:option_text", "Do not show this message again"), option_text = catalog.i18nc("@info:option_text", "Do not show this message again"),
option_state = False option_state = False,
message_type=Message.MessageType.WARNING
) )
self._xray_warning_message.optionToggled.connect(self._onDontAskMeAgain) self._xray_warning_message.optionToggled.connect(self._onDontAskMeAgain)
application.getPreferences().addPreference(self._show_xray_warning_preference, True) application.getPreferences().addPreference(self._show_xray_warning_preference, True)

View file

@ -111,4 +111,4 @@ class SyncOrchestrator(Extension):
"""Logs an error and shows it to the user""" """Logs an error and shows it to the user"""
Logger.error(text) Logger.error(text)
Message(text, lifetime=0).show() Message(text, lifetime = 0, message_type = Message.MessageType.ERROR).show()

View file

@ -19,7 +19,8 @@ class LegacyDeviceNoLongerSupportedMessage(Message):
"running Ultimaker Connect. Please update the printer to the " "running Ultimaker Connect. Please update the printer to the "
"latest firmware."), "latest firmware."),
title = I18N_CATALOG.i18nc("@info:title", "Update your printer"), title = I18N_CATALOG.i18nc("@info:title", "Update your printer"),
lifetime = 10 lifetime = 10,
message_type = Message.MessageType.WARNING
) )
def show(self) -> None: def show(self) -> None:

View file

@ -29,7 +29,8 @@ class NotClusterHostMessage(Message):
"it as a group host.", device.name), "it as a group host.", device.name),
title = I18N_CATALOG.i18nc("@info:title", "Not a group host"), title = I18N_CATALOG.i18nc("@info:title", "Not a group host"),
lifetime = 0, lifetime = 0,
dismissable = True dismissable = True,
message_type = Message.MessageType.ERROR
) )
self._address = device.address self._address = device.address
self.addAction("", I18N_CATALOG.i18nc("@action", "Configure group"), "", "") self.addAction("", I18N_CATALOG.i18nc("@action", "Configure group"), "", "")

View file

@ -14,5 +14,6 @@ class PrintJobUploadBlockedMessage(Message):
super().__init__( super().__init__(
text = I18N_CATALOG.i18nc("@info:status", "Please wait until the current job has been sent."), text = I18N_CATALOG.i18nc("@info:status", "Please wait until the current job has been sent."),
title = I18N_CATALOG.i18nc("@info:title", "Print error"), title = I18N_CATALOG.i18nc("@info:title", "Print error"),
lifetime = 10 lifetime = 10,
message_type = Message.MessageType.WARNING
) )

View file

@ -13,5 +13,6 @@ class PrintJobUploadErrorMessage(Message):
def __init__(self, message: str = None) -> None: def __init__(self, message: str = None) -> None:
super().__init__( super().__init__(
text = message or I18N_CATALOG.i18nc("@info:text", "Could not upload the data to the printer."), text = message or I18N_CATALOG.i18nc("@info:text", "Could not upload the data to the printer."),
title = I18N_CATALOG.i18nc("@info:title", "Network error") title = I18N_CATALOG.i18nc("@info:title", "Network error"),
message_type=Message.MessageType.ERROR
) )

View file

@ -15,5 +15,6 @@ class PrintJobUploadQueueFullMessage(Message):
super().__init__( super().__init__(
text = I18N_CATALOG.i18nc("@info:status", "Print job queue is full. The printer can't accept a new job."), text = I18N_CATALOG.i18nc("@info:status", "Print job queue is full. The printer can't accept a new job."),
title = I18N_CATALOG.i18nc("@info:title", "Queue Full"), title = I18N_CATALOG.i18nc("@info:title", "Queue Full"),
lifetime = 10 lifetime = 10,
message_type=Message.MessageType.WARNING
) )

View file

@ -13,5 +13,6 @@ class PrintJobUploadSuccessMessage(Message):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__( super().__init__(
text = I18N_CATALOG.i18nc("@info:status", "Print job was successfully sent to the printer."), text = I18N_CATALOG.i18nc("@info:status", "Print job was successfully sent to the printer."),
title = I18N_CATALOG.i18nc("@info:title", "Data Sent") title = I18N_CATALOG.i18nc("@info:title", "Data Sent"),
message_type = Message.MessageType.POSITIVE
) )

View file

@ -131,7 +131,9 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
""" """
if self._is_printing: if self._is_printing:
message = Message(text = catalog.i18nc("@message", "A print is still in progress. Cura cannot start another print via USB until the previous print has completed."), title = catalog.i18nc("@message", "Print in Progress")) message = Message(text = catalog.i18nc("@message", "A print is still in progress. Cura cannot start another print via USB until the previous print has completed."),
title = catalog.i18nc("@message", "Print in Progress"),
message_type = Message.MessageType.WARNING)
message.show() message.show()
return # Already printing return # Already printing
self.writeStarted.emit(self) self.writeStarted.emit(self)