221 self.setupUi(self) |
221 self.setupUi(self) |
222 |
222 |
223 self.layout().setContentsMargins(0, 3, 0, 0) |
223 self.layout().setContentsMargins(0, 3, 0, 0) |
224 |
224 |
225 self.__ui = parent |
225 self.__ui = parent |
|
226 |
226 self.__wifiController = WifiController(self, self) |
227 self.__wifiController = WifiController(self, self) |
|
228 self.__wifiMenu = None |
227 |
229 |
228 self.__superMenu = QMenu(self) |
230 self.__superMenu = QMenu(self) |
229 self.__superMenu.aboutToShow.connect(self.__aboutToShowSuperMenu) |
231 self.__superMenu.aboutToShow.connect(self.__aboutToShowSuperMenu) |
230 |
232 |
231 self.menuButton.setObjectName("micropython_supermenu_button") |
233 self.menuButton.setObjectName("micropython_supermenu_button") |
616 else: |
618 else: |
617 self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect")) |
619 self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect")) |
618 self.connectButton.setToolTip( |
620 self.connectButton.setToolTip( |
619 self.tr("Press to connect the selected device") |
621 self.tr("Press to connect the selected device") |
620 ) |
622 ) |
|
623 |
|
624 if not connected and self.__wifiMenu and self.__wifiMenu.isTearOffMenuVisible(): |
|
625 self.__wifiMenu.hideTearOffMenu() |
621 |
626 |
622 def isConnected(self): |
627 def isConnected(self): |
623 """ |
628 """ |
624 Public method to get the MicroPython device connection state. |
629 Public method to get the MicroPython device connection state. |
625 |
630 |
1447 else: |
1452 else: |
1448 downloadMenu = None |
1453 downloadMenu = None |
1449 |
1454 |
1450 # prepare the WiFi menu |
1455 # prepare the WiFi menu |
1451 if self.__device and self.__connected and self.__device.getDeviceData("wifi"): |
1456 if self.__device and self.__connected and self.__device.getDeviceData("wifi"): |
1452 wifiMenu = self.__wifiController.createMenu(self.__superMenu) |
1457 if self.__wifiMenu is not None: |
1453 else: |
1458 self.__wifiMenu.deleteLater() |
1454 wifiMenu = None |
1459 self.__wifiMenu = self.__wifiController.createMenu(self.__superMenu) |
|
1460 else: |
|
1461 self.__wifiMenu = None |
1455 |
1462 |
1456 # populate the super menu |
1463 # populate the super menu |
1457 hasTime = self.__device.hasTimeCommands() if self.__device else False |
1464 hasTime = self.__device.hasTimeCommands() if self.__device else False |
1458 |
1465 |
1459 self.__superMenu.addAction( |
1466 self.__superMenu.addAction( |
1494 ).setEnabled(available and bool(aw)) |
1501 ).setEnabled(available and bool(aw)) |
1495 self.__superMenu.addSeparator() |
1502 self.__superMenu.addSeparator() |
1496 if self.__device: |
1503 if self.__device: |
1497 self.__device.addDeviceMenuEntries(self.__superMenu) |
1504 self.__device.addDeviceMenuEntries(self.__superMenu) |
1498 self.__superMenu.addSeparator() |
1505 self.__superMenu.addSeparator() |
1499 if wifiMenu is not None: |
1506 if self.__wifiMenu is not None: |
1500 self.__superMenu.addMenu(wifiMenu) |
1507 self.__superMenu.addMenu(self.__wifiMenu) |
1501 self.__superMenu.addSeparator() |
1508 self.__superMenu.addSeparator() |
1502 if downloadMenu is None: |
1509 if downloadMenu is None: |
1503 # generic download action |
1510 # generic download action |
1504 self.__superMenu.addAction( |
1511 self.__superMenu.addAction( |
1505 self.tr("Download Firmware"), self.__downloadFirmware |
1512 self.tr("Download Firmware"), self.__downloadFirmware |
1604 boardInfo = self.__device.getBoardInformation() |
1611 boardInfo = self.__device.getBoardInformation() |
1605 |
1612 |
1606 dlg = BoardDataDialog(boardInfo) |
1613 dlg = BoardDataDialog(boardInfo) |
1607 dlg.exec() |
1614 dlg.exec() |
1608 except Exception as exc: |
1615 except Exception as exc: |
1609 self.__showError("getBoardInformation()", str(exc)) |
1616 self.showError("getBoardInformation()", str(exc)) |
1610 |
1617 |
1611 @pyqtSlot() |
1618 @pyqtSlot() |
1612 def __synchronizeTime(self, quiet=False): |
1619 def __synchronizeTime(self, quiet=False): |
1613 """ |
1620 """ |
1614 Private slot to set the time of the connected device to the local |
1621 Private slot to set the time of the connected device to the local |
1634 " synchronized with the local time.</p>" |
1641 " synchronized with the local time.</p>" |
1635 ) |
1642 ) |
1636 + self.__getDeviceTime(), |
1643 + self.__getDeviceTime(), |
1637 ) |
1644 ) |
1638 except Exception as exc: |
1645 except Exception as exc: |
1639 self.__showError("syncTime()", str(exc)) |
1646 self.showError("syncTime()", str(exc)) |
1640 |
1647 |
1641 def __getDeviceTime(self): |
1648 def __getDeviceTime(self): |
1642 """ |
1649 """ |
1643 Private method to get a string containing the date and time of the |
1650 Private method to get a string containing the date and time of the |
1644 connected device. |
1651 connected device. |
1738 "<td align='center'>{2}</td></tr>" |
1745 "<td align='center'>{2}</td></tr>" |
1739 "</table>" |
1746 "</table>" |
1740 ).format(localdate, localtime, deviceDateTimeString.strip()), |
1747 ).format(localdate, localtime, deviceDateTimeString.strip()), |
1741 ) |
1748 ) |
1742 except Exception as exc: |
1749 except Exception as exc: |
1743 self.__showError("getTime()", str(exc)) |
1750 self.showError("getTime()", str(exc)) |
1744 |
1751 |
1745 def __showError(self, method, error): |
1752 def showError(self, method, error): |
1746 """ |
1753 """ |
1747 Private method to show some error message. |
1754 Public method to show some error message. |
1748 |
1755 |
1749 @param method name of the method the error occured in |
1756 @param method name of the method the error occured in |
1750 @type str |
1757 @type str |
1751 @param error error message |
1758 @param error error message |
1752 @type str |
1759 @type str |