Merge branch 'dk_printhost'
This commit is contained in:
commit
92de7bafc6
@ -5,6 +5,7 @@
|
|||||||
#include "ImGuiWrapper.hpp"
|
#include "ImGuiWrapper.hpp"
|
||||||
#include "PrintHostDialogs.hpp"
|
#include "PrintHostDialogs.hpp"
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
|
#include "../Utils/PrintHost.hpp"
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
@ -827,8 +828,6 @@ void NotificationManager::ProgressBarNotification::render_bar(ImGuiWrapper& imgu
|
|||||||
//------PrintHostUploadNotification----------------
|
//------PrintHostUploadNotification----------------
|
||||||
void NotificationManager::PrintHostUploadNotification::set_percentage(float percent)
|
void NotificationManager::PrintHostUploadNotification::set_percentage(float percent)
|
||||||
{
|
{
|
||||||
if (m_uj_state == UploadJobState::PB_CANCELLED)
|
|
||||||
return;
|
|
||||||
m_percentage = percent;
|
m_percentage = percent;
|
||||||
if (percent >= 1.0f) {
|
if (percent >= 1.0f) {
|
||||||
m_uj_state = UploadJobState::PB_COMPLETED;
|
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);
|
ImGui::SetCursorPosY(win_size.y / 2 - button_size.y);
|
||||||
if (imgui.button(button_text.c_str(), button_size.x, button_size.y))
|
if (imgui.button(button_text.c_str(), button_size.x, button_size.y))
|
||||||
{
|
{
|
||||||
assert(m_evt_handler != nullptr);
|
wxGetApp().printhost_job_queue().cancel(m_job_id - 1);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//invisible large button
|
//invisible large button
|
||||||
@ -926,11 +921,7 @@ void NotificationManager::PrintHostUploadNotification::render_cancel_button(ImGu
|
|||||||
ImGui::SetCursorPosY(0);
|
ImGui::SetCursorPosY(0);
|
||||||
if (imgui.button(" ", m_line_height * 2.f, win_size.y))
|
if (imgui.button(" ", m_line_height * 2.f, win_size.y))
|
||||||
{
|
{
|
||||||
assert(m_evt_handler != nullptr);
|
wxGetApp().printhost_job_queue().cancel(m_job_id - 1);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
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);
|
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);
|
std::string text = PrintHostUploadNotification::get_upload_job_text(id, filename, host);
|
||||||
NotificationData data{ NotificationType::PrintHostUpload, NotificationLevel::ProgressBarNotification, 0, text };
|
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)
|
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);
|
std::string text = PrintHostUploadNotification::get_upload_job_text(id, filename, host);
|
||||||
// bool found = false;
|
|
||||||
for (std::unique_ptr<PopNotification>& notification : m_pop_notifications) {
|
for (std::unique_ptr<PopNotification>& notification : m_pop_notifications) {
|
||||||
if (notification->get_type() == NotificationType::PrintHostUpload && notification->compare_text(text)) {
|
if (notification->get_type() == NotificationType::PrintHostUpload && notification->compare_text(text)) {
|
||||||
dynamic_cast<PrintHostUploadNotification*>(notification.get())->set_percentage(percentage);
|
dynamic_cast<PrintHostUploadNotification*>(notification.get())->set_percentage(percentage);
|
||||||
wxGetApp().plater()->get_current_canvas3D()->schedule_extra_frame(0);
|
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)
|
void NotificationManager::upload_job_notification_show_canceled(int id, const std::string& filename, const std::string& host)
|
||||||
{
|
{
|
||||||
|
@ -147,7 +147,7 @@ public:
|
|||||||
// Exporting finished, show this information with path, button to open containing folder and if ejectable - eject button
|
// Exporting finished, show this information with path, button to open containing folder and if ejectable - eject button
|
||||||
void push_exporting_finished_notification(const std::string& path, const std::string& dir_path, bool on_removable);
|
void push_exporting_finished_notification(const std::string& path, const std::string& dir_path, bool on_removable);
|
||||||
// notification with progress bar
|
// notification with progress bar
|
||||||
void push_upload_job_notification(wxEvtHandler* evt_handler, int id, float filesize, const std::string& filename, const std::string& host, float percentage = 0);
|
void push_upload_job_notification(int id, float filesize, const std::string& filename, const std::string& host, float percentage = 0);
|
||||||
void set_upload_job_notification_percentage(int id, const std::string& filename, const std::string& host, float percentage);
|
void set_upload_job_notification_percentage(int id, const std::string& filename, const std::string& host, float percentage);
|
||||||
void upload_job_notification_show_canceled(int id, const std::string& filename, const std::string& host);
|
void upload_job_notification_show_canceled(int id, const std::string& filename, const std::string& host);
|
||||||
void upload_job_notification_show_error(int id, const std::string& filename, const std::string& host);
|
void upload_job_notification_show_error(int id, const std::string& filename, const std::string& host);
|
||||||
|
@ -245,7 +245,6 @@ PrintHostQueueDialog::PrintHostQueueDialog(wxWindow *parent)
|
|||||||
|
|
||||||
const JobState state = get_state(selected);
|
const JobState state = get_state(selected);
|
||||||
if (state < ST_ERROR) {
|
if (state < ST_ERROR) {
|
||||||
// TODO: cancel
|
|
||||||
GUI::wxGetApp().printhost_job_queue().cancel(selected);
|
GUI::wxGetApp().printhost_job_queue().cancel(selected);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -282,7 +281,7 @@ void PrintHostQueueDialog::append_job(const PrintHostJob &job)
|
|||||||
// Both strings are UTF-8 encoded.
|
// Both strings are UTF-8 encoded.
|
||||||
upload_names.emplace_back(job.printhost->get_host(), job.upload_data.upload_path.string());
|
upload_names.emplace_back(job.printhost->get_host(), job.upload_data.upload_path.string());
|
||||||
|
|
||||||
wxGetApp().notification_manager()->push_upload_job_notification(this, job_list->GetItemCount(), (float)size_i / 1024 / 1024, job.upload_data.upload_path.string(), job.printhost->get_host());
|
wxGetApp().notification_manager()->push_upload_job_notification(job_list->GetItemCount(), (float)size_i / 1024 / 1024, job.upload_data.upload_path.string(), job.printhost->get_host());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintHostQueueDialog::on_dpi_changed(const wxRect &suggested_rect)
|
void PrintHostQueueDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
|
Loading…
Reference in New Issue
Block a user