diff --git a/radio/src/gui/colorlcd/radio_sdmanager.cpp b/radio/src/gui/colorlcd/radio_sdmanager.cpp index f30eaa553..8d9a0f99e 100644 --- a/radio/src/gui/colorlcd/radio_sdmanager.cpp +++ b/radio/src/gui/colorlcd/radio_sdmanager.cpp @@ -124,41 +124,14 @@ class FlashDialog: public FullScreenDialog }; template -class MultiFlashDialog: public FullScreenDialog +class MultiFlashDialog: public FlashDialog { public: explicit MultiFlashDialog(ModuleIndex module, MultiModuleType type): - FullScreenDialog(WARNING_TYPE_INFO, "Flash device"), - device(module), - type(type), - progress(this, {LCD_W / 2 - 50, LCD_H / 2, 100, 15}) + FlashDialog(module) { + device.setType(type); } - - void deleteLater(bool detach = true, bool trash = true) override - { - if (_deleted) - return; - - progress.deleteLater(true, false); - - FullScreenDialog::deleteLater(detach, trash); - } - - void flash(const char * filename) - { - device.flashFirmware(filename, type, [=](const char * title, const char * message, int count, int total) -> void { - setMessage(message); - progress.setValue(total > 0 ? count * 100 / total : 0); - MainWindow::instance()->run(false); - }); - deleteLater(); - } - - protected: - T device; - MultiModuleType type; - Progress progress; }; void RadioSdManagerPage::build(FormWindow * window) diff --git a/radio/src/io/multi_firmware_update.cpp b/radio/src/io/multi_firmware_update.cpp index 940b7dc74..1c0a526eb 100644 --- a/radio/src/io/multi_firmware_update.cpp +++ b/radio/src/io/multi_firmware_update.cpp @@ -546,7 +546,7 @@ const char * MultiFirmwareInformation::readMultiFirmwareInformation(FIL * file) return readV1Signature(buffer); } -bool MultiDeviceFirmwareUpdate::flashFirmware(const char * filename, MultiModuleType type, ProgressHandler progressHandler) +bool MultiDeviceFirmwareUpdate::flashFirmware(const char * filename, ProgressHandler progressHandler) { FIL file; diff --git a/radio/src/io/multi_firmware_update.h b/radio/src/io/multi_firmware_update.h index 837dcd7bf..4d73162e5 100644 --- a/radio/src/io/multi_firmware_update.h +++ b/radio/src/io/multi_firmware_update.h @@ -112,8 +112,14 @@ class MultiDeviceFirmwareUpdate { { } - bool flashFirmware(const char * filename, MultiModuleType type, ProgressHandler progressHandler); + void setType(MultiModuleType value) + { + type = value; + } + + bool flashFirmware(const char * filename, ProgressHandler progressHandler); protected: ModuleIndex module; + MultiModuleType type; };