summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorsuchinton2001 <suchinton.2001@gmail.com>2023-10-24 16:57:31 +0530
committersuchinton2001 <suchinton.2001@gmail.com>2023-10-24 16:57:31 +0530
commitb100328904e366b72042a1493bbc9c04c1c45da2 (patch)
treef994bd7a9b52a4324e9b3b62e17105cc8dd2d6c8 /main.py
parent9af16ad7272f4e1d068004fc4443db5d14f89b3c (diff)
agl-demo-control-panel: Fix circular import problem
Fix circular import, causing control panel to fail to launch SPEC-4942 Signed-off-by: suchinton2001 <suchinton.2001@gmail.com> Change-Id: Id035ba28b8c19d1002abf0073656d99572c43b0e
Diffstat (limited to 'main.py')
-rw-r--r--main.py38
1 files changed, 14 insertions, 24 deletions
diff --git a/main.py b/main.py
index 9fe799e..4d9be1f 100644
--- a/main.py
+++ b/main.py
@@ -55,6 +55,8 @@ class MainWindow(Base, Form):
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setStyle(QtWidgets.QStyleFactory.create('Fusion'))
+ self.current_page = None
+
self.headerContainer = self.findChild(QWidget, 'headerContainer')
self.headerContainer.DoubleClickMaximize = lambda: UI_Handeler.toggleMaximized(
self)
@@ -83,7 +85,7 @@ class MainWindow(Base, Form):
# make the close button also end all threads
closeButton.clicked.connect(
- lambda: [self.close(), self.stop_thread_signal.emit()])
+ lambda: [UI_Handeler.stop_client(self), self.close(), self.stop_thread_signal.emit()])
minimizeButton.clicked.connect(self.showMinimized)
maximizeButton.clicked.connect(
lambda: UI_Handeler.toggleMaximized(self))
@@ -112,9 +114,6 @@ class MainWindow(Base, Form):
self.stackedWidget.currentChanged.connect(self.handleChangedPage)
- self.stop_thread_signal.connect(
- self.stackedWidget.widget(0).feed_kuksa.stop)
-
self.stackedWidget.setCurrentIndex(0)
self.dashboardButton.setChecked(True)
UI_Handeler.Hide_Navbar(self, bool_arg=False)
@@ -127,7 +126,6 @@ class MainWindow(Base, Form):
self.centralwidget = self.findChild(QWidget, 'centralwidget')
self.size_grip = QtWidgets.QSizeGrip(self)
self.size_grip.setFixedSize(20, 20)
- # self.size_grip.setStyleSheet("QSizeGrip { background-color: transparent; }")
self.size_grip.setStyleSheet("""
QSizeGrip {
background-color: transparent;
@@ -150,31 +148,23 @@ class MainWindow(Base, Form):
"""
UI_Handeler.Hide_Navbar(self, bool_arg=False)
- def handleChangedPage(self, index):
+ def handleChangedPage(self, page_index):
"""
Handles the change of pages in the stacked widget.
Stops the previous thread and starts the new one.
If the index is 0, the navbar is not hidden. Otherwise, it is hidden.
"""
- if index == 0:
- UI_Handeler.Hide_Navbar(self, bool_arg=False)
- else:
- UI_Handeler.Hide_Navbar(self, bool_arg=True)
- try:
- self.stop_thread_signal.connect(
- self.stackedWidget.widget(self.current_page).feed_kuksa.stop)
- self.stop_thread_signal.emit()
- except:
- pass
+ hide_navbar = page_index != 0
+ UI_Handeler.Hide_Navbar(self, hide_navbar)
- self.current_page = self.stackedWidget.currentIndex()
+ if self.current_page is not None:
+ if self.current_page != 0 and self.current_page != 4:
+ self.stackedWidget.widget(self.current_page).feed_kuksa.stop()
+
+ self.current_page = page_index
- try:
- self.start_thread_signal.connect(
- self.stackedWidget.widget(self.current_page).feed_kuksa.start)
- self.start_thread_signal.emit()
- except:
- pass
+ if self.current_page != 0 and self.current_page != 4:
+ self.stackedWidget.widget(self.current_page).feed_kuksa.start()
if __name__ == '__main__':
@@ -184,4 +174,4 @@ if __name__ == '__main__':
':/Images/Images/Automotive_Grade_Linux_logo.svg'))
window = MainWindow()
window.show()
- sys.exit(app.exec_())
+ sys.exit(app.exec_()) \ No newline at end of file