diff options
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 38 |
1 files changed, 14 insertions, 24 deletions
@@ -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 |