mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-30 06:12:12 +00:00
ENH: [STUDIO-4029] sync printer config with cloud
Change-Id: Icffee9d5987131e1d78d51ccfcafeefff18f26cb Jira: STUDIO-4029 (cherry picked from commit 5b58e5f2658753efbf11037f0b6cbb023070c0ea)
This commit is contained in:
@@ -470,6 +470,12 @@ PrinterArch MachineObject::get_printer_arch() const
|
||||
return DeviceManager::get_printer_arch(printer_type);
|
||||
}
|
||||
|
||||
void MachineObject::reload_printer_settings()
|
||||
{
|
||||
print_json.load_compatible_settings("", "");
|
||||
parse_json("{}");
|
||||
}
|
||||
|
||||
MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string id, std::string ip)
|
||||
:dev_name(name),
|
||||
dev_id(id),
|
||||
@@ -2592,10 +2598,8 @@ int MachineObject::parse_json(std::string payload)
|
||||
if (j_pre["print"]["msg"].get<int>() == 0) { //all message
|
||||
BOOST_LOG_TRIVIAL(trace) << "static: get push_all msg, dev_id=" << dev_id;
|
||||
m_push_count++;
|
||||
if (j_pre["print"].contains("printer_type")) {
|
||||
printer_type = parse_printer_type(j_pre["print"]["printer_type"].get<std::string>());
|
||||
}
|
||||
print_json.load_compatible_settings(printer_type, "");
|
||||
if (!printer_type.empty())
|
||||
print_json.load_compatible_settings(printer_type, "");
|
||||
print_json.diff2all_base_reset(j_pre);
|
||||
} else if (j_pre["print"]["msg"].get<int>() == 1) { //diff message
|
||||
if (print_json.diff2all(j_pre, j) == 0) {
|
||||
@@ -4764,6 +4768,12 @@ MachineObject* DeviceManager::get_local_selected_machine()
|
||||
return get_local_machine(local_selected_machine);
|
||||
}
|
||||
|
||||
void DeviceManager::reload_printer_settings()
|
||||
{
|
||||
for (auto obj : this->userMachineList)
|
||||
obj.second->reload_printer_settings();
|
||||
}
|
||||
|
||||
MachineObject* DeviceManager::get_default_machine() {
|
||||
|
||||
std::string dev_id;
|
||||
|
||||
@@ -413,6 +413,7 @@ public:
|
||||
std::string printer_type; /* model_id */
|
||||
PrinterSeries get_printer_series() const;
|
||||
PrinterArch get_printer_arch() const;
|
||||
void reload_printer_settings();
|
||||
|
||||
std::string printer_thumbnail_img;
|
||||
std::string monitor_upgrade_printer_img;
|
||||
@@ -911,6 +912,7 @@ public:
|
||||
MachineObject* get_my_machine(std::string dev_id);
|
||||
void erase_user_machine(std::string dev_id);
|
||||
void clean_user_info();
|
||||
void reload_printer_settings();
|
||||
|
||||
bool set_selected_machine(std::string dev_id, bool need_disconnect = false);
|
||||
MachineObject* get_selected_machine();
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace GUI {
|
||||
wxDEFINE_EVENT(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, EjectDriveNotificationClickedEvent);
|
||||
wxDEFINE_EVENT(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, ExportGcodeNotificationClickedEvent);
|
||||
wxDEFINE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClickedEvent);
|
||||
wxDEFINE_EVENT(EVT_PRINTER_CONFIG_UPDATE_AVAILABLE_CLICKED, PrinterConfigUpdateAvailableClickedEvent);
|
||||
|
||||
namespace {
|
||||
/* // not used?
|
||||
|
||||
@@ -27,6 +27,8 @@ using ExportGcodeNotificationClickedEvent = SimpleEvent;
|
||||
wxDECLARE_EVENT(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, ExportGcodeNotificationClickedEvent);
|
||||
using PresetUpdateAvailableClickedEvent = SimpleEvent;
|
||||
wxDECLARE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClickedEvent);
|
||||
using PrinterConfigUpdateAvailableClickedEvent = SimpleEvent;
|
||||
wxDECLARE_EVENT(EVT_PRINTER_CONFIG_UPDATE_AVAILABLE_CLICKED, PrinterConfigUpdateAvailableClickedEvent);
|
||||
|
||||
using CancelFn = std::function<void()>;
|
||||
|
||||
@@ -141,6 +143,7 @@ enum class NotificationType
|
||||
BBLPluginInstallHint,
|
||||
BBLPluginUpdateAvailable,
|
||||
BBLPreviewOnlyMode,
|
||||
BBLPrinterConfigUpdateAvailable,
|
||||
};
|
||||
|
||||
class NotificationManager
|
||||
@@ -914,6 +917,15 @@ private:
|
||||
return true;
|
||||
}},
|
||||
|
||||
NotificationData{NotificationType::BBLPrinterConfigUpdateAvailable, NotificationLevel::ImportantNotificationLevel, BBL_NOTICE_MAX_INTERVAL,
|
||||
_u8L("New printer config available."),
|
||||
_u8L("Details"),
|
||||
[](wxEvtHandler* evnthndlr) {
|
||||
if (evnthndlr != nullptr)
|
||||
wxPostEvent(evnthndlr, PrinterConfigUpdateAvailableClickedEvent(EVT_PRINTER_CONFIG_UPDATE_AVAILABLE_CLICKED));
|
||||
return true;
|
||||
}},
|
||||
|
||||
NotificationData{NotificationType::UndoDesktopIntegrationFail, NotificationLevel::WarningNotificationLevel, 10,
|
||||
_u8L("Undo integration failed.") },
|
||||
NotificationData{NotificationType::ExportOngoing, NotificationLevel::RegularNotificationLevel, 0, _u8L("Exporting.")},
|
||||
|
||||
@@ -2693,6 +2693,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
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(); });
|
||||
this->q->Bind(EVT_PRINTER_CONFIG_UPDATE_AVAILABLE_CLICKED, [](PrinterConfigUpdateAvailableClickedEvent&) {
|
||||
wxGetApp().get_preset_updater()->do_printer_config_update();
|
||||
wxGetApp().getDeviceManager()->reload_printer_settings(); });
|
||||
|
||||
/* BBS do not handle removeable driver event */
|
||||
this->q->Bind(EVT_REMOVABLE_DRIVE_EJECTED, [this](RemovableDriveEjectEvent &evt) {
|
||||
|
||||
Reference in New Issue
Block a user