diff -r 1445ca4be40d -r 6cbe3948044c src/eric7/MicroPython/UF2FlashDialog.py --- a/src/eric7/MicroPython/UF2FlashDialog.py Mon Feb 27 16:22:19 2023 +0100 +++ b/src/eric7/MicroPython/UF2FlashDialog.py Mon Feb 27 16:24:53 2023 +0100 @@ -13,7 +13,7 @@ from PyQt6.QtCore import QCoreApplication, QEventLoop, Qt, QThread, pyqtSlot from PyQt6.QtSerialPort import QSerialPortInfo -from PyQt6.QtWidgets import QDialog +from PyQt6.QtWidgets import QDialog, QInputDialog from eric7.EricGui import EricPixmapCache from eric7.EricWidgets.EricApplication import ericApp @@ -720,6 +720,9 @@ self.bootPicker.setMode(EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE) self.bootPicker.setEnabled(False) + self.searchBootButton.setIcon(EricPixmapCache.getIcon("question")) + self.searchBootButton.setEnabled(False) + self.__mandatoryStyleSheet = ( "QLineEdit {border: 2px solid; border-color: #dd8888}" if ericApp().usesDarkPalette() @@ -1002,7 +1005,7 @@ QCoreApplication.processEvents( QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents ) - shutil.copy2(firmwarePath, volumePath) + shutil.copy(firmwarePath, volumePath) QThread.sleep(1) self.on_refreshButton_clicked() @@ -1028,6 +1031,7 @@ vidpid = self.devicesComboBox.itemData(index, self.DeviceVidPidRole) boardType = self.devicesComboBox.itemData(index, self.DeviceTypeRole) + self.searchBootButton.setEnabled(boardType == self.__manualType) self.bootPicker.setEnabled(boardType == self.__manualType) if boardType == self.__manualType: self.__showManualInstructions() @@ -1071,3 +1075,34 @@ @type str """ self.__updateFlashButton() + + @pyqtSlot() + def on_searchBootButton_clicked(self): + """ + Private slot to look for all known boot paths and present a list to select from. + """ + foundBootVolumes = set() + for boardType in SupportedUF2Boards: + for volumes in SupportedUF2Boards[boardType]["volumes"].values(): + for volume in volumes: + foundBootVolumes.update( + FileSystemUtilities.findVolume(volume, findAll=True) + ) + + if len(foundBootVolumes) == 0: + selectedVolume = "" + elif len(foundBootVolumes) == 1: + selectedVolume = list(foundBootVolumes)[0] + else: + result, ok = QInputDialog.getItem( + None, + QCoreApplication.translate("UF2FlashDialog", "Flash UF2 Device"), + QCoreApplication.translate( + "UF2FlashDialog", "Select the Boot Volume of the device:" + ), + list(foundBootVolumes), + 0, True, + ) + selectedVolume = result if ok else "" + + self.bootPicker.setText(selectedVolume)