ENH: parse ack of upgrade confirm

Change-Id: I33691749221aac4c83f71d6d76708d7b2d8d6d4d
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2023-01-11 09:26:01 +08:00 committed by Lane.Wei
parent 8c923804fc
commit 6fee9bcca1
4 changed files with 58 additions and 23 deletions

View file

@ -738,6 +738,17 @@ void MachineInfoPanel::on_sys_color_changed()
}
}
void MachineInfoPanel::confirm_upgrade(MachineObject* obj)
{
if (obj) {
obj->command_upgrade_confirm();
obj->upgrade_display_state = MachineObject::UpgradingDisplayState::UpgradingInProgress;
obj->upgrade_display_hold_count = HOLD_COUNT_MAX;
// enter in progress status first
this->show_status(MachineObject::UpgradingDisplayState::UpgradingInProgress);
}
}
void MachineInfoPanel::upgrade_firmware_internal() {
if (!m_obj)
return;
@ -746,7 +757,7 @@ void MachineInfoPanel::upgrade_firmware_internal() {
} else if (panel_type == ptAmsPanel) {
m_obj->command_upgrade_firmware(m_ams_info);
} else if (panel_type == ptPushPanel) {
m_obj->command_upgrade_confirm();
confirm_upgrade();
}
}
@ -755,9 +766,7 @@ void MachineInfoPanel::on_upgrade_firmware(wxCommandEvent &event)
if (confirm_dlg == nullptr) {
confirm_dlg = new SecondaryCheckDialog(this->GetParent(), wxID_ANY, _L("Update firmware"));
confirm_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent& e) {
if (m_obj) {
m_obj->command_upgrade_confirm();
}
this->confirm_upgrade(m_obj);
});
}
confirm_dlg->update_text(_L("Are you sure you want to update? This will take about 10 minutes. Do not turn off the power while the printer is updating."));
@ -899,6 +908,8 @@ void UpgradePanel::update(MachineObject *obj)
force_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent& e) {
if (m_obj) {
m_obj->command_upgrade_confirm();
m_obj->upgrade_display_state == MachineObject::UpgradingDisplayState::UpgradingInProgress;
m_obj->upgrade_display_hold_count = HOLD_COUNT_MAX;
}
});
}