summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--Widgets/Dashboard.py41
-rw-r--r--main.py38
2 files changed, 33 insertions, 46 deletions
diff --git a/Widgets/Dashboard.py b/Widgets/Dashboard.py
index 8b6a11f..370405c 100644
--- a/Widgets/Dashboard.py
+++ b/Widgets/Dashboard.py
@@ -14,8 +14,7 @@
limitations under the License.
"""
-from PyQt5 import QtCore, QtGui, QtWidgets
-from extras.FeedKuksa import FeedKuksa
+from PyQt5 import QtCore, QtWidgets
import os
import sys
from PyQt5 import uic
@@ -64,8 +63,6 @@ class Dashboard(Base, Form):
super(self.__class__, self).__init__(parent)
self.setupUi(self)
- self.feed_kuksa = FeedKuksa()
-
Dashboard_tiles = (self.DB_IC_Tile,
self.DB_HVAC_Tile,
self.DB_Steering_Tile,
@@ -80,23 +77,23 @@ class Dashboard(Base, Form):
DashboardTiles.addButton(tile)
def set_icon(self, tile, icon_size):
- try:
- if tile == self.DB_IC_Tile:
- file = ":/Carbon_Icons/carbon_icons/meter.svg"
- if tile == self.DB_HVAC_Tile:
- file = ":/Carbon_Icons/carbon_icons/windy--strong.svg"
- if tile == self.DB_Steering_Tile:
- file = ":/Images/Images/steering-wheel.svg"
- if tile == self.DB_Settings_Tile:
- file = ":/Carbon_Icons/carbon_icons/settings.svg"
- getsize = QtSvg.QSvgRenderer(file)
- svg_widget = QtSvg.QSvgWidget(file)
- svg_widget.setFixedSize(getsize.defaultSize()*2)
- svg_widget.setStyleSheet("background-color: transparent;")
- tile.setIcon(QIcon(svg_widget.grab()))
- tile.setIconSize(QtCore.QSize(icon_size, icon_size))
- except Exception as e:
- print(f"Failed to set icon: {e}")
+ icon_mapping = {
+ self.DB_IC_Tile: ":/Carbon_Icons/carbon_icons/meter.svg",
+ self.DB_HVAC_Tile: ":/Carbon_Icons/carbon_icons/windy--strong.svg",
+ self.DB_Steering_Tile: ":/Images/Images/steering-wheel.svg",
+ self.DB_Settings_Tile: ":/Carbon_Icons/carbon_icons/settings.svg"
+ }
+
+ file = icon_mapping.get(tile)
+ if file is None:
+ return
+
+ getsize = QtSvg.QSvgRenderer(file)
+ svg_widget = QtSvg.QSvgWidget(file)
+ svg_widget.setFixedSize(getsize.defaultSize()*2)
+ svg_widget.setStyleSheet("background-color: transparent;")
+ tile.setIcon(QIcon(svg_widget.grab()))
+ tile.setIconSize(QtCore.QSize(icon_size, icon_size))
def tile_clicked(self, tile):
"""
@@ -122,4 +119,4 @@ if __name__ == '__main__':
app = QApplication(sys.argv)
w = Dashboard()
w.show()
- sys.exit(app.exec_()) \ No newline at end of file
+ sys.exit(app.exec_())
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