GUI revamp
This commit is contained in:
parent
f1023ebacb
commit
a26852bf14
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<height>530</height>
|
||||
<width>493</width>
|
||||
<height>466</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -32,29 +32,62 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QToolBox" name="toolBox">
|
||||
<widget class="QFrame" name="globalMessage">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="globalMessageTitle">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="globalMessageText">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::South</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-25</y>
|
||||
<width>471</width>
|
||||
<height>399</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QWidget" name="programmingTab">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Programming</string>
|
||||
<attribute name="title">
|
||||
<string>Flashing</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0,0,0,0,0,0,1">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
@ -62,6 +95,66 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QProgressBar" name="progressBar"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="versionBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="uploadButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Upload</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="expertModeBox">
|
||||
<property name="text">
|
||||
<string>Expert mode</string>
|
||||
</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>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Board:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QWidget" name="expertForm" native="true">
|
||||
<property name="sizePolicy">
|
||||
@ -101,98 +194,143 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QProgressBar" name="progressBar"/>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="discoveryTab">
|
||||
<attribute name="title">
|
||||
<string>Discovery</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QListWidget" name="discoveryList"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="versionBox">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Double-click to open configuration page.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<property name="text">
|
||||
<string>Sensors detected in local network:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="discoveryRefreshButton">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="serialTab">
|
||||
<attribute name="title">
|
||||
<string>Serial Monitor</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="2" column="0">
|
||||
<widget class="QTextEdit" name="serialTextEdit"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>In case of sensor issues, Serial Monitor can be used to review logs sent by the sensor over USB cable.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Board:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="uploadButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Upload</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="expertModeBox">
|
||||
<property name="text">
|
||||
<string>Expert mode</string>
|
||||
</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">
|
||||
<widget class="QPushButton" name="serialConnectButton">
|
||||
<property name="text">
|
||||
<string>Scan</string>
|
||||
<string>Connect</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_5">
|
||||
<attribute name="label">
|
||||
<widget class="QWidget" name="aboutTab">
|
||||
<attribute name="title">
|
||||
<string>About</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3"/>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="spacing">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>../assets/logo.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Luftdaten.info Flashing Tool</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Developed by <a href="https://inf.re/"><span style=" text-decoration: underline; color:#0000ff;">Piotr Dobrowolski</span></a>.</p><p>This software is released under the terms of MIT license. No warranty is provided.</p><p>For newest release see: <a href="https://d.inf.re/luftdaten/"><span style=" text-decoration: underline; color:#0000ff;">https://d.inf.re/luftdaten/</span></a></p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
@ -203,8 +341,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<height>29</height>
|
||||
<width>493</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -4,94 +4,149 @@
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="199"/>
|
||||
<location filename="../luftdaten-tool.py" line="132"/>
|
||||
<source>No boards found</source>
|
||||
<translation>Nie znaleziono płytki</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="204"/>
|
||||
<location filename="../luftdaten-tool.py" line="141"/>
|
||||
<source>Others...</source>
|
||||
<translation>Inne...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="233"/>
|
||||
<location filename="../luftdaten-tool.py" line="170"/>
|
||||
<source>No device selected.</source>
|
||||
<translation>Nie wybrano urządzenia.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="237"/>
|
||||
<location filename="../luftdaten-tool.py" line="174"/>
|
||||
<source>No version selected.</source>
|
||||
<translation>Nie wybrano wersji.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="131"/>
|
||||
<location filename="../gui/mainwindow.py" line="226"/>
|
||||
<source>Board:</source>
|
||||
<translation>Płytka:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="132"/>
|
||||
<location filename="../gui/mainwindow.py" line="223"/>
|
||||
<source>Firmware version:</source>
|
||||
<translation>Wersja oprogramowania:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="133"/>
|
||||
<location filename="../gui/mainwindow.py" line="224"/>
|
||||
<source>Upload</source>
|
||||
<translation>Wgraj</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="134"/>
|
||||
<location filename="../gui/mainwindow.py" line="225"/>
|
||||
<source>Expert mode</source>
|
||||
<translation>Tryb eksperta</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="135"/>
|
||||
<location filename="../gui/mainwindow.py" line="227"/>
|
||||
<source>Baudrate:</source>
|
||||
<translation>Prędkość portu:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="252"/>
|
||||
<location filename="../luftdaten-tool.py" line="189"/>
|
||||
<source>Invalid version / file does not exist</source>
|
||||
<translation>Błędna wersja / plik nie istnieje</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="257"/>
|
||||
<location filename="../luftdaten-tool.py" line="194"/>
|
||||
<source>Work in progess...</source>
|
||||
<translation>Praca w toku...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="284"/>
|
||||
<location filename="../luftdaten-tool.py" line="221"/>
|
||||
<source>Downloading...</source>
|
||||
<translation>Pobieranie...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="296"/>
|
||||
<location filename="../luftdaten-tool.py" line="231"/>
|
||||
<source>Connecting...</source>
|
||||
<translation>Łączenie...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="301"/>
|
||||
<location filename="../luftdaten-tool.py" line="236"/>
|
||||
<source>Connected. Chip type: {chip_type}</source>
|
||||
<translation>Połączono. Typ układu: {chip_type}</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="319"/>
|
||||
<location filename="../luftdaten-tool.py" line="254"/>
|
||||
<source>Writing at 0x{address:08x}...</source>
|
||||
<translation>Zapisywanie pod adresem 0x{address:08x}...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="330"/>
|
||||
<location filename="../luftdaten-tool.py" line="265"/>
|
||||
<source>Finished in {time:.2f} seconds. Sensor ID: {sensor_id}</source>
|
||||
<translation>Zakończono w {time:.2f} sekundy. ID sensora: {sensor_id}</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="130"/>
|
||||
<location filename="../gui/mainwindow.py" line="236"/>
|
||||
<source>Luftdaten.info Flashing Tool</source>
|
||||
<translation>Luftdaten.info Flashing Tool</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="138"/>
|
||||
<location filename="../luftdaten-tool.py" line="52"/>
|
||||
<source>Loading firmware list...</source>
|
||||
<translation>Ładowanie wersji oprogramowania...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../luftdaten-tool.py" line="132"/>
|
||||
<source>Have you installed <a href="{drivers_url}">the drivers</a>?</source>
|
||||
<translation>Czy zainstalowałeś <a href="{drivers_url}">sterowniki</a>?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="228"/>
|
||||
<source>Flashing</source>
|
||||
<translation>Programowanie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="229"/>
|
||||
<source>Double-click to open configuration page.</source>
|
||||
<translation>Naciśnij dwukrotnie aby otworzyć stronę konfiguracji.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="230"/>
|
||||
<source>Sensors detected in local network:</source>
|
||||
<translation>Sensory wykryte w sieci lokalnej:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="231"/>
|
||||
<source>Refresh</source>
|
||||
<translation>Odśwież</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="232"/>
|
||||
<source>Discovery</source>
|
||||
<translation>Wykrywanie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="233"/>
|
||||
<source>In case of sensor issues, Serial Monitor can be used to review logs sent by the sensor over USB cable.</source>
|
||||
<translation>W przypadku problemów z sensorem, Serial Monitor pozwala na przejrzenie stanu urządzenia przez kabel USB.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="234"/>
|
||||
<source>Connect</source>
|
||||
<translation>Połącz</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="235"/>
|
||||
<source>Serial Monitor</source>
|
||||
<translation>Serial Monitor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="237"/>
|
||||
<source><html><head/><body><p>Developed by <a href="https://inf.re/"><span style=" text-decoration: underline; color:#0000ff;">Piotr Dobrowolski</span></a>.</p><p>This software is released under the terms of MIT license. No warranty is provided.</p><p>For newest release see: <a href="https://d.inf.re/luftdaten/"><span style=" text-decoration: underline; color:#0000ff;">https://d.inf.re/luftdaten/</span></a></p></body></html></source>
|
||||
<translation><html><head/><body><p>Wykonane przez <a href="https://inf.re/"><span style=" text-decoration: underline; color:#0000ff;">Piotr Dobrowolski</span></a>.</p><p>Ten program wypuszczony jest na warunkach licencji MIT. Brak gwarancji.</p><p>Najnowszą wersję znajdziesz na: <a href="https://d.inf.re/luftdaten/"><span style=" text-decoration: underline; color:#0000ff;">https://d.inf.re/luftdaten/</span></a></p></body></html></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/mainwindow.py" line="238"/>
|
||||
<source>About</source>
|
||||
<translation>O programie</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -19,7 +19,7 @@ from luftdatentool.workers import PortDetectThread, FirmwareListThread, \
|
||||
from gui import mainwindow
|
||||
|
||||
from luftdatentool.consts import UPDATE_REPOSITORY, ALLOWED_PROTO, \
|
||||
PREFERED_PORTS, ROLE_DEVICE
|
||||
PREFERED_PORTS, ROLE_DEVICE, DRIVERS_URL
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
RESOURCES_PATH = sys._MEIPASS
|
||||
@ -31,6 +31,8 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
uploadProgress = QtCore.Signal([str, int])
|
||||
errorSignal = QtCore.Signal([str])
|
||||
uploadThread = None
|
||||
zeroconf_discovery = None
|
||||
boards_detected = False
|
||||
|
||||
def __init__(self, parent=None, app=None):
|
||||
super(MainWindow, self).__init__(parent)
|
||||
@ -43,8 +45,8 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
os.chdir(oldcwd)
|
||||
|
||||
self.app = app
|
||||
self.translator = QtCore.QTranslator()
|
||||
|
||||
self.translator = QtCore.QTranslator()
|
||||
self.i18n_init(QtCore.QLocale.system())
|
||||
|
||||
self.statusbar.showMessage(self.tr("Loading firmware list..."))
|
||||
@ -59,18 +61,25 @@ 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.discovery_start()
|
||||
|
||||
self.globalMessage.hide()
|
||||
|
||||
# Hide WIP GUI parts...
|
||||
self.on_expertModeBox_clicked()
|
||||
self.expertModeBox.hide()
|
||||
self.tabWidget.removeTab(self.tabWidget.indexOf(self.serialTab))
|
||||
|
||||
self.uploadProgress.connect(self.on_work_update)
|
||||
self.errorSignal.connect(self.on_work_error)
|
||||
|
||||
self.cachedir = tempfile.TemporaryDirectory()
|
||||
|
||||
def show_global_message(self, title, message):
|
||||
self.globalMessage.show()
|
||||
self.globalMessageTitle.setText(title)
|
||||
self.globalMessageText.setText(message)
|
||||
|
||||
def on_work_update(self, status, progress):
|
||||
self.statusbar.showMessage(status)
|
||||
self.progressBar.setValue(progress)
|
||||
@ -78,17 +87,6 @@ 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"""
|
||||
|
||||
@ -131,6 +129,17 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
sep.setEnabled(False)
|
||||
self.boardBox.model().appendRow(sep)
|
||||
|
||||
# No prefered boards has been found so far and there is a
|
||||
# suggested driver download URL available
|
||||
if not self.boards_detected and DRIVERS_URL:
|
||||
self.show_global_message(
|
||||
self.tr('No boards found'),
|
||||
self.tr('Have you installed <a href="{drivers_url}">'
|
||||
'the drivers</a>?').format(drivers_url=DRIVERS_URL))
|
||||
else:
|
||||
self.globalMessage.hide()
|
||||
self.boards_detected = True
|
||||
|
||||
if others:
|
||||
sep = QtGui.QStandardItem(self.tr('Others...'))
|
||||
sep.setEnabled(False)
|
||||
@ -263,9 +272,36 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
@QtCore.Slot()
|
||||
def on_expertModeBox_clicked(self):
|
||||
self.expertForm.setVisible(self.expertModeBox.checkState())
|
||||
self.centralwidget.setFixedHeight(
|
||||
self.centralwidget.sizeHint().height())
|
||||
self.setFixedHeight(self.sizeHint().height())
|
||||
#self.centralwidget.setFixedHeight(
|
||||
# self.centralwidget.sizeHint().height())
|
||||
#self.setFixedHeight(self.sizeHint().height())
|
||||
|
||||
# Zeroconf page
|
||||
def discovery_start(self):
|
||||
if self.zeroconf_discovery:
|
||||
self.zeroconf_discovery.stop()
|
||||
|
||||
self.zeroconf_discovery = ZeroconfDiscoveryThread()
|
||||
self.zeroconf_discovery.deviceDiscovered.connect(
|
||||
self.on_zeroconf_discovered)
|
||||
self.zeroconf_discovery.start()
|
||||
|
||||
|
||||
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.discoveryList.addItem(item)
|
||||
|
||||
@QtCore.Slot(QtWidgets.QListWidgetItem)
|
||||
def on_discoveryList_itemDoubleClicked(self, index):
|
||||
QtGui.QDesktopServices.openUrl(QtCore.QUrl(index.data(ROLE_DEVICE)))
|
||||
|
||||
@QtCore.Slot()
|
||||
def on_discoveryRefreshButton_clicked(self):
|
||||
self.discoveryList.clear()
|
||||
self.discovery_start()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,5 +1,8 @@
|
||||
import sys
|
||||
|
||||
from .qtvariant import QtCore
|
||||
|
||||
|
||||
# Firmware update repository
|
||||
UPDATE_REPOSITORY = 'https://www.madavi.de/sensor/update/data/'
|
||||
|
||||
@ -16,3 +19,10 @@ PREFERED_PORTS = [
|
||||
]
|
||||
|
||||
ROLE_DEVICE = QtCore.Qt.UserRole + 1
|
||||
|
||||
if sys.platform.startswith('darwin'):
|
||||
DRIVERS_URL = 'http://www.wch.cn/downloads/CH341SER_MAC_ZIP.html'
|
||||
elif sys.platform.startswith(('cygwin', 'win32')):
|
||||
DRIVERS_URL = 'http://www.wch.cn/downloads/CH341SER_ZIP.html'
|
||||
else:
|
||||
DRIVERS_URL = None
|
||||
|
@ -39,10 +39,13 @@ class FirmwareListThread(QuickThread):
|
||||
|
||||
class ZeroconfDiscoveryThread(QuickThread):
|
||||
deviceDiscovered = QtCore.Signal(str, str, object)
|
||||
browser = None
|
||||
|
||||
def target(self):
|
||||
zc = zeroconf.Zeroconf()
|
||||
browser = zeroconf.ServiceBrowser(zc, "_http._tcp.local.",
|
||||
"""This thread scans for Bonjour/mDNS devices and emits
|
||||
deviceDiscovered signal with its name, address and info object"""
|
||||
self.zc = zeroconf.Zeroconf()
|
||||
self.browser = zeroconf.ServiceBrowser(self.zc, "_http._tcp.local.",
|
||||
handlers=[self.on_state_change])
|
||||
while True:
|
||||
time.sleep(0.5)
|
||||
@ -51,3 +54,7 @@ class ZeroconfDiscoveryThread(QuickThread):
|
||||
info = zeroconf.get_service_info(service_type, name)
|
||||
if info:
|
||||
self.deviceDiscovered.emit(name, socket.inet_ntoa(info.address), info)
|
||||
|
||||
def stop(self):
|
||||
if self.browser:
|
||||
self.browser.cancel()
|
||||
|
Loading…
x
Reference in New Issue
Block a user