ENH:add preset check for sending files

Change-Id: Ia3313d281b5ce91e277b380498014ffdac5debd3
This commit is contained in:
tao wang 2023-12-01 09:59:12 +08:00 committed by Lane.Wei
parent fd00d28027
commit 02ec94b6f8
2 changed files with 32 additions and 1 deletions

View File

@ -1058,7 +1058,11 @@ void SendToPrinterDialog::update_show_status()
reset_timeout(); reset_timeout();
// reading done // reading done
if (obj_->is_in_upgrading()) { if (is_blocking_printing(obj_)) {
show_status(PrintDialogStatus::PrintStatusUnsupportedPrinter);
return;
}
else if (obj_->is_in_upgrading()) {
show_status(PrintDialogStatus::PrintStatusInUpgrading); show_status(PrintDialogStatus::PrintStatusInUpgrading);
return; return;
} }
@ -1087,6 +1091,26 @@ void SendToPrinterDialog::update_show_status()
} }
} }
bool SendToPrinterDialog::is_blocking_printing(MachineObject* obj_)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return true;
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
auto target_model = obj_->printer_type;
if (source_model != target_model) {
std::vector<std::string> compatible_machine = dev->get_compatible_machine(target_model);
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
if (it == compatible_machine.end()) {
return true;
}
}
return false;
}
void SendToPrinterDialog::Enable_Refresh_Button(bool en) void SendToPrinterDialog::Enable_Refresh_Button(bool en)
{ {
if (!en) { if (!en) {
@ -1167,6 +1191,12 @@ void SendToPrinterDialog::show_status(PrintDialogStatus status, std::vector<wxSt
Enable_Send_Button(false); Enable_Send_Button(false);
Enable_Refresh_Button(true); Enable_Refresh_Button(true);
} }
else if (status == PrintDialogStatus::PrintStatusUnsupportedPrinter) {
wxString msg_text = _L("The selected printer is incompatible with the chosen printer presets.");
update_print_status_msg(msg_text, true, true);
Enable_Send_Button(false);
Enable_Refresh_Button(true);
}
else if (status == PrintDialogStatus::PrintStatusRefreshingMachineList) { else if (status == PrintDialogStatus::PrintStatusRefreshingMachineList) {
update_print_status_msg(wxEmptyString, false, true); update_print_status_msg(wxEmptyString, false, true);
Enable_Send_Button(false); Enable_Send_Button(false);

View File

@ -130,6 +130,7 @@ public:
void reset_timeout(); void reset_timeout();
void update_user_printer(); void update_user_printer();
void update_show_status(); void update_show_status();
bool is_blocking_printing(MachineObject* obj_);
void prepare(int print_plate_idx); void prepare(int print_plate_idx);
void check_focus(wxWindow* window); void check_focus(wxWindow* window);
void check_fcous_state(wxWindow* window); void check_fcous_state(wxWindow* window);