Replaced UI file parsing with generated code

This commit is contained in:
Ezra Taimuty-Loomis 2021-02-26 22:00:08 -05:00
parent 0cd5dd5911
commit 64da45fdde
6 changed files with 2088 additions and 76 deletions

View File

@ -12,6 +12,7 @@ from threading import Thread
from time import sleep
import ui_scan_client
import audio_manager
import common
import constants
@ -34,13 +35,9 @@ class PiScanClient(QWidget, common.AppInterface):
def __init__(self, parent=None, address=None, port=None, use_audio=False, rtsp_port=None):
super(PiScanClient, self).__init__(parent)
common.setInstance(self)
ui_file = 'scan_client.ui'
ui_file = QFile(ui_file)
ui_file.open(QFile.ReadOnly)
loader = QUiLoader()
self.window = loader.load(ui_file)
ui_file.close()
self.window = ui_scan_client.Ui_Form()
self.window.setupUi(self)
self.parentWindow = parent
#layout = QGridLayout(self)
@ -53,7 +50,7 @@ class PiScanClient(QWidget, common.AppInterface):
self.scanner = scanner.Scanner(self.window)
self.dialogs = dialogs.Dialogs(self.window)
self.contextStack = self.window.findChild(QStackedWidget, 'contextStack')
self.contextStack = self.window.contextStack
#self.setWindowMode(common.WindowMode.CONNECT)
self.showConnectDialog()
#self.setWindowMode(common.WindowMode.SCANNER)
@ -280,12 +277,11 @@ class HostWindow(QtWidgets.QMainWindow):
form = PiScanClient(self, address, port, use_audio, rtsp_port)
mainWidget = form.mainWidget()
self.setPalette(mainWidget.palette())
self.setGeometry(mainWidget.geometry())
self.setWindowTitle(mainWidget.windowTitle())
self.setPalette(form.palette())
self.setGeometry(form.geometry())
self.setWindowTitle(form.windowTitle())
self.setCentralWidget(mainWidget)
self.setCentralWidget(form)
#self.actionQuit.triggered.connect(self.closeEvent)
#self.show()

View File

@ -12,18 +12,18 @@ import constants
class ConnectDialog:
def __init__(self, parentWindow, address=None, port=None, use_audio=False, rtsp_port=None):
self.widget = parentWindow.findChild(QWidget, 'connectPage')
self.errorLabel = parentWindow.findChild(QLabel, 'connect_errorLabel')
self.confirmButton = parentWindow.findChild(QPushButton, 'connect_confirmButton')
self.connectIndicator = parentWindow.findChild(QLabel, 'connect_indicator')
self.hostLineEdit = parentWindow.findChild(QLineEdit, 'connect_hostnameLineEdit')
self.portLineEdit = parentWindow.findChild(QLineEdit, 'connect_portLineEdit')
self.logo = parentWindow.findChild(QLabel, 'connect_logoImage')
self.hostLabel = parentWindow.findChild(QLabel, 'hostLabel')
self.portLabel = parentWindow.findChild(QLabel, 'hostPortLabel')
self.audioCheckBox = parentWindow.findChild(QCheckBox, 'connect_audioCheckBox')
self.rtspPortPanel = parentWindow.findChild(QWidget, 'connect_rtspPortPanel')
self.rtspPortLineEdit = parentWindow.findChild(QLineEdit, 'connect_rtspPortLineEdit')
self.widget = parentWindow.connectPage
self.errorLabel = parentWindow.connect_errorLabel
self.confirmButton = parentWindow.connect_confirmButton
self.connectIndicator = parentWindow.connect_indicator
self.hostLineEdit = parentWindow.connect_hostnameLineEdit
self.portLineEdit = parentWindow.connect_portLineEdit
self.logo = parentWindow.connect_logoImage
self.hostLabel = parentWindow.hostLabel
self.portLabel = parentWindow.hostPortLabel
self.audioCheckBox = parentWindow.connect_audioCheckBox
self.rtspPortPanel = parentWindow.connect_rtspPortPanel
self.rtspPortLineEdit = parentWindow.connect_rtspPortLineEdit
self.logo.setPixmap(QPixmap("resources/icon-256.png"))
self.logo.setVisible(False)

View File

@ -10,11 +10,11 @@ class Dialogs:
dialogStack = deque()
def __init__(self, parent):
self.widget = parent.findChild(QWidget, 'dialogsPage')
self.header = parent.findChild(QWidget, 'dialogHeader')
self.backButton = parent.findChild(QPushButton, 'dialog_backButton')
self.titleLabel = parent.findChild(QLabel, 'dialog_titleLabel')
self.dialogStackWidget = parent.findChild(QStackedWidget, 'dialogsStack')
self.widget = parent.dialogsPage
self.header = parent.dialogHeader
self.backButton = parent.dialog_backButton
self.titleLabel = parent.dialog_titleLabel
self.dialogStackWidget = parent.dialogsStack
self.backButton.clicked.connect(self.dialogReturn)
self.dialogStackWidget.currentChanged.connect(self.updateTitle)
@ -47,10 +47,10 @@ class Dialogs:
class ManualEntry:
def __init__(self, parentWindow, dialogHost):
self.widget = parentWindow.findChild(QWidget, 'manualEntryDialog')
self.confirmButton = parentWindow.findChild(QPushButton, 'manual_confirmButton')
self.freqLineEdit = parentWindow.findChild(QLineEdit, 'manual_freqLineEdit')
self.modulationCombo = parentWindow.findChild(QComboBox, 'manual_modulationCombo')
self.widget = parentWindow.manualEntryDialog
self.confirmButton = parentWindow.manual_confirmButton
self.freqLineEdit = parentWindow.manual_freqLineEdit
self.modulationCombo = parentWindow.manual_modulationCombo
self.host = dialogHost
self.confirmButton.clicked.connect(self.onConfirm)
@ -68,12 +68,12 @@ class Dialogs:
class EditEntry:
def __init__(self, parent):
self.widget = parent.findChild(QWidget, 'editEntryDialog')
self.codeLineEdit = parent.findChild(QLineEdit, 'entry_codeLineEdit')
self.delayLineEdit = parent.findChild(QLineEdit, 'entry_delayLineEdit')
self.freqLineEdit = parent.findChild(QLineEdit, 'entry_freqLineEdit')
self.lockoutCheckbox = parent.findChild(QCheckBox, 'entry_lockoutCheckbox')
self.modulationCombo = parent.findChild(QComboBox, 'entry_modulationCombo')
self.systemCombo = parent.findChild(QComboBox, 'entry_systemCombo')
self.tagLineEdit = parent.findChild(QLineEdit, 'entry_tagLineEdit')
self.widget = parent.editEntryDialog
self.codeLineEdit = parent.entry_codeLineEdit
self.delayLineEdit = parent.entry_delayLineEdit
self.freqLineEdit = parent.entry_freqLineEdit
self.lockoutCheckbox = parent.entry_lockoutCheckbox
self.modulationCombo = parent.entry_modulationCombo
self.systemCombo = parent.entry_systemCombo
self.tagLineEdit = parent.entry_tagLineEdit

View File

@ -4917,7 +4917,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>179</width>
<width>443</width>
<height>223</height>
</rect>
</property>

View File

@ -17,43 +17,41 @@ class Scanner:
squelchFromContext = False
def __init__(self, parentWindow):
self.widget = parentWindow.findChild(QWidget, 'scannerPage')
self.contextStack = parentWindow.findChild(QStackedWidget, 'scanContextStack')
self.holdPage = parentWindow.findChild(QWidget, 'scanner_holdPage')
self.scanPage = parentWindow.findChild(QWidget, 'scanner_scanPage')
self.entryTagLabel = parentWindow.findChild(QLabel, 'scanner_entryTagLabel')
self.frequencyLabel = parentWindow.findChild(QLabel, 'scanner_frequencyLabel')
self.modulationLabel = parentWindow.findChild(QLabel, 'scanner_modulationLabel')
self.systemTagLabel = parentWindow.findChild(QLabel, 'scanner_systemTagLabel')
self.entryNumLabel = parentWindow.findChild(QLabel, 'scanner_entryNumLabel')
self.delayLabel = parentWindow.findChild(QLabel, 'scanner_delayLabel')
self.lockoutDurationLabel = parentWindow.findChild(QLabel, 'scanner_lockoutDurationLabel')
self.scanModeLabel = parentWindow.findChild(QLabel, 'scanner_scanModeLabel')
self.lockoutDurationButton = parentWindow.findChild(QPushButton, 'scanner_lockoutDurationButton')
self.scanIndicator = parentWindow.findChild(QLabel, 'scanner_scanIndicator')
self.gainSlider = parentWindow.findChild(QSlider, 'scanner_gainSlider')
##self.gainLabel = parentWindow.findChild(QLabel, 'scanner_gainLabel')
self.sigStrengthBar = parentWindow.findChild(QProgressBar, 'scanner_sigStrengthBar')
self.squelchSlider = parentWindow.findChild(QSlider, 'scanner_squelchSlider')
##self.squelchLabel = parentWindow.findChild(QLabel, 'scanner_squelchLabel')
self.fnButtonsWidget = parentWindow.findChild(QWidget, 'scanner_fnButtonsWidget')
self.fnButton1 = parentWindow.findChild(QPushButton, 'scanner_fnButton1')
self.fnButton2 = parentWindow.findChild(QPushButton, 'scanner_fnButton2')
self.fnButton3 = parentWindow.findChild(QPushButton, 'scanner_fnButton3')
self.fnButton4 = parentWindow.findChild(QPushButton, 'scanner_fnButton4')
self.widget = parentWindow.scannerPage
self.contextStack = parentWindow.scanContextStack
self.holdPage = parentWindow.scanner_holdPage
self.scanPage = parentWindow.scanner_scanPage
self.entryTagLabel = parentWindow.scanner_entryTagLabel
self.frequencyLabel = parentWindow.scanner_frequencyLabel
self.modulationLabel = parentWindow.scanner_modulationLabel
self.systemTagLabel = parentWindow.scanner_systemTagLabel
self.entryNumLabel = parentWindow.scanner_entryNumLabel
self.delayLabel = parentWindow.scanner_delayLabel
self.lockoutDurationLabel = parentWindow.scanner_lockoutDurationLabel
self.scanModeLabel = parentWindow.scanner_scanModeLabel
self.lockoutDurationButton = parentWindow.scanner_lockoutDurationButton
self.scanIndicator = parentWindow.scanner_scanIndicator
self.gainSlider = parentWindow.scanner_gainSlider
self.sigStrengthBar = parentWindow.scanner_sigStrengthBar
self.squelchSlider = parentWindow.scanner_squelchSlider
self.fnButtonsWidget = parentWindow.scanner_fnButtonsWidget
self.fnButton1 = parentWindow.scanner_fnButton1
self.fnButton2 = parentWindow.scanner_fnButton2
self.fnButton3 = parentWindow.scanner_fnButton3
self.fnButton4 = parentWindow.scanner_fnButton4
self.sidebarToggleButton = parentWindow.findChild(QToolButton, 'scanner_sidebarToggle')
self.sidebarPanel = parentWindow.findChild(QWidget, 'scanner_sidebarPanel')
self.sidebarToggleButton = parentWindow.scanner_sidebarToggle
self.sidebarPanel = parentWindow.scanner_sidebarPanel
self.disconnectButton = parentWindow.findChild(QToolButton, 'scanner_disconnectButton')
self.settingsButton = parentWindow.findChild(QToolButton, 'scanner_settingsButton')
self.connectInfoButton = parentWindow.findChild(QToolButton, 'scanner_connectInfoButton')
self.disconnectButton = parentWindow.scanner_disconnectButton
self.settingsButton = parentWindow.scanner_settingsButton
self.connectInfoButton = parentWindow.scanner_connectInfoButton
self.volumeControlPanel = parentWindow.findChild(QWidget, 'scanner_volumeControl')
self.volumeSlider = parentWindow.findChild(QWidget, 'scanner_volumeSlider')
self.muteButton = parentWindow.findChild(QWidget, 'scanner_volumeMute')
self.volumeControlPanel = parentWindow.scanner_volumeControl
self.volumeSlider = parentWindow.scanner_volumeSlider
self.muteButton = parentWindow.scanner_volumeMute
self.entryEditButton = parentWindow.findChild(QToolButton, 'scanner_entryEditButton')
self.entryEditButton = parentWindow.scanner_entryEditButton
self.fnButton1.clicked.connect(self.onFnButton1)
self.fnButton2.clicked.connect(self.onFnButton2)
@ -81,7 +79,7 @@ class Scanner:
self.entryEditButton.setVisible(False)
self.delayLabel.setVisible(False)
self.scanModeLabel.setVisible(False)
parentWindow.findChild(QWidget, 'line_4').setVisible(False)
parentWindow.line_4.setVisible(False)
movie = QMovie("resources/bar-scan.gif")
movie.start()

2018
client/py/ui_scan_client.py Normal file

File diff suppressed because it is too large Load Diff