diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 38d33e7..9598f3a 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -32,121 +32,168 @@ - - - - 0 - 0 - + + + 0 - - - - - Board: - - - - - - - - 0 - 0 - - - - - - - - Firmware version: - - - - - - - - 0 - 0 - - - - true - - - - - - - - - - 0 - 0 - - - - Upload - - - - - - - Expert mode - - - true - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - Baudrate: - - - - - - - - 0 - 0 - - - - - - - - - 0 - 1 - - - - - + + + + 0 + -25 + 471 + 399 + + + + + 0 + 0 + + + + Programming + + + + + + Firmware version: + + + + + + + + 0 + 0 + + + + + + + Baudrate: + + + + + + + + 0 + 0 + + + + + + + + + 0 + 1 + + + + + + + + + + + + + + + 0 + 0 + + + + true + + + + + + + Board: + + + + + + + + + + 0 + 0 + + + + Upload + + + + + + + Expert mode + + + true + + + + + + + + + + 0 + 0 + + + + + + + + + + 0 + 0 + 491 + 374 + + + + Discovery + + + + + + + + + Scan + + + + + + + + About + + + @@ -157,7 +204,7 @@ 0 0 503 - 22 + 29 diff --git a/luftdaten-tool.py b/luftdaten-tool.py index debc4c9..311440f 100644 --- a/luftdaten-tool.py +++ b/luftdaten-tool.py @@ -59,6 +59,11 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): self.port_detect.error.connect(self.on_work_error) self.port_detect.start() + self.zeroconf_discovery = ZeroconfDiscoveryThread() + self.zeroconf_discovery.deviceDiscovered.connect( + self.on_zeroconf_discovered) + self.zeroconf_discovery.start() + self.on_expertModeBox_clicked() self.uploadProgress.connect(self.on_work_update) @@ -73,6 +78,17 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): def on_work_error(self, message): self.statusbar.showMessage(message) + def on_zeroconf_discovered(self, name, address, info): + """Called on every zeroconf discovered device""" + if name.startswith('Feinstaubsensor'): + item = QtWidgets.QListWidgetItem('{}: {}'.format(address, name.split('.')[0])) + item.setData(ROLE_DEVICE, 'http://{}:{}'.format(address, info.port)) + self.listWidget.addItem(item) + + @QtCore.Slot(QtWidgets.QListWidgetItem) + def on_listWidget_itemDoubleClicked(self, index): + QtGui.QDesktopServices.openUrl(QtCore.QUrl(index.data(ROLE_DEVICE))) + def i18n_init(self, locale): """Initializes i18n to specified QLocale"""