From 1cfdf4ae5fc3895899954dd89453e276c5709c74 Mon Sep 17 00:00:00 2001 From: "liz.li" Date: Tue, 28 Nov 2023 10:56:50 +0800 Subject: [PATCH] FIX: dailytips should not change content frequently when slicing all jira: STUDIO-5234 Change-Id: Icb7e9c28404d9db8ebed58d937e13f89c5403b5c --- src/slic3r/GUI/NotificationManager.cpp | 16 ++++++++++++++++ src/slic3r/GUI/NotificationManager.hpp | 1 + src/slic3r/GUI/Plater.cpp | 4 ++++ src/slic3r/GUI/SlicingProgressNotification.cpp | 4 ---- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index ece473b91..c70c571e3 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -1943,6 +1943,22 @@ void NotificationManager::init_slicing_progress_notification(std::function(data, m_id_provider, m_evt_handler, cancel_callback), 0); } +void NotificationManager::update_slicing_notif_dailytips(bool need_change) +{ + for (std::unique_ptr& notification : m_pop_notifications) { + if (notification->get_type() == NotificationType::SlicingProgress) { + SlicingProgressNotification* spn = dynamic_cast(notification.get()); + if (need_change) { + wxGetApp().plater()->get_dailytips()->close(); + spn->get_dailytips_panel()->retrieve_data_from_hint_database(HintDataNavigation::Random); + wxGetApp().plater()->get_current_canvas3D()->schedule_extra_frame(0); + } + return; + } + } + // Slicing progress notification was not found - init it thru plater so correct cancel callback function is appended + wxGetApp().plater()->init_notification_manager(); +} void NotificationManager::set_slicing_progress_began() { for (std::unique_ptr & notification : m_pop_notifications) { diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index a8221e89e..91211a661 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -244,6 +244,7 @@ public: // notifications with progress bar // slicing progress void init_slicing_progress_notification(std::function cancel_callback); + void update_slicing_notif_dailytips(bool need_change); void set_slicing_progress_began(); // percentage negative = canceled, <0-1) = progress, 1 = completed void set_slicing_progress_percentage(const std::string& text, float percentage); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 73464bf31..b2df6d975 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6186,7 +6186,11 @@ void Plater::priv::on_slicing_began() clear_warnings(); notification_manager->close_notification_of_type(NotificationType::SignDetected); notification_manager->close_notification_of_type(NotificationType::ExportFinished); + bool is_first_plate = m_cur_slice_plate == 0; + bool slice_all = q->m_only_gcode ? m_slice_all_only_has_gcode : m_slice_all; + bool need_change_dailytips = !(slice_all && !is_first_plate); notification_manager->set_slicing_progress_began(); + notification_manager->update_slicing_notif_dailytips(need_change_dailytips); } void Plater::priv::add_warning(const Slic3r::PrintStateBase::Warning& warning, size_t oid) { diff --git a/src/slic3r/GUI/SlicingProgressNotification.cpp b/src/slic3r/GUI/SlicingProgressNotification.cpp index 0dd280235..5600c6247 100644 --- a/src/slic3r/GUI/SlicingProgressNotification.cpp +++ b/src/slic3r/GUI/SlicingProgressNotification.cpp @@ -85,10 +85,6 @@ bool NotificationManager::SlicingProgressNotification::set_progress_state(Notifi if ((m_sp_state != SlicingProgressState::SP_BEGAN && m_sp_state != SlicingProgressState::SP_PROGRESS) || percent < m_percentage) return false; set_percentage(percent); - if (m_sp_state == SlicingProgressState::SP_BEGAN) { - wxGetApp().plater()->get_dailytips()->close(); - m_dailytips_panel->retrieve_data_from_hint_database(HintDataNavigation::Random); - } m_sp_state = state; m_current_fade_opacity = 1; return true;