Fixed upload notification cancel button

This commit is contained in:
David Kocik 2021-03-15 17:40:17 +01:00
parent 80b9a3c62b
commit 5daaaa2845
3 changed files with 8 additions and 25 deletions

View file

@ -5,6 +5,7 @@
#include "ImGuiWrapper.hpp"
#include "PrintHostDialogs.hpp"
#include "wxExtensions.hpp"
#include "../Utils/PrintHost.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/log/trivial.hpp>
@ -827,8 +828,6 @@ void NotificationManager::ProgressBarNotification::render_bar(ImGuiWrapper& imgu
//------PrintHostUploadNotification----------------
void NotificationManager::PrintHostUploadNotification::set_percentage(float percent)
{
if (m_uj_state == UploadJobState::PB_CANCELLED)
return;
m_percentage = percent;
if (percent >= 1.0f) {
m_uj_state = UploadJobState::PB_COMPLETED;
@ -914,11 +913,7 @@ void NotificationManager::PrintHostUploadNotification::render_cancel_button(ImGu
ImGui::SetCursorPosY(win_size.y / 2 - button_size.y);
if (imgui.button(button_text.c_str(), button_size.x, button_size.y))
{
assert(m_evt_handler != nullptr);
if (m_evt_handler != nullptr) {
auto evt = new PrintHostQueueDialog::Event(GUI::EVT_PRINTHOST_CANCEL, m_job_id, m_job_id);
wxQueueEvent(m_evt_handler, evt);
}
wxGetApp().printhost_job_queue().cancel(m_job_id - 1);
}
//invisible large button
@ -926,11 +921,7 @@ void NotificationManager::PrintHostUploadNotification::render_cancel_button(ImGu
ImGui::SetCursorPosY(0);
if (imgui.button(" ", m_line_height * 2.f, win_size.y))
{
assert(m_evt_handler != nullptr);
if (m_evt_handler != nullptr) {
auto evt = new PrintHostQueueDialog::Event(GUI::EVT_PRINTHOST_CANCEL, m_job_id, m_job_id);
wxQueueEvent(m_evt_handler, evt);
}
wxGetApp().printhost_job_queue().cancel(m_job_id - 1);
}
ImGui::PopStyleColor();
ImGui::PopStyleColor();
@ -1129,28 +1120,21 @@ void NotificationManager::push_exporting_finished_notification(const std::string
push_notification_data(std::make_unique<NotificationManager::ExportFinishedNotification>(data, m_id_provider, m_evt_handler, on_removable, path, dir_path), 0);
}
void NotificationManager::push_upload_job_notification(wxEvtHandler* evt_handler, int id, float filesize, const std::string& filename, const std::string& host, float percentage)
void NotificationManager::push_upload_job_notification(int id, float filesize, const std::string& filename, const std::string& host, float percentage)
{
std::string text = PrintHostUploadNotification::get_upload_job_text(id, filename, host);
NotificationData data{ NotificationType::PrintHostUpload, NotificationLevel::ProgressBarNotification, 0, text };
push_notification_data(std::make_unique<NotificationManager::PrintHostUploadNotification>(data, m_id_provider, evt_handler, 0, id, filesize), 0);
push_notification_data(std::make_unique<NotificationManager::PrintHostUploadNotification>(data, m_id_provider, m_evt_handler, 0, id, filesize), 0);
}
void NotificationManager::set_upload_job_notification_percentage(int id, const std::string& filename, const std::string& host, float percentage)
{
std::string text = PrintHostUploadNotification::get_upload_job_text(id, filename, host);
// bool found = false;
for (std::unique_ptr<PopNotification>& notification : m_pop_notifications) {
if (notification->get_type() == NotificationType::PrintHostUpload && notification->compare_text(text)) {
dynamic_cast<PrintHostUploadNotification*>(notification.get())->set_percentage(percentage);
wxGetApp().plater()->get_current_canvas3D()->schedule_extra_frame(0);
// found = true;
}
}
/*
if (!found) {
push_upload_job_notification(id, filename, host, percentage);
}
*/
}
void NotificationManager::upload_job_notification_show_canceled(int id, const std::string& filename, const std::string& host)
{