Zeroconf UI
This commit is contained in:
parent
1042835685
commit
f1023ebacb
@ -32,121 +32,168 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="formWidget" native="true">
|
<widget class="QToolBox" name="toolBox">
|
||||||
<property name="sizePolicy">
|
<property name="currentIndex">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
<number>0</number>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<widget class="QWidget" name="page_3">
|
||||||
<item row="0" column="0">
|
<property name="geometry">
|
||||||
<widget class="QLabel" name="label">
|
<rect>
|
||||||
<property name="text">
|
<x>0</x>
|
||||||
<string>Board:</string>
|
<y>-25</y>
|
||||||
</property>
|
<width>471</width>
|
||||||
</widget>
|
<height>399</height>
|
||||||
</item>
|
</rect>
|
||||||
<item row="0" column="1">
|
</property>
|
||||||
<widget class="QComboBox" name="boardBox">
|
<property name="sizePolicy">
|
||||||
<property name="sizePolicy">
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
<horstretch>0</horstretch>
|
||||||
<horstretch>0</horstretch>
|
<verstretch>0</verstretch>
|
||||||
<verstretch>0</verstretch>
|
</sizepolicy>
|
||||||
</sizepolicy>
|
</property>
|
||||||
</property>
|
<attribute name="label">
|
||||||
</widget>
|
<string>Programming</string>
|
||||||
</item>
|
</attribute>
|
||||||
<item row="1" column="0">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<widget class="QLabel" name="label_2">
|
<item row="3" column="0">
|
||||||
<property name="text">
|
<widget class="QLabel" name="label_2">
|
||||||
<string>Firmware version:</string>
|
<property name="text">
|
||||||
</property>
|
<string>Firmware version:</string>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
</widget>
|
||||||
<item row="1" column="1">
|
</item>
|
||||||
<widget class="QComboBox" name="versionBox">
|
<item row="7" column="0" colspan="2">
|
||||||
<property name="sizePolicy">
|
<widget class="QWidget" name="expertForm" native="true">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
<property name="sizePolicy">
|
||||||
<horstretch>0</horstretch>
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<verstretch>0</verstretch>
|
<horstretch>0</horstretch>
|
||||||
</sizepolicy>
|
<verstretch>0</verstretch>
|
||||||
</property>
|
</sizepolicy>
|
||||||
<property name="editable">
|
</property>
|
||||||
<bool>true</bool>
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
</property>
|
<item row="0" column="0">
|
||||||
</widget>
|
<widget class="QLabel" name="label_3">
|
||||||
</item>
|
<property name="text">
|
||||||
<item row="3" column="0" colspan="2">
|
<string>Baudrate:</string>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
</property>
|
||||||
<item>
|
</widget>
|
||||||
<widget class="QPushButton" name="uploadButton">
|
</item>
|
||||||
<property name="sizePolicy">
|
<item row="0" column="1">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<widget class="QComboBox" name="comboBox">
|
||||||
<horstretch>0</horstretch>
|
<property name="sizePolicy">
|
||||||
<verstretch>0</verstretch>
|
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||||
</sizepolicy>
|
<horstretch>0</horstretch>
|
||||||
</property>
|
<verstretch>0</verstretch>
|
||||||
<property name="text">
|
</sizepolicy>
|
||||||
<string>Upload</string>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
<item row="1" column="0" colspan="2">
|
||||||
<item>
|
<widget class="QTextBrowser" name="textBrowser">
|
||||||
<widget class="QCheckBox" name="expertModeBox">
|
<property name="sizePolicy">
|
||||||
<property name="text">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<string>Expert mode</string>
|
<horstretch>0</horstretch>
|
||||||
</property>
|
<verstretch>1</verstretch>
|
||||||
<property name="checkable">
|
</sizepolicy>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
</layout>
|
||||||
</layout>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="QProgressBar" name="progressBar"/>
|
<widget class="QProgressBar" name="progressBar"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<item row="3" column="1">
|
||||||
</widget>
|
<widget class="QComboBox" name="versionBox">
|
||||||
</item>
|
<property name="sizePolicy">
|
||||||
<item>
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||||
<widget class="QWidget" name="expertForm" native="true">
|
<horstretch>0</horstretch>
|
||||||
<property name="sizePolicy">
|
<verstretch>0</verstretch>
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
</sizepolicy>
|
||||||
<horstretch>0</horstretch>
|
</property>
|
||||||
<verstretch>0</verstretch>
|
<property name="editable">
|
||||||
</sizepolicy>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout_2">
|
</widget>
|
||||||
<item row="0" column="0">
|
</item>
|
||||||
<widget class="QLabel" name="label_3">
|
<item row="0" column="0">
|
||||||
<property name="text">
|
<widget class="QLabel" name="label">
|
||||||
<string>Baudrate:</string>
|
<property name="text">
|
||||||
</property>
|
<string>Board:</string>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
</widget>
|
||||||
<item row="0" column="1">
|
</item>
|
||||||
<widget class="QComboBox" name="comboBox">
|
<item row="6" column="0" colspan="2">
|
||||||
<property name="sizePolicy">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
<item>
|
||||||
<horstretch>0</horstretch>
|
<widget class="QPushButton" name="uploadButton">
|
||||||
<verstretch>0</verstretch>
|
<property name="sizePolicy">
|
||||||
</sizepolicy>
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
</property>
|
<horstretch>0</horstretch>
|
||||||
</widget>
|
<verstretch>0</verstretch>
|
||||||
</item>
|
</sizepolicy>
|
||||||
<item row="1" column="0" colspan="2">
|
</property>
|
||||||
<widget class="QTextBrowser" name="textBrowser">
|
<property name="text">
|
||||||
<property name="sizePolicy">
|
<string>Upload</string>
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
</property>
|
||||||
<horstretch>0</horstretch>
|
</widget>
|
||||||
<verstretch>1</verstretch>
|
</item>
|
||||||
</sizepolicy>
|
<item>
|
||||||
</property>
|
<widget class="QCheckBox" name="expertModeBox">
|
||||||
</widget>
|
<property name="text">
|
||||||
</item>
|
<string>Expert mode</string>
|
||||||
</layout>
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="boardBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="page_4">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>491</width>
|
||||||
|
<height>374</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<attribute name="label">
|
||||||
|
<string>Discovery</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QListWidget" name="listWidget"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Scan</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="page_5">
|
||||||
|
<attribute name="label">
|
||||||
|
<string>About</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3"/>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -157,7 +204,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>503</width>
|
<width>503</width>
|
||||||
<height>22</height>
|
<height>29</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -59,6 +59,11 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.port_detect.error.connect(self.on_work_error)
|
self.port_detect.error.connect(self.on_work_error)
|
||||||
self.port_detect.start()
|
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.on_expertModeBox_clicked()
|
||||||
|
|
||||||
self.uploadProgress.connect(self.on_work_update)
|
self.uploadProgress.connect(self.on_work_update)
|
||||||
@ -73,6 +78,17 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
def on_work_error(self, message):
|
def on_work_error(self, message):
|
||||||
self.statusbar.showMessage(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):
|
def i18n_init(self, locale):
|
||||||
"""Initializes i18n to specified QLocale"""
|
"""Initializes i18n to specified QLocale"""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user