From aebbafc75c28e564c7b2c14cb0bb8d0de5473404 Mon Sep 17 00:00:00 2001 From: David Kocik <kocikdav@gmail.com> Date: Thu, 29 Jul 2021 13:54:45 +0200 Subject: [PATCH] Validate Error notification --- src/slic3r/GUI/NotificationManager.cpp | 5 +++++ src/slic3r/GUI/NotificationManager.hpp | 11 +++++++---- src/slic3r/GUI/Plater.cpp | 11 ++++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index 1142fdca8..48d7f5de8 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -1096,6 +1096,11 @@ void NotificationManager::push_notification(NotificationType type, } push_notification_data({ type, level, duration, text, hypertext, callback }, timestamp); } +void NotificationManager::push_validate_error_notification(const std::string& text) +{ + push_notification_data({ NotificationType::ValidateError, NotificationLevel::ErrorNotification, 0, _u8L("ERROR:") + "\n" + text }, 0); +} + void NotificationManager::push_slicing_error_notification(const std::string& text) { set_all_slicing_errors_gray(false); diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index d9a5230f3..81599b68f 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -55,8 +55,11 @@ enum class NotificationType // Contains a hyperlink to execute installation of the new system profiles. PresetUpdateAvailable, // LoadingFailed, - // Not used - instead Slicing error is used for both slicing and validate errors. -// ValidateError, + // Errors emmited by Print::validate + // difference from Slicing error is that they disappear not grey out at update_background_process + ValidateError, + // Notification emitted by Print::validate + ValidateWarning, // Slicing error produced by BackgroundSlicingProcess::validate() or by the BackgroundSlicingProcess background // thread thowing a SlicingError exception. SlicingError, @@ -79,8 +82,6 @@ enum class NotificationType EmptyAutoColorChange, // Notification about detected sign SignDetected, - // Notification emitted by Print::validate - PrintValidateWarning, // Notification telling user to quit SLA supports manual editing QuitSLAManualMode, // Desktop integration basic info @@ -123,6 +124,8 @@ public: // ErrorNotification and ImportantNotification are never faded out. void push_notification(NotificationType type, NotificationLevel level, const std::string& text, const std::string& hypertext = "", std::function<bool(wxEvtHandler*)> callback = std::function<bool(wxEvtHandler*)>(), int timestamp = 0); + // Creates Validate Error notification with a custom text and no fade out. + void push_validate_error_notification(const std::string& text); // Creates Slicing Error notification with a custom text and no fade out. void push_slicing_error_notification(const std::string& text); // Creates Slicing Warning notification with a custom text and no fade out. diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 0a3ae2743..e87b4b3d7 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2897,7 +2897,7 @@ void Plater::priv::update_print_volume_state() void Plater::priv::process_validation_warning(const std::string& warning) const { if (warning.empty()) - notification_manager->close_notification_of_type(NotificationType::PrintValidateWarning); + notification_manager->close_notification_of_type(NotificationType::ValidateWarning); else { std::string text = warning; std::string hypertext = ""; @@ -2920,9 +2920,9 @@ void Plater::priv::process_validation_warning(const std::string& warning) const } notification_manager->push_notification( - NotificationType::PrintValidateWarning, - NotificationManager::NotificationLevel::ImportantNotification, - text, hypertext, action_fn + NotificationType::ValidateWarning, + NotificationManager::NotificationLevel::WarningNotification, + _u8L("WARNING:") + "\n" + text, hypertext, action_fn ); } } @@ -2974,6 +2974,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool std::string err = background_process.validate(&warning); if (err.empty()) { notification_manager->set_all_slicing_errors_gray(true); + notification_manager->close_notification_of_type(NotificationType::ValidateError); if (invalidated != Print::APPLY_STATUS_UNCHANGED && background_processing_enabled()) return_state |= UPDATE_BACKGROUND_PROCESS_RESTART; @@ -2989,7 +2990,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool else { // The print is not valid. // Show error as notification. - notification_manager->push_slicing_error_notification(err); + notification_manager->push_validate_error_notification(err); return_state |= UPDATE_BACKGROUND_PROCESS_INVALID; if (printer_technology == ptFFF) { const Print* print = background_process.fff_print();