mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
FIX:add the sd card removal function
Change-Id: I98592a5d3d4abcfd3a67b8c12fa4cf07e79b0e4b
This commit is contained in:
parent
b9b3f7b4c1
commit
bf927f5adc
12 changed files with 74 additions and 56 deletions
1
resources/images/notification_eject_sd.svg
Normal file
1
resources/images/notification_eject_sd.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800"><title>notification_eject_sd</title><path d="M702.38,400c0,166.31-135.31,300.87-302.38,300.87S97.62,566.31,97.62,400,232.93,99.13,400,99.13,702.38,233.69,702.38,400Z" fill="#eee"/><path d="M240.49,533.8a16.78,16.78,0,0,1,16.63-16.63H552a16.64,16.64,0,0,1,0,33.27H257.12A16.78,16.78,0,0,1,240.49,533.8Z" fill="#ff6f00" fill-rule="evenodd"/><path d="M530,434.77,405.29,220.08l-124,214.69ZM434.77,203.45c-12.85-21.92-45.35-21.92-58.2,0L251.83,418.14c-12.85,21.93,3,49.9,28.73,49.9H529.27c25.7,0,42.33-28,28.72-49.9Z" fill="#ff6f00" fill-rule="evenodd"/></svg>
|
After Width: | Height: | Size: 651 B |
1
resources/images/notification_eject_sd_hover.svg
Normal file
1
resources/images/notification_eject_sd_hover.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800"><title>notification_eject_sd_hover</title><path d="M780.4,400c0,209.22-170.23,378.5-380.4,378.5S19.6,609.22,19.6,400,189.83,21.5,400,21.5,780.4,190.78,780.4,400Z" fill="#eee"/><path d="M199.34,568.33a21.11,21.11,0,0,1,20.92-20.92H591.15a20.92,20.92,0,0,1,0,41.84H220.26A21.11,21.11,0,0,1,199.34,568.33Z" fill="#ff6f00" fill-rule="evenodd"/><path d="M563.57,443.75,406.66,173.66l-156,270.09Zm-119.82-291c-16.17-27.58-57.06-27.58-73.23,0L213.6,422.82c-16.16,27.58,3.81,62.77,36.14,62.77H562.62c32.34,0,53.26-35.19,36.14-62.77Z" fill="#ff6f00" fill-rule="evenodd"/></svg>
|
After Width: | Height: | Size: 663 B |
|
@ -253,8 +253,8 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/wxExtensions.hpp
|
||||
GUI/WipeTowerDialog.cpp
|
||||
GUI/WipeTowerDialog.hpp
|
||||
#GUI/RemovableDriveManager.cpp
|
||||
#GUI/RemovableDriveManager.hpp
|
||||
GUI/RemovableDriveManager.cpp
|
||||
GUI/RemovableDriveManager.hpp
|
||||
GUI/SendSystemInfoDialog.cpp
|
||||
GUI/SendSystemInfoDialog.hpp
|
||||
GUI/ImGuiWrapper.hpp
|
||||
|
@ -387,8 +387,8 @@ if (APPLE)
|
|||
list(APPEND SLIC3R_GUI_SOURCES
|
||||
Utils/RetinaHelperImpl.mm
|
||||
Utils/MacDarkMode.mm
|
||||
#GUI/RemovableDriveManagerMM.mm
|
||||
#GUI/RemovableDriveManagerMM.h
|
||||
GUI/RemovableDriveManagerMM.mm
|
||||
GUI/RemovableDriveManagerMM.h
|
||||
GUI/Mouse3DHandlerMac.mm
|
||||
#GUI/InstanceCheckMac.mm
|
||||
#GUI/InstanceCheckMac.h
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
#include "SysInfoDialog.hpp"
|
||||
#include "UpdateDialogs.hpp"
|
||||
#include "Mouse3DController.hpp"
|
||||
//#include "RemovableDriveManager.hpp"
|
||||
#include "RemovableDriveManager.hpp"
|
||||
#include "InstanceCheck.hpp"
|
||||
#include "NotificationManager.hpp"
|
||||
#include "UnsavedChangesDialog.hpp"
|
||||
|
@ -1119,7 +1119,7 @@ GUI_App::GUI_App()
|
|||
, m_em_unit(10)
|
||||
, m_imgui(new ImGuiWrapper())
|
||||
, hms_query(new HMSQuery())
|
||||
//, m_removable_drive_manager(std::make_unique<RemovableDriveManager>())
|
||||
, m_removable_drive_manager(std::make_unique<RemovableDriveManager>())
|
||||
//, m_other_instance_message_handler(std::make_unique<OtherInstanceMessageHandler>())
|
||||
{
|
||||
//app config initializes early becasuse it is used in instance checking in BambuStudio.cpp
|
||||
|
|
|
@ -49,7 +49,7 @@ class NetworkAgent;
|
|||
|
||||
namespace GUI{
|
||||
|
||||
//class RemovableDriveManager;
|
||||
class RemovableDriveManager;
|
||||
class OtherInstanceMessageHandler;
|
||||
class MainFrame;
|
||||
class Sidebar;
|
||||
|
@ -244,7 +244,7 @@ private:
|
|||
const wxLanguageInfo *m_language_info_best = nullptr;
|
||||
|
||||
OpenGLManager m_opengl_mgr;
|
||||
//std::unique_ptr<RemovableDriveManager> m_removable_drive_manager;
|
||||
std::unique_ptr<RemovableDriveManager> m_removable_drive_manager;
|
||||
|
||||
std::unique_ptr<ImGuiWrapper> m_imgui;
|
||||
//std::unique_ptr <OtherInstanceMessageHandler> m_other_instance_message_handler;
|
||||
|
@ -479,7 +479,7 @@ public:
|
|||
std::vector<Tab *> tabs_list;
|
||||
std::vector<Tab *> model_tabs_list;
|
||||
|
||||
//RemovableDriveManager* removable_drive_manager() { return m_removable_drive_manager.get(); }
|
||||
RemovableDriveManager* removable_drive_manager() { return m_removable_drive_manager.get(); }
|
||||
//OtherInstanceMessageHandler* other_instance_message_handler() { return m_other_instance_message_handler.get(); }
|
||||
//wxSingleInstanceChecker* single_instance_checker() {return m_single_instance_checker.get();}
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ static const std::map<const wchar_t, std::string> font_icons_large = {
|
|||
{ImGui::CloseNotifButton , "notification_close" },
|
||||
{ImGui::CloseNotifHoverButton , "notification_close_hover" },
|
||||
//BBS removed
|
||||
//{ImGui::EjectButton , "notification_eject_sd" },
|
||||
//{ImGui::EjectHoverButton , "notification_eject_sd_hover" },
|
||||
{ImGui::EjectButton , "notification_eject_sd" },
|
||||
{ImGui::EjectHoverButton , "notification_eject_sd_hover" },
|
||||
//{ImGui::WarningMarker , "notification_warning" },
|
||||
//{ImGui::ErrorMarker , "notification_error" },
|
||||
{ImGui::CancelButton , "notification_cancel" },
|
||||
|
|
|
@ -34,7 +34,7 @@ static constexpr int FADING_OUT_TIMEOUT = 100;
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
//wxDEFINE_EVENT(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, EjectDriveNotificationClickedEvent);
|
||||
wxDEFINE_EVENT(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, EjectDriveNotificationClickedEvent);
|
||||
wxDEFINE_EVENT(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, ExportGcodeNotificationClickedEvent);
|
||||
wxDEFINE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClickedEvent);
|
||||
|
||||
|
@ -801,11 +801,11 @@ void NotificationManager::ExportFinishedNotification::render_text(ImGuiWrapper&
|
|||
void NotificationManager::ExportFinishedNotification::render_close_button(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
|
||||
{
|
||||
PopNotification::render_close_button(imgui, win_size_x, win_size_y, win_pos_x, win_pos_y);
|
||||
//if(m_to_removable && ! m_eject_pending)
|
||||
// render_eject_button(imgui, win_size_x, win_size_y, win_pos_x, win_pos_y);
|
||||
if (m_to_removable && !m_eject_pending)
|
||||
render_eject_button(imgui, win_size_x, win_size_y, win_pos_x, win_pos_y);
|
||||
}
|
||||
|
||||
/*void NotificationManager::ExportFinishedNotification::render_eject_button(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
|
||||
void NotificationManager::ExportFinishedNotification::render_eject_button(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
|
||||
{
|
||||
ImVec2 win_size(win_size_x, win_size_y);
|
||||
ImVec2 win_pos(win_pos_x, win_pos_y);
|
||||
|
@ -824,17 +824,19 @@ void NotificationManager::ExportFinishedNotification::render_close_button(ImGuiW
|
|||
{
|
||||
button_text = ImGui::EjectHoverButton;
|
||||
//tooltip
|
||||
|
||||
long time_now = wxGetLocalTime();
|
||||
if (m_hover_time > 0 && m_hover_time < time_now) {
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BACKGROUND);
|
||||
ImGui::BeginTooltip();
|
||||
imgui.text(_u8L("Eject drive") + " " + GUI::shortkey_ctrl_prefix() + "T");
|
||||
ImGui::EndTooltip();
|
||||
//ImGui::BeginTooltip();
|
||||
//imgui.text(_u8L("Eject drive") + " " + GUI::shortkey_ctrl_prefix() + "T");
|
||||
//ImGui::EndTooltip();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
if (m_hover_time == 0)
|
||||
m_hover_time = time_now;
|
||||
} else
|
||||
}
|
||||
else
|
||||
m_hover_time = 0;
|
||||
|
||||
ImVec2 button_pic_size = ImGui::CalcTextSize(button_text.c_str());
|
||||
|
@ -860,7 +862,8 @@ void NotificationManager::ExportFinishedNotification::render_close_button(ImGuiW
|
|||
on_eject_click();
|
||||
}
|
||||
ImGui::PopStyleColor(5);
|
||||
}*/
|
||||
}
|
||||
|
||||
bool NotificationManager::ExportFinishedNotification::on_text_click()
|
||||
{
|
||||
open_folder(m_export_dir_path);
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
//using EjectDriveNotificationClickedEvent = SimpleEvent;
|
||||
//wxDECLARE_EVENT(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, EjectDriveNotificationClickedEvent);
|
||||
using EjectDriveNotificationClickedEvent = SimpleEvent;
|
||||
wxDECLARE_EVENT(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, EjectDriveNotificationClickedEvent);
|
||||
using ExportGcodeNotificationClickedEvent = SimpleEvent;
|
||||
wxDECLARE_EVENT(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, ExportGcodeNotificationClickedEvent);
|
||||
using PresetUpdateAvailableClickedEvent = SimpleEvent;
|
||||
|
@ -690,9 +690,9 @@ private:
|
|||
void render_close_button(ImGuiWrapper& imgui,
|
||||
const float win_size_x, const float win_size_y,
|
||||
const float win_pos_x, const float win_pos_y) override;
|
||||
/*void render_eject_button(ImGuiWrapper& imgui,
|
||||
void render_eject_button(ImGuiWrapper& imgui,
|
||||
const float win_size_x, const float win_size_y,
|
||||
const float win_pos_x, const float win_pos_y);*/
|
||||
const float win_pos_x, const float win_pos_y);
|
||||
void render_minimize_button(ImGuiWrapper& imgui, const float win_pos_x, const float win_pos_y) override
|
||||
{ m_minimize_b_visible = false; }
|
||||
bool on_text_click() override;
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
#include "../Utils/UndoRedo.hpp"
|
||||
#include "../Utils/PresetUpdater.hpp"
|
||||
#include "../Utils/Process.hpp"
|
||||
//#include "RemovableDriveManager.hpp"
|
||||
#include "RemovableDriveManager.hpp"
|
||||
#include "InstanceCheck.hpp"
|
||||
#include "NotificationManager.hpp"
|
||||
#include "PresetComboBoxes.hpp"
|
||||
|
@ -2240,12 +2240,11 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
//notification_manager = new NotificationManager(this->q);
|
||||
|
||||
if (wxGetApp().is_editor()) {
|
||||
//this->q->Bind(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, [this](EjectDriveNotificationClickedEvent&) { this->q->eject_drive(); });
|
||||
this->q->Bind(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, [this](EjectDriveNotificationClickedEvent&) { this->q->eject_drive(); });
|
||||
this->q->Bind(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, [this](ExportGcodeNotificationClickedEvent&) { this->q->export_gcode(true); });
|
||||
this->q->Bind(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, [](PresetUpdateAvailableClickedEvent&) { wxGetApp().get_preset_updater()->on_update_notification_confirm(); });
|
||||
|
||||
/* BBS do not handle removeable driver event */
|
||||
/*
|
||||
this->q->Bind(EVT_REMOVABLE_DRIVE_EJECTED, [this](RemovableDriveEjectEvent &evt) {
|
||||
if (evt.data.second) {
|
||||
// BBS
|
||||
|
@ -2268,14 +2267,13 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
// Close notification ExportingFinished but only if last export was to removable
|
||||
notification_manager->device_ejected();
|
||||
});
|
||||
*/
|
||||
// Start the background thread and register this window as a target for update events.
|
||||
//wxGetApp().removable_drive_manager()->init(this->q);
|
||||
//#ifdef _WIN32
|
||||
wxGetApp().removable_drive_manager()->init(this->q);
|
||||
#ifdef _WIN32
|
||||
//Trigger enumeration of removable media on Win32 notification.
|
||||
//this->q->Bind(EVT_VOLUME_ATTACHED, [this](VolumeAttachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
||||
//this->q->Bind(EVT_VOLUME_DETACHED, [this](VolumeDetachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
||||
//#endif /* _WIN32 */
|
||||
this->q->Bind(EVT_VOLUME_ATTACHED, [this](VolumeAttachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
||||
this->q->Bind(EVT_VOLUME_DETACHED, [this](VolumeDetachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
// Initialize the Undo / Redo stack with a first snapshot.
|
||||
|
@ -5382,16 +5380,16 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt)
|
|||
notification_manager->close_notification_of_type(NotificationType::ExportOngoing);
|
||||
}
|
||||
// If writing to removable drive was scheduled, show notification with eject button
|
||||
/*if (exporting_status == ExportingStatus::EXPORTING_TO_REMOVABLE && !has_error) {
|
||||
if (exporting_status == ExportingStatus::EXPORTING_TO_REMOVABLE && !has_error) {
|
||||
//show_action_buttons(ready_to_slice);
|
||||
this->main_frame->update_slice_print_status(MainFrame::eEventSliceUpdate, ready_to_slice, true);
|
||||
notification_manager->push_exporting_finished_notification(last_output_path, last_output_dir_path,
|
||||
// Don't offer the "Eject" button on ChromeOS, the Linux side has no control over it.
|
||||
platform_flavor() != PlatformFlavor::LinuxOnChromium);
|
||||
//wxGetApp().removable_drive_manager()->set_exporting_finished(true);
|
||||
}else */
|
||||
//if (exporting_status == ExportingStatus::EXPORTING_TO_LOCAL && !has_error)
|
||||
// notification_manager->push_exporting_finished_notification(last_output_path, last_output_dir_path, false);
|
||||
wxGetApp().removable_drive_manager()->set_exporting_finished(true);
|
||||
}else
|
||||
if (exporting_status == ExportingStatus::EXPORTING_TO_LOCAL && !has_error)
|
||||
notification_manager->push_exporting_finished_notification(last_output_path, last_output_dir_path, false);
|
||||
}
|
||||
|
||||
exporting_status = ExportingStatus::NOT_EXPORTING;
|
||||
|
@ -8172,16 +8170,16 @@ void Plater::export_gcode(bool prefer_removable)
|
|||
}
|
||||
default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string()));
|
||||
AppConfig &appconfig = *wxGetApp().app_config;
|
||||
//RemovableDriveManager &removable_drive_manager = *wxGetApp().removable_drive_manager();
|
||||
RemovableDriveManager &removable_drive_manager = *wxGetApp().removable_drive_manager();
|
||||
// Get a last save path, either to removable media or to an internal media.
|
||||
std::string start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), prefer_removable);
|
||||
/*if (prefer_removable) {
|
||||
if (prefer_removable) {
|
||||
// Returns a path to a removable media if it exists, prefering start_dir. Update the internal removable drives database.
|
||||
start_dir = removable_drive_manager.get_removable_drive_path(start_dir);
|
||||
if (start_dir.empty())
|
||||
// Direct user to the last internal media.
|
||||
start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), false);
|
||||
}*/
|
||||
}
|
||||
|
||||
fs::path output_path;
|
||||
{
|
||||
|
@ -8209,8 +8207,8 @@ void Plater::export_gcode(bool prefer_removable)
|
|||
}
|
||||
|
||||
if (! output_path.empty()) {
|
||||
//bool path_on_removable_media = removable_drive_manager.set_and_verify_last_save_path(output_path.string());
|
||||
bool path_on_removable_media = false;
|
||||
bool path_on_removable_media = removable_drive_manager.set_and_verify_last_save_path(output_path.string());
|
||||
//bool path_on_removable_media = false;
|
||||
p->notification_manager->new_export_began(path_on_removable_media);
|
||||
p->exporting_status = path_on_removable_media ? ExportingStatus::EXPORTING_TO_REMOVABLE : ExportingStatus::EXPORTING_TO_LOCAL;
|
||||
p->last_output_path = output_path.string();
|
||||
|
@ -8279,13 +8277,20 @@ void Plater::export_gcode_3mf()
|
|||
p->notification_manager->new_export_began(path_on_removable_media);
|
||||
p->exporting_status = path_on_removable_media ? ExportingStatus::EXPORTING_TO_REMOVABLE : ExportingStatus::EXPORTING_TO_LOCAL;
|
||||
//BBS do not save last output path
|
||||
//p->last_output_path = output_path.string();
|
||||
p->last_output_path = output_path.string();
|
||||
p->last_output_dir_path = output_path.parent_path().string();
|
||||
int curr_plate_idx = get_partplate_list().get_curr_plate_index();
|
||||
export_3mf(output_path, SaveStrategy::Silence | SaveStrategy::SplitModel | SaveStrategy::WithGcode | SaveStrategy::SkipModel, curr_plate_idx); // BBS: silence
|
||||
// update lost output dir
|
||||
|
||||
RemovableDriveManager& removable_drive_manager = *wxGetApp().removable_drive_manager();
|
||||
|
||||
|
||||
bool on_removable = removable_drive_manager.is_path_on_removable_drive(p->last_output_dir_path);
|
||||
|
||||
|
||||
// update last output dir
|
||||
appconfig.update_last_output_dir(output_path.parent_path().string(), false);
|
||||
p->notification_manager->push_exporting_finished_notification(output_path.string(), p->last_output_dir_path, false);
|
||||
p->notification_manager->push_exporting_finished_notification(output_path.string(), p->last_output_dir_path, on_removable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8925,11 +8930,12 @@ void Plater::print_job_finished(wxCommandEvent &evt)
|
|||
}
|
||||
|
||||
// Called when the Eject button is pressed.
|
||||
/*void Plater::eject_drive()
|
||||
void Plater::eject_drive()
|
||||
{
|
||||
wxBusyCursor wait;
|
||||
wxGetApp().removable_drive_manager()->set_and_verify_last_save_path(p->last_output_dir_path);
|
||||
wxGetApp().removable_drive_manager()->eject_drive();
|
||||
}*/
|
||||
}
|
||||
|
||||
void Plater::take_snapshot(const std::string &snapshot_name) { p->take_snapshot(snapshot_name); }
|
||||
//void Plater::take_snapshot(const wxString &snapshot_name) { p->take_snapshot(snapshot_name); }
|
||||
|
|
|
@ -332,7 +332,7 @@ public:
|
|||
int export_config_3mf(int plate_idx = -1, Export3mfProgressFn proFn = nullptr);
|
||||
//BBS jump to nonitor after print job finished
|
||||
void print_job_finished(wxCommandEvent &evt);
|
||||
//void eject_drive();
|
||||
void eject_drive();
|
||||
|
||||
void take_snapshot(const std::string &snapshot_name);
|
||||
//void take_snapshot(const wxString &snapshot_name);
|
||||
|
|
|
@ -442,7 +442,14 @@ bool RemovableDriveManager::set_and_verify_last_save_path(const std::string &pat
|
|||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
#ifdef __APPLE__
|
||||
m_last_save_path = path;
|
||||
#else
|
||||
m_last_save_path = this->get_removable_drive_from_path(path);
|
||||
#endif
|
||||
|
||||
|
||||
m_exporting_finished = false;
|
||||
return ! m_last_save_path.empty();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
RemovableDriveManager() = default;
|
||||
RemovableDriveManager(RemovableDriveManager const&) = delete;
|
||||
void operator=(RemovableDriveManager const&) = delete;
|
||||
~RemovableDriveManager() { assert(! m_initialized); }
|
||||
~RemovableDriveManager() { /*assert(! m_initialized);*/ }
|
||||
|
||||
// Start the background thread and register this window as a target for update events.
|
||||
// Register for OSX notifications.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue