From 9acf10b0c85026a2dc6b4b9c897c7e1072af39b2 Mon Sep 17 00:00:00 2001 From: Roberto Date: Mon, 22 Dec 2025 09:37:47 +0000 Subject: [PATCH 1/4] ADD: added update page to connection page --- BlocksScreen/lib/moonrakerComm.py | 15 +- BlocksScreen/lib/panels/mainWindow.py | 1 + .../lib/panels/widgets/connectionPage.py | 93 +- BlocksScreen/lib/panels/widgets/updatePage.py | 51 +- BlocksScreen/lib/ui/connectionWindow.ui | 1145 +++++++++-------- BlocksScreen/lib/ui/connectionWindow_ui.py | 264 ++-- 6 files changed, 864 insertions(+), 705 deletions(-) diff --git a/BlocksScreen/lib/moonrakerComm.py b/BlocksScreen/lib/moonrakerComm.py index 78fba08e..ba298ba7 100644 --- a/BlocksScreen/lib/moonrakerComm.py +++ b/BlocksScreen/lib/moonrakerComm.py @@ -734,13 +734,16 @@ def update_status(self, refresh: bool = False) -> bool: @QtCore.pyqtSlot(name="update-refresh") @QtCore.pyqtSlot(str, name="update-refresh") - def refresh_update_status(self, name: str = "") -> bool: + def refresh_update_status(self, name: str = None) -> bool: """Refresh packages state""" - if not isinstance(name, str) or not name: - return False - return self._ws.send_request( - method="machine.update.refresh", params={"name": name} - ) + if isinstance(name, str): + return self._ws.send_request( + method="machine.update.refresh", params={"name": name} + ) + else: + return self._ws.send_request( + method="machine.update.refresh", + ) @QtCore.pyqtSlot(name="update-full") def full_update(self) -> bool: diff --git a/BlocksScreen/lib/panels/mainWindow.py b/BlocksScreen/lib/panels/mainWindow.py index 18549a39..66e8fa47 100644 --- a/BlocksScreen/lib/panels/mainWindow.py +++ b/BlocksScreen/lib/panels/mainWindow.py @@ -153,6 +153,7 @@ def __init__(self): ) self.controlPanel.disable_popups.connect(self.popup_toggle) self.on_update_message.connect(self.utilitiesPanel.on_update_message) + self.on_update_message.connect(self.conn_window.on_update_message) self.ui.extruder_temp_display.display_format = "upper_downer" self.ui.bed_temp_display.display_format = "upper_downer" if self.config.has_section("server"): diff --git a/BlocksScreen/lib/panels/widgets/connectionPage.py b/BlocksScreen/lib/panels/widgets/connectionPage.py index 0b7e054d..b6f835c7 100644 --- a/BlocksScreen/lib/panels/widgets/connectionPage.py +++ b/BlocksScreen/lib/panels/widgets/connectionPage.py @@ -1,8 +1,10 @@ import logging +import typing from events import KlippyDisconnected, KlippyReady, KlippyShutdown from lib.moonrakerComm import MoonWebSocket from lib.ui.connectionWindow_ui import Ui_ConnectivityForm +from lib.panels.widgets.updatePage import UpdatePage from PyQt6 import QtCore, QtWidgets @@ -13,11 +15,35 @@ class ConnectionPage(QtWidgets.QFrame): reboot_clicked = QtCore.pyqtSignal(name="reboot_clicked") restart_klipper_clicked = QtCore.pyqtSignal(name="restart_klipper_clicked") firmware_restart_clicked = QtCore.pyqtSignal(name="firmware_restart_clicked") + on_update_message: typing.ClassVar[QtCore.pyqtSignal] = QtCore.pyqtSignal( + dict, name="handle-update-message" + ) def __init__(self, parent: QtWidgets.QWidget, ws: MoonWebSocket, /): super().__init__(parent) + self.setMinimumSize(QtCore.QSize(800, 480)) + self.stack = QtWidgets.QStackedLayout(self) + self.connection_widget = QtWidgets.QFrame(self) self.panel = Ui_ConnectivityForm() - self.panel.setupUi(self) + self.panel.setupUi(self.connection_widget) + self.up = UpdatePage(self) + self.stack.addWidget(self.connection_widget) + self.stack.addWidget(self.up) + + self.stack.currentChanged.connect(self.up.build_model_list) + + self.stack.setCurrentWidget(self.connection_widget) + + self.up.update_back_btn.clicked.connect( + lambda: {self.stack.setCurrentWidget(self.connection_widget)} + ) + self.panel.updatepageButton.clicked.connect( + lambda: { + self.stack.setCurrentWidget(self.up), + self.ws.api.refresh_update_status(), + } + ) + self.ws = ws self._moonraker_status: str = "disconnected" self._klippy_state: str = "closed" @@ -46,6 +72,22 @@ def __init__(self, parent: QtWidgets.QWidget, ws: MoonWebSocket, /): self.ws.klippy_connected_signal.connect(self.on_klippy_connected) self.ws.klippy_state_signal.connect(self.on_klippy_state) + self.on_update_message.connect(self.up.handle_update_message) + self.up.request_full_update.connect(self.ws.api.full_update) + self.up.request_recover_repo[str].connect(self.ws.api.recover_corrupt_repo) + self.up.request_recover_repo[str, bool].connect( + self.ws.api.recover_corrupt_repo + ) + self.up.request_refresh_update.connect(self.ws.api.refresh_update_status) + self.up.request_refresh_update[str].connect(self.ws.api.refresh_update_status) + + self.up.request_rollback_update.connect(self.ws.api.rollback_update) + self.up.request_update_client.connect(self.ws.api.update_client) + self.up.request_update_klipper.connect(self.ws.api.update_klipper) + self.up.request_update_moonraker.connect(self.ws.api.update_moonraker) + self.up.request_update_status.connect(self.ws.api.update_status) + self.up.request_update_system.connect(self.ws.api.update_system) + def show_panel(self, reason: str | None = None): """Show widget""" self.show() @@ -58,6 +100,8 @@ def show_panel(self, reason: str | None = None): @QtCore.pyqtSlot(bool, name="on_klippy_connected") def on_klippy_connection(self, connected: bool): """Handle klippy connection state""" + self.dot_timer.stop() + self._klippy_connection = connected if not connected: self.panel.connectionTextBox.setText("Klipper Disconnected") @@ -69,6 +113,7 @@ def on_klippy_connection(self, connected: bool): @QtCore.pyqtSlot(str, name="on_klippy_state") def on_klippy_state(self, state: str): """Handle klippy state changes""" + self.dot_timer.stop() if state == "error": self.panel.connectionTextBox.setText("Klipper Connection Error") if not self.isVisible(): @@ -87,7 +132,6 @@ def on_klippy_state(self, state: str): self.panel.connectionTextBox.setText("Klipper Startup") elif state == "ready": self.panel.connectionTextBox.setText("Klipper Ready") - self.hide() @QtCore.pyqtSlot(int, name="on_websocket_connecting") @QtCore.pyqtSlot(str, name="on_websocket_connecting") @@ -98,21 +142,22 @@ def on_websocket_connecting(self, attempt: int): @QtCore.pyqtSlot(name="on_websocket_connection_achieved") def on_websocket_connection_achieved(self): """Handle websocket connected state""" + self.dot_timer.stop() self.panel.connectionTextBox.setText("Moonraker Connected\n Klippy not ready") - self.hide() - @QtCore.pyqtSlot(name="on_websocket_connection_lost") + @QtCore.pyqtSlot(name="on_websocket_connection_lzost") def on_websocket_connection_lost(self): """Handle websocket connection lost state""" if not self.isVisible(): self.show() + self.dot_timer.stop() self.text_update(text="Websocket lost") def text_update(self, text: int | str | None = None): """Update widget text""" if self.state == "shutdown" and self.message is not None: return False - + self.dot_timer.stop() logging.debug(f"[ConnectionWindowPanel] text_update: {text}") if text == "wb lost": self.panel.connectionTextBox.setText("Moonraker connection lost") @@ -125,41 +170,34 @@ def text_update(self, text: int | str | None = None): return True if isinstance(text, str): self.panel.connectionTextBox.setText( - f""" - Connection to Moonraker unavailable\nTry again by reconnecting or \nrestarting klipper\n{text} - """ + f"""Connection to Moonraker unavailable\nTry again by reconnecting or \nrestarting klipper\n{text}""" ) return True if isinstance(text, int): # * Websocket connection messages + + self.base_text = f"Attempting to reconnect to Moonraker.\n\nConnection try number: {text}" + if text == 0: - self.dot_timer.stop() self.panel.connectionTextBox.setText( - "Unable to Connect to Moonraker.\n\nTry again" + "Connection to Moonraker timeout \n \n please retry" ) - return False + return + self.dot_count = 0 - if text == 1: - if self.dot_timer.isActive(): - self.dot_timer.stop() - return - self.dot_timer.start() - - self.text2 = f"Attempting to reconnect to Moonraker.\n\nConnection try number: {text}" + self.dot_timer.start() + self._add_dot() return False def _add_dot(self): - if self.state == "shutdown" and self.message is not None: + """Add one dot per second (max 3).""" + self.dot_count += 1 + if self.dot_count > 3: self.dot_timer.stop() - return False - - if self.dot_count > 2: - self.dot_count = 1 - else: - self.dot_count += 1 + return dots = "." * self.dot_count + " " * (3 - self.dot_count) - self.panel.connectionTextBox.setText(f"{self.text2}{dots}") + self.panel.connectionTextBox.setText(f"{self.base_text}{dots}") @QtCore.pyqtSlot(str, str, name="webhooks_update") def webhook_update(self, state: str, message: str): @@ -171,16 +209,19 @@ def webhook_update(self, state: str, message: str): def eventFilter(self, object: QtCore.QObject, event: QtCore.QEvent) -> bool: """Re-implemented method, filter events""" if event.type() == KlippyDisconnected.type(): + self.dot_timer.stop() if not self.isVisible(): self.panel.connectionTextBox.setText("Klippy Disconnected") self.show() elif event.type() == KlippyReady.type(): + self.dot_timer.stop() self.panel.connectionTextBox.setText("Klippy Ready") self.hide() return False elif event.type() == KlippyShutdown.type(): + self.dot_timer.stop() if not self.isVisible(): self.panel.connectionTextBox.setText(f"{self.message}") self.show() diff --git a/BlocksScreen/lib/panels/widgets/updatePage.py b/BlocksScreen/lib/panels/widgets/updatePage.py index 534bbabe..b4def035 100644 --- a/BlocksScreen/lib/panels/widgets/updatePage.py +++ b/BlocksScreen/lib/panels/widgets/updatePage.py @@ -8,6 +8,7 @@ from lib.utils.list_model import EntryDelegate, EntryListModel, ListItem from PyQt6 import QtCore, QtGui, QtWidgets +from lib.panels.widgets.loadWidget import LoadingOverlayWidget class UpdatePage(QtWidgets.QWidget): """Update GUI Page, @@ -78,6 +79,8 @@ def __init__(self, parent=None) -> None: self.repeated_request_status.timeout.connect( lambda: self.request_update_status.emit(False) ) + self.setAttribute(QtCore.Qt.WidgetAttribute.WA_StyledBackground, True) + self.show_loading(True) def handle_update_end(self) -> None: """Handles update end signal @@ -112,6 +115,7 @@ def deleteLater(self) -> None: def showEvent(self, event: QtGui.QShowEvent | None) -> None: """Re-add clients to update list""" self.build_model_list() + return super().showEvent(event) def build_model_list(self) -> None: @@ -165,11 +169,13 @@ def on_item_clicked(self, item: ListItem) -> None: """ if not item: return + self.show_loading(False) cli_data = self.cli_tracking.get(item.text, {}) if not cli_data: self.version_tracking_info.setText("Missing, Cannot Update") self.selected_item = copy.copy(item) if item.text == "system": + self.no_update_placeholder.hide() self.remote_version_title.hide() self.remote_version_tracking.hide() updatable_packages = cli_data.get("package_count", 0) @@ -224,6 +230,19 @@ def on_item_clicked(self, item: ListItem) -> None: self.no_update_placeholder.hide() self.action_btn.show() + def show_loading(self,loading:bool = False)->None: + """Show or hide loading overlay""" + self.loadwidget.setVisible(loading) + self.info_loadwidget.setVisible(loading) + self.info_loadwidget.setFixedSize(self.infobox_frame.size()) + self.update_buttons_list_widget.setVisible(not loading) + self.remote_version_title.setVisible(not loading) + self.remote_version_tracking.setVisible(not loading) + self.version_tracking_info.setVisible(not loading) + self.version_title.setVisible(not loading) + self.action_btn.setVisible(not loading) + self.no_update_placeholder.setVisible(not loading) + @QtCore.pyqtSlot(dict, name="handle-update-message") def handle_update_message(self, message: dict) -> None: """Handle receiving current state of each item update. @@ -244,6 +263,7 @@ def handle_update_message(self, message: dict) -> None: if not cli_version_info: return self.cli_tracking = cli_version_info + self.build_model_list() # Signal that updates exist (Used to render red dots) _update_avail = any( value @@ -281,11 +301,19 @@ def _setupUI(self) -> None: sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) self.setSizePolicy(sizePolicy) - self.setMinimumSize(QtCore.QSize(710, 400)) - self.setMaximumSize(QtCore.QSize(720, 420)) + self.setObjectName("updatePage") + self.setStyleSheet( + """#updatePage { + background-image: url(:/background/media/1st_background.png); + } + #updatePage, + #updatePage * { + border: 3px solid #ffffff; + }""" + ) self.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight) self.update_page_content_layout = QtWidgets.QVBoxLayout() - self.update_page_content_layout.setContentsMargins(15, 15, 2, 2) + self.update_page_content_layout.setContentsMargins(15, 15, 15, 15) self.header_content_layout = QtWidgets.QHBoxLayout() self.header_content_layout.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop) @@ -472,17 +500,22 @@ def _setupUI(self) -> None: QtWidgets.QScroller.ScrollerGestureType.LeftMouseButtonGesture, ) self.update_buttons_layout = QtWidgets.QVBoxLayout() - self.update_buttons_layout.setContentsMargins(15, 20, 20, 5) + self.update_buttons_layout.setContentsMargins(10, 10, 10, 10) self.update_buttons_layout.addWidget(self.update_buttons_list_widget, 0) + self.update_buttons_list_widget.hide() + self.loadwidget = LoadingOverlayWidget(self) + self.loadwidget.setMinimumSize(self.update_buttons_frame.size()) + self.update_buttons_layout.addWidget(self.loadwidget, 1) self.update_buttons_frame.setLayout(self.update_buttons_layout) self.main_content_layout.addWidget(self.update_buttons_frame, 0) self.infobox_frame = BlocksCustomFrame() - self.infobox_frame.setMinimumSize(QtCore.QSize(250, 300)) - self.info_box_layout = QtWidgets.QVBoxLayout() - self.info_box_layout.setContentsMargins(10, 0, 10, 0) + self.info_box_layout.setContentsMargins(10, 10, 10, 10) + self.infobox_frame.setLayout(self.info_box_layout) + self.info_loadwidget = LoadingOverlayWidget(self) + self.info_box_layout.addWidget(self.info_loadwidget, 0) font = QtGui.QFont() font.setFamily(font_family) @@ -579,16 +612,14 @@ def _setupUI(self) -> None: self.no_update_placeholder.setWordWrap(True) self.no_update_placeholder.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) self.info_box_layout.addWidget( - self.no_update_placeholder, 0, QtCore.Qt.AlignmentFlag.AlignBottom + self.no_update_placeholder, 0, QtCore.Qt.AlignmentFlag.AlignCenter ) - self.no_update_placeholder.hide() self.info_box_layout.addLayout( self.button_box, 0, ) - self.infobox_frame.setLayout(self.info_box_layout) self.main_content_layout.addWidget(self.infobox_frame, 1) self.update_page_content_layout.addLayout(self.main_content_layout, 1) self.setLayout(self.update_page_content_layout) diff --git a/BlocksScreen/lib/ui/connectionWindow.ui b/BlocksScreen/lib/ui/connectionWindow.ui index 84558abd..96a2179b 100644 --- a/BlocksScreen/lib/ui/connectionWindow.ui +++ b/BlocksScreen/lib/ui/connectionWindow.ui @@ -41,13 +41,7 @@ false - #ConnectivityForm{ - background-image: url(:/background/media/1st_background.png); -} - - - - + #ConnectivityForm{background-image: url(:/background/media/1st_background.png);} @@ -115,551 +109,613 @@ 0 - - - - 623 - 10 - 154 - 80 - - - - - 0 - 0 - - - - - 154 - 80 - - - - - 154 - 80 - - - - - 80 - 80 - - - - - - - - - - - - 13 - - - - true - - - Qt::ClickFocus - - - false - - - - - - Retry - - - - :/system_icons/media/btn_icons/retry_connection.svg:/system_icons/media/btn_icons/retry_connection.svg - - - - 16 - 16 - - - - false - - + + 0 - + 0 - - false - - - false - - - true - - - bottom - - - :/system/media/btn_icons/restart_printer.svg - - - - 255 - 255 - 255 - - - - true - - - - - - 475 - 11 - 154 - 80 - - - - - 0 - 0 - - - - - 154 - 80 - - - - - 154 - 80 - - - - - 80 - 80 - - - - true - - - Qt::NoFocus - - - Qt::NoContextMenu - - - false - - - Wifi Settings - - - - :/system_icons/media/btn_icons/retry_connection.svg:/system_icons/media/btn_icons/retry_connection.svg - - - false - - - false - - - true - - - system_control_btn - - - :/network/media/btn_icons/wifi_config.svg - - - true - - - bottom - - - - - - 315 - 10 - 154 - 80 - - - - - 0 - 0 - - - - - 154 - 80 - - - - - 154 - 80 - - - - - 160 - 80 - - - - BlankCursor - - - true - - - Qt::NoFocus - - - Qt::NoContextMenu - - - false - - - Firmware Restart - - - - :/system_icons/media/btn_icons/firmware_restart.svg:/system_icons/media/btn_icons/firmware_restart.svg - - - false - - - false - - - true + + 5 - - :/system/media/btn_icons/restart_firmware.svg - - - true - - - bottom - - - - 255 - 255 - 255 - - - - - - - 157 - 10 - 154 - 80 - - - - - 0 - 0 - - - - - 154 - 80 - - - - - 154 - 80 - - - - - 80 - 80 - - - - BlankCursor - - - true - - - Qt::NoFocus - - - Qt::NoContextMenu - - - false - - - Reboot - - - - :/system_icons/media/btn_icons/firmware_restart.svg:/system_icons/media/btn_icons/firmware_restart.svg - - - false - - - false - - - true - - - :/system/media/btn_icons/reboot.svg - - - bottom - - - - 255 - 255 - 255 - - - - true - - - - - - 4 - 10 - 154 - 80 - - - - - 0 - 0 - - - - - 154 - 80 - - - - - 154 - 80 - - - - - 160 - 80 - - - - - - - - - 66 - 66 - 66 - - - - - - - 66 - 66 - 66 - - - - - - - 66 - 66 - 66 - - - - - - - - - 66 - 66 - 66 - - - - - - - 66 - 66 - 66 - - - - - - - 66 - 66 - 66 - - - - - - - - - 66 - 66 - 66 - - - - - - - 66 - 66 - 66 - - - - - - - 66 - 66 - 66 - - - - - - - - - false - PreferAntialias - false - - - - BlankCursor - - - true - - - Qt::NoFocus - - - Qt::NoContextMenu - - - Qt::LeftToRight - - - false - - - - - - Restart Klipper - - - - :/system_icons/media/btn_icons/restart_klipper.svg - - - - - 46 - 42 - - - - false - - - false - - - false - - + 0 - + 0 - - false - - - true - - - :/system/media/btn_icons/restart_klipper.svg - - - true - - - bottom - - - - 255 - 255 - 255 - - - + + + + + 0 + 0 + + + + + 154 + 80 + + + + + 154 + 80 + + + + + 160 + 80 + + + + + + + + + 66 + 66 + 66 + + + + + + + 66 + 66 + 66 + + + + + + + 66 + 66 + 66 + + + + + + + + + 66 + 66 + 66 + + + + + + + 66 + 66 + 66 + + + + + + + 66 + 66 + 66 + + + + + + + + + 66 + 66 + 66 + + + + + + + 66 + 66 + 66 + + + + + + + 66 + 66 + 66 + + + + + + + + + false + PreferAntialias + false + + + + BlankCursor + + + true + + + Qt::NoFocus + + + Qt::NoContextMenu + + + Qt::LeftToRight + + + false + + + + + + Restart Klipper + + + + :/system_icons/media/btn_icons/restart_klipper.svg + + + + + 46 + 42 + + + + false + + + false + + + false + + + 0 + + + 0 + + + false + + + true + + + :/system/media/btn_icons/restart_klipper.svg + + + true + + + bottom + + + + 255 + 255 + 255 + + + + + + + + + 0 + 0 + + + + + 154 + 80 + + + + + 154 + 80 + + + + + 80 + 80 + + + + BlankCursor + + + true + + + Qt::NoFocus + + + Qt::NoContextMenu + + + false + + + Reboot + + + + :/system_icons/media/btn_icons/firmware_restart.svg:/system_icons/media/btn_icons/firmware_restart.svg + + + false + + + false + + + true + + + :/system/media/btn_icons/reboot.svg + + + bottom + + + + 255 + 255 + 255 + + + + true + + + + + + + + 0 + 0 + + + + + 154 + 80 + + + + + 154 + 80 + + + + + 160 + 80 + + + + BlankCursor + + + true + + + Qt::NoFocus + + + Qt::NoContextMenu + + + false + + + Firmware Restart + + + + :/system_icons/media/btn_icons/firmware_restart.svg:/system_icons/media/btn_icons/firmware_restart.svg + + + false + + + false + + + true + + + :/system/media/btn_icons/restart_firmware.svg + + + true + + + bottom + + + + 255 + 255 + 255 + + + + + + + + + 0 + 0 + + + + + 154 + 80 + + + + + 154 + 80 + + + + + 80 + 80 + + + + + + + + + + + + 13 + + + + true + + + Qt::ClickFocus + + + false + + + + + + Retry + + + + :/system_icons/media/btn_icons/retry_connection.svg:/system_icons/media/btn_icons/retry_connection.svg + + + + 16 + 16 + + + + false + + + 0 + + + 0 + + + false + + + false + + + true + + + bottom + + + :/system/media/btn_icons/restart_printer.svg + + + + 255 + 255 + 255 + + + + true + + + + + + + + 0 + 0 + + + + + 154 + 80 + + + + + 154 + 80 + + + + + 80 + 80 + + + + BlankCursor + + + true + + + Qt::NoFocus + + + Qt::NoContextMenu + + + false + + + Update page + + + + :/system_icons/media/btn_icons/firmware_restart.svg:/system_icons/media/btn_icons/firmware_restart.svg + + + false + + + false + + + true + + + :/system/media/btn_icons/update-software-icon.svg + + + bottom + + + + 255 + 255 + 255 + + + + true + + + + + + + + 0 + 0 + + + + + 154 + 80 + + + + + 154 + 80 + + + + + 80 + 80 + + + + true + + + Qt::NoFocus + + + Qt::NoContextMenu + + + false + + + Wifi Settings + + + + :/system_icons/media/btn_icons/retry_connection.svg:/system_icons/media/btn_icons/retry_connection.svg + + + false + + + false + + + true + + + system_control_btn + + + :/network/media/btn_icons/wifi_config.svg + + + true + + + bottom + + + + @@ -691,6 +747,9 @@ false + + + QFrame::NoFrame diff --git a/BlocksScreen/lib/ui/connectionWindow_ui.py b/BlocksScreen/lib/ui/connectionWindow_ui.py index 58c5945b..caca54fa 100644 --- a/BlocksScreen/lib/ui/connectionWindow_ui.py +++ b/BlocksScreen/lib/ui/connectionWindow_ui.py @@ -1,4 +1,4 @@ -# Form implementation generated from reading ui file 'main/BlocksScreen/BlocksScreen/lib/ui/connectionWindow.ui' +# Form implementation generated from reading ui file '/home/levi/BlocksScreen/BlocksScreen/lib/ui/connectionWindow.ui' # # Created by: PyQt6 UI code generator 6.7.1 # @@ -23,13 +23,7 @@ def setupUi(self, ConnectivityForm): ConnectivityForm.setMaximumSize(QtCore.QSize(800, 480)) ConnectivityForm.setWindowOpacity(1.0) ConnectivityForm.setAutoFillBackground(False) - ConnectivityForm.setStyleSheet("#ConnectivityForm{\n" -" background-image: url(:/background/media/1st_background.png);\n" -"}\n" -"\n" -"\n" -"\n" -"") + ConnectivityForm.setStyleSheet("#ConnectivityForm{background-image: url(:/background/media/1st_background.png);}") ConnectivityForm.setProperty("class", "") self.cw_buttonFrame = BlocksCustomFrame(parent=ConnectivityForm) self.cw_buttonFrame.setGeometry(QtCore.QRect(10, 380, 780, 124)) @@ -53,110 +47,11 @@ def setupUi(self, ConnectivityForm): self.cw_buttonFrame.setFrameShadow(QtWidgets.QFrame.Shadow.Plain) self.cw_buttonFrame.setLineWidth(0) self.cw_buttonFrame.setObjectName("cw_buttonFrame") - self.RetryConnectionButton = IconButton(parent=self.cw_buttonFrame) - self.RetryConnectionButton.setGeometry(QtCore.QRect(623, 10, 154, 80)) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.RetryConnectionButton.sizePolicy().hasHeightForWidth()) - self.RetryConnectionButton.setSizePolicy(sizePolicy) - self.RetryConnectionButton.setMinimumSize(QtCore.QSize(154, 80)) - self.RetryConnectionButton.setMaximumSize(QtCore.QSize(154, 80)) - self.RetryConnectionButton.setBaseSize(QtCore.QSize(80, 80)) - palette = QtGui.QPalette() - self.RetryConnectionButton.setPalette(palette) - font = QtGui.QFont() - font.setPointSize(13) - self.RetryConnectionButton.setFont(font) - self.RetryConnectionButton.setTabletTracking(True) - self.RetryConnectionButton.setFocusPolicy(QtCore.Qt.FocusPolicy.ClickFocus) - self.RetryConnectionButton.setAutoFillBackground(False) - self.RetryConnectionButton.setStyleSheet("") - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(":/system_icons/media/btn_icons/retry_connection.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) - self.RetryConnectionButton.setIcon(icon) - self.RetryConnectionButton.setIconSize(QtCore.QSize(16, 16)) - self.RetryConnectionButton.setCheckable(False) - self.RetryConnectionButton.setAutoRepeatDelay(0) - self.RetryConnectionButton.setAutoRepeatInterval(0) - self.RetryConnectionButton.setAutoDefault(False) - self.RetryConnectionButton.setDefault(False) - self.RetryConnectionButton.setFlat(True) - self.RetryConnectionButton.setProperty("icon_pixmap", QtGui.QPixmap(":/system/media/btn_icons/restart_printer.svg")) - self.RetryConnectionButton.setProperty("text_color", QtGui.QColor(255, 255, 255)) - self.RetryConnectionButton.setProperty("has_text", True) - self.RetryConnectionButton.setObjectName("RetryConnectionButton") - self.wifi_button = IconButton(parent=self.cw_buttonFrame) - self.wifi_button.setGeometry(QtCore.QRect(475, 11, 154, 80)) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.wifi_button.sizePolicy().hasHeightForWidth()) - self.wifi_button.setSizePolicy(sizePolicy) - self.wifi_button.setMinimumSize(QtCore.QSize(154, 80)) - self.wifi_button.setMaximumSize(QtCore.QSize(154, 80)) - self.wifi_button.setBaseSize(QtCore.QSize(80, 80)) - self.wifi_button.setTabletTracking(True) - self.wifi_button.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus) - self.wifi_button.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.NoContextMenu) - self.wifi_button.setAutoFillBackground(False) - self.wifi_button.setIcon(icon) - self.wifi_button.setAutoDefault(False) - self.wifi_button.setDefault(False) - self.wifi_button.setFlat(True) - self.wifi_button.setProperty("icon_pixmap", QtGui.QPixmap(":/network/media/btn_icons/wifi_config.svg")) - self.wifi_button.setProperty("has_text", True) - self.wifi_button.setObjectName("wifi_button") - self.FirmwareRestartButton = IconButton(parent=self.cw_buttonFrame) - self.FirmwareRestartButton.setGeometry(QtCore.QRect(315, 10, 154, 80)) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.FirmwareRestartButton.sizePolicy().hasHeightForWidth()) - self.FirmwareRestartButton.setSizePolicy(sizePolicy) - self.FirmwareRestartButton.setMinimumSize(QtCore.QSize(154, 80)) - self.FirmwareRestartButton.setMaximumSize(QtCore.QSize(154, 80)) - self.FirmwareRestartButton.setBaseSize(QtCore.QSize(160, 80)) - self.FirmwareRestartButton.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.BlankCursor)) - self.FirmwareRestartButton.setTabletTracking(True) - self.FirmwareRestartButton.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus) - self.FirmwareRestartButton.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.NoContextMenu) - self.FirmwareRestartButton.setAutoFillBackground(False) - icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(":/system_icons/media/btn_icons/firmware_restart.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) - self.FirmwareRestartButton.setIcon(icon1) - self.FirmwareRestartButton.setAutoDefault(False) - self.FirmwareRestartButton.setDefault(False) - self.FirmwareRestartButton.setFlat(True) - self.FirmwareRestartButton.setProperty("icon_pixmap", QtGui.QPixmap(":/system/media/btn_icons/restart_firmware.svg")) - self.FirmwareRestartButton.setProperty("has_text", True) - self.FirmwareRestartButton.setProperty("text_color", QtGui.QColor(255, 255, 255)) - self.FirmwareRestartButton.setObjectName("FirmwareRestartButton") - self.RebootSystemButton = IconButton(parent=self.cw_buttonFrame) - self.RebootSystemButton.setGeometry(QtCore.QRect(157, 10, 154, 80)) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.RebootSystemButton.sizePolicy().hasHeightForWidth()) - self.RebootSystemButton.setSizePolicy(sizePolicy) - self.RebootSystemButton.setMinimumSize(QtCore.QSize(154, 80)) - self.RebootSystemButton.setMaximumSize(QtCore.QSize(154, 80)) - self.RebootSystemButton.setBaseSize(QtCore.QSize(80, 80)) - self.RebootSystemButton.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.BlankCursor)) - self.RebootSystemButton.setTabletTracking(True) - self.RebootSystemButton.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus) - self.RebootSystemButton.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.NoContextMenu) - self.RebootSystemButton.setAutoFillBackground(False) - self.RebootSystemButton.setIcon(icon1) - self.RebootSystemButton.setAutoDefault(False) - self.RebootSystemButton.setDefault(False) - self.RebootSystemButton.setFlat(True) - self.RebootSystemButton.setProperty("icon_pixmap", QtGui.QPixmap(":/system/media/btn_icons/reboot.svg")) - self.RebootSystemButton.setProperty("text_color", QtGui.QColor(255, 255, 255)) - self.RebootSystemButton.setProperty("has_text", True) - self.RebootSystemButton.setObjectName("RebootSystemButton") + self.horizontalLayout = QtWidgets.QHBoxLayout(self.cw_buttonFrame) + self.horizontalLayout.setContentsMargins(0, 5, 0, 0) + self.horizontalLayout.setSpacing(0) + self.horizontalLayout.setObjectName("horizontalLayout") self.RestartKlipperButton = IconButton(parent=self.cw_buttonFrame) - self.RestartKlipperButton.setGeometry(QtCore.QRect(4, 10, 154, 80)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -206,9 +101,9 @@ def setupUi(self, ConnectivityForm): self.RestartKlipperButton.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight) self.RestartKlipperButton.setAutoFillBackground(False) self.RestartKlipperButton.setStyleSheet("") - icon2 = QtGui.QIcon() - icon2.addPixmap(QtGui.QPixmap(":/system_icons/media/btn_icons/restart_klipper.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.On) - self.RestartKlipperButton.setIcon(icon2) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(":/system_icons/media/btn_icons/restart_klipper.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.On) + self.RestartKlipperButton.setIcon(icon) self.RestartKlipperButton.setIconSize(QtCore.QSize(46, 42)) self.RestartKlipperButton.setCheckable(False) self.RestartKlipperButton.setAutoRepeat(False) @@ -221,6 +116,132 @@ def setupUi(self, ConnectivityForm): self.RestartKlipperButton.setProperty("has_text", True) self.RestartKlipperButton.setProperty("text_color", QtGui.QColor(255, 255, 255)) self.RestartKlipperButton.setObjectName("RestartKlipperButton") + self.horizontalLayout.addWidget(self.RestartKlipperButton, 0, QtCore.Qt.AlignmentFlag.AlignHCenter|QtCore.Qt.AlignmentFlag.AlignTop) + self.RebootSystemButton = IconButton(parent=self.cw_buttonFrame) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.RebootSystemButton.sizePolicy().hasHeightForWidth()) + self.RebootSystemButton.setSizePolicy(sizePolicy) + self.RebootSystemButton.setMinimumSize(QtCore.QSize(154, 80)) + self.RebootSystemButton.setMaximumSize(QtCore.QSize(154, 80)) + self.RebootSystemButton.setBaseSize(QtCore.QSize(80, 80)) + self.RebootSystemButton.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.BlankCursor)) + self.RebootSystemButton.setTabletTracking(True) + self.RebootSystemButton.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus) + self.RebootSystemButton.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.NoContextMenu) + self.RebootSystemButton.setAutoFillBackground(False) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap(":/system_icons/media/btn_icons/firmware_restart.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) + self.RebootSystemButton.setIcon(icon1) + self.RebootSystemButton.setAutoDefault(False) + self.RebootSystemButton.setDefault(False) + self.RebootSystemButton.setFlat(True) + self.RebootSystemButton.setProperty("icon_pixmap", QtGui.QPixmap(":/system/media/btn_icons/reboot.svg")) + self.RebootSystemButton.setProperty("text_color", QtGui.QColor(255, 255, 255)) + self.RebootSystemButton.setProperty("has_text", True) + self.RebootSystemButton.setObjectName("RebootSystemButton") + self.horizontalLayout.addWidget(self.RebootSystemButton, 0, QtCore.Qt.AlignmentFlag.AlignHCenter|QtCore.Qt.AlignmentFlag.AlignTop) + self.FirmwareRestartButton = IconButton(parent=self.cw_buttonFrame) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.FirmwareRestartButton.sizePolicy().hasHeightForWidth()) + self.FirmwareRestartButton.setSizePolicy(sizePolicy) + self.FirmwareRestartButton.setMinimumSize(QtCore.QSize(154, 80)) + self.FirmwareRestartButton.setMaximumSize(QtCore.QSize(154, 80)) + self.FirmwareRestartButton.setBaseSize(QtCore.QSize(160, 80)) + self.FirmwareRestartButton.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.BlankCursor)) + self.FirmwareRestartButton.setTabletTracking(True) + self.FirmwareRestartButton.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus) + self.FirmwareRestartButton.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.NoContextMenu) + self.FirmwareRestartButton.setAutoFillBackground(False) + self.FirmwareRestartButton.setIcon(icon1) + self.FirmwareRestartButton.setAutoDefault(False) + self.FirmwareRestartButton.setDefault(False) + self.FirmwareRestartButton.setFlat(True) + self.FirmwareRestartButton.setProperty("icon_pixmap", QtGui.QPixmap(":/system/media/btn_icons/restart_firmware.svg")) + self.FirmwareRestartButton.setProperty("has_text", True) + self.FirmwareRestartButton.setProperty("text_color", QtGui.QColor(255, 255, 255)) + self.FirmwareRestartButton.setObjectName("FirmwareRestartButton") + self.horizontalLayout.addWidget(self.FirmwareRestartButton, 0, QtCore.Qt.AlignmentFlag.AlignHCenter|QtCore.Qt.AlignmentFlag.AlignTop) + self.RetryConnectionButton = IconButton(parent=self.cw_buttonFrame) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.RetryConnectionButton.sizePolicy().hasHeightForWidth()) + self.RetryConnectionButton.setSizePolicy(sizePolicy) + self.RetryConnectionButton.setMinimumSize(QtCore.QSize(154, 80)) + self.RetryConnectionButton.setMaximumSize(QtCore.QSize(154, 80)) + self.RetryConnectionButton.setBaseSize(QtCore.QSize(80, 80)) + palette = QtGui.QPalette() + self.RetryConnectionButton.setPalette(palette) + font = QtGui.QFont() + font.setPointSize(13) + self.RetryConnectionButton.setFont(font) + self.RetryConnectionButton.setTabletTracking(True) + self.RetryConnectionButton.setFocusPolicy(QtCore.Qt.FocusPolicy.ClickFocus) + self.RetryConnectionButton.setAutoFillBackground(False) + self.RetryConnectionButton.setStyleSheet("") + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap(":/system_icons/media/btn_icons/retry_connection.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) + self.RetryConnectionButton.setIcon(icon2) + self.RetryConnectionButton.setIconSize(QtCore.QSize(16, 16)) + self.RetryConnectionButton.setCheckable(False) + self.RetryConnectionButton.setAutoRepeatDelay(0) + self.RetryConnectionButton.setAutoRepeatInterval(0) + self.RetryConnectionButton.setAutoDefault(False) + self.RetryConnectionButton.setDefault(False) + self.RetryConnectionButton.setFlat(True) + self.RetryConnectionButton.setProperty("icon_pixmap", QtGui.QPixmap(":/system/media/btn_icons/restart_printer.svg")) + self.RetryConnectionButton.setProperty("text_color", QtGui.QColor(255, 255, 255)) + self.RetryConnectionButton.setProperty("has_text", True) + self.RetryConnectionButton.setObjectName("RetryConnectionButton") + self.horizontalLayout.addWidget(self.RetryConnectionButton, 0, QtCore.Qt.AlignmentFlag.AlignHCenter|QtCore.Qt.AlignmentFlag.AlignTop) + self.updatepageButton = IconButton(parent=self.cw_buttonFrame) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.updatepageButton.sizePolicy().hasHeightForWidth()) + self.updatepageButton.setSizePolicy(sizePolicy) + self.updatepageButton.setMinimumSize(QtCore.QSize(154, 80)) + self.updatepageButton.setMaximumSize(QtCore.QSize(154, 80)) + self.updatepageButton.setBaseSize(QtCore.QSize(80, 80)) + self.updatepageButton.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.BlankCursor)) + self.updatepageButton.setTabletTracking(True) + self.updatepageButton.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus) + self.updatepageButton.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.NoContextMenu) + self.updatepageButton.setAutoFillBackground(False) + self.updatepageButton.setIcon(icon1) + self.updatepageButton.setAutoDefault(False) + self.updatepageButton.setDefault(False) + self.updatepageButton.setFlat(True) + self.updatepageButton.setProperty("icon_pixmap", QtGui.QPixmap(":/system/media/btn_icons/update-software-icon.svg")) + self.updatepageButton.setProperty("text_color", QtGui.QColor(255, 255, 255)) + self.updatepageButton.setProperty("has_text", True) + self.updatepageButton.setObjectName("updatepageButton") + self.horizontalLayout.addWidget(self.updatepageButton, 0, QtCore.Qt.AlignmentFlag.AlignHCenter|QtCore.Qt.AlignmentFlag.AlignTop) + self.wifi_button = IconButton(parent=self.cw_buttonFrame) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.wifi_button.sizePolicy().hasHeightForWidth()) + self.wifi_button.setSizePolicy(sizePolicy) + self.wifi_button.setMinimumSize(QtCore.QSize(154, 80)) + self.wifi_button.setMaximumSize(QtCore.QSize(154, 80)) + self.wifi_button.setBaseSize(QtCore.QSize(80, 80)) + self.wifi_button.setTabletTracking(True) + self.wifi_button.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus) + self.wifi_button.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.NoContextMenu) + self.wifi_button.setAutoFillBackground(False) + self.wifi_button.setIcon(icon2) + self.wifi_button.setAutoDefault(False) + self.wifi_button.setDefault(False) + self.wifi_button.setFlat(True) + self.wifi_button.setProperty("icon_pixmap", QtGui.QPixmap(":/network/media/btn_icons/wifi_config.svg")) + self.wifi_button.setProperty("has_text", True) + self.wifi_button.setObjectName("wifi_button") + self.horizontalLayout.addWidget(self.wifi_button, 0, QtCore.Qt.AlignmentFlag.AlignHCenter|QtCore.Qt.AlignmentFlag.AlignTop) self.cw_Frame = QtWidgets.QFrame(parent=ConnectivityForm) self.cw_Frame.setGeometry(QtCore.QRect(0, 0, 800, 380)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Minimum) @@ -231,6 +252,7 @@ def setupUi(self, ConnectivityForm): self.cw_Frame.setMinimumSize(QtCore.QSize(800, 380)) self.cw_Frame.setMaximumSize(QtCore.QSize(800, 380)) self.cw_Frame.setAutoFillBackground(False) + self.cw_Frame.setStyleSheet("") self.cw_Frame.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.cw_Frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised) self.cw_Frame.setObjectName("cw_Frame") @@ -297,16 +319,18 @@ def setupUi(self, ConnectivityForm): def retranslateUi(self, ConnectivityForm): _translate = QtCore.QCoreApplication.translate ConnectivityForm.setWindowTitle(_translate("ConnectivityForm", "Form")) + self.RestartKlipperButton.setText(_translate("ConnectivityForm", "Restart Klipper")) + self.RestartKlipperButton.setProperty("text_formatting", _translate("ConnectivityForm", "bottom")) + self.RebootSystemButton.setText(_translate("ConnectivityForm", "Reboot")) + self.RebootSystemButton.setProperty("text_formatting", _translate("ConnectivityForm", "bottom")) + self.FirmwareRestartButton.setText(_translate("ConnectivityForm", "Firmware Restart")) + self.FirmwareRestartButton.setProperty("text_formatting", _translate("ConnectivityForm", "bottom")) self.RetryConnectionButton.setText(_translate("ConnectivityForm", "Retry ")) self.RetryConnectionButton.setProperty("text_formatting", _translate("ConnectivityForm", "bottom")) + self.updatepageButton.setText(_translate("ConnectivityForm", "Update page")) + self.updatepageButton.setProperty("text_formatting", _translate("ConnectivityForm", "bottom")) self.wifi_button.setText(_translate("ConnectivityForm", "Wifi Settings")) self.wifi_button.setProperty("class", _translate("ConnectivityForm", "system_control_btn")) self.wifi_button.setProperty("text_formatting", _translate("ConnectivityForm", "bottom")) - self.FirmwareRestartButton.setText(_translate("ConnectivityForm", "Firmware Restart")) - self.FirmwareRestartButton.setProperty("text_formatting", _translate("ConnectivityForm", "bottom")) - self.RebootSystemButton.setText(_translate("ConnectivityForm", "Reboot")) - self.RebootSystemButton.setProperty("text_formatting", _translate("ConnectivityForm", "bottom")) - self.RestartKlipperButton.setText(_translate("ConnectivityForm", "Restart Klipper")) - self.RestartKlipperButton.setProperty("text_formatting", _translate("ConnectivityForm", "bottom")) from lib.utils.blocks_frame import BlocksCustomFrame from lib.utils.icon_button import IconButton From d37b3293ad6da46653c4319583a26860e783b138 Mon Sep 17 00:00:00 2001 From: Roberto Date: Mon, 22 Dec 2025 11:11:43 +0000 Subject: [PATCH 2/4] ADD: added reload button to updatepage Refactor : evertime it reload shows loadwidget Refactor: info frame layout --- BlocksScreen/lib/panels/widgets/updatePage.py | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/BlocksScreen/lib/panels/widgets/updatePage.py b/BlocksScreen/lib/panels/widgets/updatePage.py index b4def035..ba208758 100644 --- a/BlocksScreen/lib/panels/widgets/updatePage.py +++ b/BlocksScreen/lib/panels/widgets/updatePage.py @@ -79,6 +79,7 @@ def __init__(self, parent=None) -> None: self.repeated_request_status.timeout.connect( lambda: self.request_update_status.emit(False) ) + self.reload_btn.clicked.connect(self.on_request_reload) self.setAttribute(QtCore.Qt.WidgetAttribute.WA_StyledBackground, True) self.show_loading(True) @@ -89,7 +90,7 @@ def handle_update_end(self) -> None: if self.load_popup.isVisible(): self.load_popup.close() self.repeated_request_status.stop() - self.request_refresh_update.emit() + self.on_request_reload() self.build_model_list() def handle_ongoing_update(self) -> None: @@ -100,6 +101,14 @@ def handle_ongoing_update(self) -> None: self.load_popup.show() self.repeated_request_status.start(2000) + def on_request_reload(self, service: str | None = None) -> None: + """Handles reload button click, requests update status refresh""" + self.show_loading(True) + if service: + self.request_refresh_update.emit([service]) + else: + self.request_refresh_update.emit() + def reset_view_model(self) -> None: """Clears items from ListView (Resets `QAbstractListModel` by clearing entries) @@ -176,8 +185,8 @@ def on_item_clicked(self, item: ListItem) -> None: self.selected_item = copy.copy(item) if item.text == "system": self.no_update_placeholder.hide() - self.remote_version_title.hide() - self.remote_version_tracking.hide() + self.remote_version_title.setText("") + self.remote_version_tracking.setText("") updatable_packages = cli_data.get("package_count", 0) if updatable_packages == 0: self.version_title.hide() @@ -196,6 +205,7 @@ def on_item_clicked(self, item: ListItem) -> None: self.remote_version_tracking.hide() self.remote_version_title.show() self.remote_version_tracking.show() + self.remote_version_title.setText("Remote Version: ") self.remote_version_tracking.setText(_remote_version) _curr_version = cli_data.get("version", None) if not _curr_version: @@ -233,8 +243,6 @@ def on_item_clicked(self, item: ListItem) -> None: def show_loading(self,loading:bool = False)->None: """Show or hide loading overlay""" self.loadwidget.setVisible(loading) - self.info_loadwidget.setVisible(loading) - self.info_loadwidget.setFixedSize(self.infobox_frame.size()) self.update_buttons_list_widget.setVisible(not loading) self.remote_version_title.setVisible(not loading) self.remote_version_tracking.setVisible(not loading) @@ -305,10 +313,6 @@ def _setupUI(self) -> None: self.setStyleSheet( """#updatePage { background-image: url(:/background/media/1st_background.png); - } - #updatePage, - #updatePage * { - border: 3px solid #ffffff; }""" ) self.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight) @@ -317,6 +321,14 @@ def _setupUI(self) -> None: self.header_content_layout = QtWidgets.QHBoxLayout() self.header_content_layout.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop) + self.reload_btn = IconButton(self) + self.reload_btn.setMinimumSize(QtCore.QSize(60, 60)) + self.reload_btn.setMaximumSize(QtCore.QSize(60, 60)) + self.reload_btn.setFlat(True) + self.reload_btn.setPixmap(QtGui.QPixmap(":/ui/media/btn_icons/refresh.svg")) + self.header_content_layout.addWidget(self.reload_btn)# alignment=QtCore.Qt.AlignmentFlag.AlignCenter) + + self.header_title = QtWidgets.QLabel(self) self.header_title.setMinimumSize(QtCore.QSize(100, 60)) self.header_title.setMaximumSize(QtCore.QSize(16777215, 60)) @@ -328,16 +340,20 @@ def _setupUI(self) -> None: self.header_title.setFont(font) self.header_title.setPalette(palette) self.header_title.setLayoutDirection(QtCore.Qt.LayoutDirection.RightToLeft) - self.header_title.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) self.header_title.setObjectName("header-title") self.header_title.setText("Update Manager") - self.header_content_layout.addWidget(self.header_title, 0) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Policy.Expanding, + QtWidgets.QSizePolicy.Policy.Expanding, + ) + self.header_title.setSizePolicy(sizePolicy) + self.header_content_layout.addWidget(self.header_title, alignment=QtCore.Qt.AlignmentFlag.AlignCenter) self.update_back_btn = IconButton(self) self.update_back_btn.setMinimumSize(QtCore.QSize(60, 60)) self.update_back_btn.setMaximumSize(QtCore.QSize(60, 60)) self.update_back_btn.setFlat(True) self.update_back_btn.setPixmap(QtGui.QPixmap(":/ui/media/btn_icons/back.svg")) - self.header_content_layout.addWidget(self.update_back_btn, 0) + self.header_content_layout.addWidget(self.update_back_btn) #alignment=QtCore.Qt.AlignmentFlag.AlignCenter) self.update_page_content_layout.addLayout(self.header_content_layout, 0) self.main_content_layout = QtWidgets.QHBoxLayout() @@ -514,8 +530,7 @@ def _setupUI(self) -> None: self.info_box_layout = QtWidgets.QVBoxLayout() self.info_box_layout.setContentsMargins(10, 10, 10, 10) self.infobox_frame.setLayout(self.info_box_layout) - self.info_loadwidget = LoadingOverlayWidget(self) - self.info_box_layout.addWidget(self.info_loadwidget, 0) + font = QtGui.QFont() font.setFamily(font_family) @@ -589,7 +604,7 @@ def _setupUI(self) -> None: self.action_btn = BlocksCustomButton() self.action_btn.setMinimumSize(QtCore.QSize(200, 60)) - self.action_btn.setMaximumSize(QtCore.QSize(250, 60)) + self.action_btn.setMaximumSize(QtCore.QSize(300, 60)) font.setPointSize(20) self.action_btn.setFont(font) self.action_btn.setPalette(palette) @@ -599,7 +614,7 @@ def _setupUI(self) -> None: QtGui.QPixmap(":/system/media/btn_icons/update-software-icon.svg") ) self.button_box.addWidget( - self.action_btn, 0, QtCore.Qt.AlignmentFlag.AlignHCenter + self.action_btn, 0, QtCore.Qt.AlignmentFlag.AlignCenter ) self.no_update_placeholder = QtWidgets.QLabel(self) self.no_update_placeholder.setMinimumSize(QtCore.QSize(200, 60)) From 79425c149e25bac53607b321f7e5f382c8176abc Mon Sep 17 00:00:00 2001 From: Roberto Date: Mon, 22 Dec 2025 11:38:41 +0000 Subject: [PATCH 3/4] Refactor: when update page gets refreshed --- BlocksScreen/lib/panels/widgets/connectionPage.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/BlocksScreen/lib/panels/widgets/connectionPage.py b/BlocksScreen/lib/panels/widgets/connectionPage.py index b6f835c7..9804c02f 100644 --- a/BlocksScreen/lib/panels/widgets/connectionPage.py +++ b/BlocksScreen/lib/panels/widgets/connectionPage.py @@ -38,10 +38,8 @@ def __init__(self, parent: QtWidgets.QWidget, ws: MoonWebSocket, /): lambda: {self.stack.setCurrentWidget(self.connection_widget)} ) self.panel.updatepageButton.clicked.connect( - lambda: { - self.stack.setCurrentWidget(self.up), - self.ws.api.refresh_update_status(), - } + lambda: + self.stack.setCurrentWidget(self.up) ) self.ws = ws @@ -97,6 +95,11 @@ def show_panel(self, reason: str | None = None): self.text_update() return False + def showEvent(self, a0: QtCore.QEvent|None): + """Handle show event""" + self.ws.api.refresh_update_status() + return super().showEvent(a0) + @QtCore.pyqtSlot(bool, name="on_klippy_connected") def on_klippy_connection(self, connected: bool): """Handle klippy connection state""" From 87566a3d3ef687329b4839f0cb88c6b1efdd39d8 Mon Sep 17 00:00:00 2001 From: Roberto Date: Mon, 22 Dec 2025 15:07:27 +0000 Subject: [PATCH 4/4] Added: icon_button pressed state Refactor: resized icon buttons on connectionwindow --- BlocksScreen/lib/ui/connectionWindow.ui | 28 ++++---- BlocksScreen/lib/ui/connectionWindow_ui.py | 28 ++++---- BlocksScreen/lib/utils/icon_button.py | 76 +++++++++++----------- 3 files changed, 67 insertions(+), 65 deletions(-) diff --git a/BlocksScreen/lib/ui/connectionWindow.ui b/BlocksScreen/lib/ui/connectionWindow.ui index 96a2179b..f2bd4899 100644 --- a/BlocksScreen/lib/ui/connectionWindow.ui +++ b/BlocksScreen/lib/ui/connectionWindow.ui @@ -41,7 +41,9 @@ false - #ConnectivityForm{background-image: url(:/background/media/1st_background.png);} + #ConnectivityForm{ +background-image: url(:/background/media/1st_background.png); +} @@ -135,13 +137,13 @@ - 154 + 100 80 - 154 + 100 80 @@ -333,13 +335,13 @@ - 154 + 100 80 - 154 + 100 80 @@ -408,13 +410,13 @@ - 154 + 100 80 - 154 + 100 80 @@ -483,13 +485,13 @@ - 154 + 100 80 - 154 + 100 80 @@ -582,13 +584,13 @@ - 154 + 100 80 - 154 + 100 80 @@ -657,13 +659,13 @@ - 154 + 100 80 - 154 + 100 80 diff --git a/BlocksScreen/lib/ui/connectionWindow_ui.py b/BlocksScreen/lib/ui/connectionWindow_ui.py index caca54fa..772dc227 100644 --- a/BlocksScreen/lib/ui/connectionWindow_ui.py +++ b/BlocksScreen/lib/ui/connectionWindow_ui.py @@ -23,7 +23,9 @@ def setupUi(self, ConnectivityForm): ConnectivityForm.setMaximumSize(QtCore.QSize(800, 480)) ConnectivityForm.setWindowOpacity(1.0) ConnectivityForm.setAutoFillBackground(False) - ConnectivityForm.setStyleSheet("#ConnectivityForm{background-image: url(:/background/media/1st_background.png);}") + ConnectivityForm.setStyleSheet("#ConnectivityForm{\n" +"background-image: url(:/background/media/1st_background.png);\n" +"}") ConnectivityForm.setProperty("class", "") self.cw_buttonFrame = BlocksCustomFrame(parent=ConnectivityForm) self.cw_buttonFrame.setGeometry(QtCore.QRect(10, 380, 780, 124)) @@ -57,8 +59,8 @@ def setupUi(self, ConnectivityForm): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.RestartKlipperButton.sizePolicy().hasHeightForWidth()) self.RestartKlipperButton.setSizePolicy(sizePolicy) - self.RestartKlipperButton.setMinimumSize(QtCore.QSize(154, 80)) - self.RestartKlipperButton.setMaximumSize(QtCore.QSize(154, 80)) + self.RestartKlipperButton.setMinimumSize(QtCore.QSize(100, 80)) + self.RestartKlipperButton.setMaximumSize(QtCore.QSize(100, 80)) self.RestartKlipperButton.setBaseSize(QtCore.QSize(160, 80)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(66, 66, 66)) @@ -123,8 +125,8 @@ def setupUi(self, ConnectivityForm): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.RebootSystemButton.sizePolicy().hasHeightForWidth()) self.RebootSystemButton.setSizePolicy(sizePolicy) - self.RebootSystemButton.setMinimumSize(QtCore.QSize(154, 80)) - self.RebootSystemButton.setMaximumSize(QtCore.QSize(154, 80)) + self.RebootSystemButton.setMinimumSize(QtCore.QSize(100, 80)) + self.RebootSystemButton.setMaximumSize(QtCore.QSize(100, 80)) self.RebootSystemButton.setBaseSize(QtCore.QSize(80, 80)) self.RebootSystemButton.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.BlankCursor)) self.RebootSystemButton.setTabletTracking(True) @@ -148,8 +150,8 @@ def setupUi(self, ConnectivityForm): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.FirmwareRestartButton.sizePolicy().hasHeightForWidth()) self.FirmwareRestartButton.setSizePolicy(sizePolicy) - self.FirmwareRestartButton.setMinimumSize(QtCore.QSize(154, 80)) - self.FirmwareRestartButton.setMaximumSize(QtCore.QSize(154, 80)) + self.FirmwareRestartButton.setMinimumSize(QtCore.QSize(100, 80)) + self.FirmwareRestartButton.setMaximumSize(QtCore.QSize(100, 80)) self.FirmwareRestartButton.setBaseSize(QtCore.QSize(160, 80)) self.FirmwareRestartButton.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.BlankCursor)) self.FirmwareRestartButton.setTabletTracking(True) @@ -171,8 +173,8 @@ def setupUi(self, ConnectivityForm): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.RetryConnectionButton.sizePolicy().hasHeightForWidth()) self.RetryConnectionButton.setSizePolicy(sizePolicy) - self.RetryConnectionButton.setMinimumSize(QtCore.QSize(154, 80)) - self.RetryConnectionButton.setMaximumSize(QtCore.QSize(154, 80)) + self.RetryConnectionButton.setMinimumSize(QtCore.QSize(100, 80)) + self.RetryConnectionButton.setMaximumSize(QtCore.QSize(100, 80)) self.RetryConnectionButton.setBaseSize(QtCore.QSize(80, 80)) palette = QtGui.QPalette() self.RetryConnectionButton.setPalette(palette) @@ -204,8 +206,8 @@ def setupUi(self, ConnectivityForm): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.updatepageButton.sizePolicy().hasHeightForWidth()) self.updatepageButton.setSizePolicy(sizePolicy) - self.updatepageButton.setMinimumSize(QtCore.QSize(154, 80)) - self.updatepageButton.setMaximumSize(QtCore.QSize(154, 80)) + self.updatepageButton.setMinimumSize(QtCore.QSize(100, 80)) + self.updatepageButton.setMaximumSize(QtCore.QSize(100, 80)) self.updatepageButton.setBaseSize(QtCore.QSize(80, 80)) self.updatepageButton.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.BlankCursor)) self.updatepageButton.setTabletTracking(True) @@ -227,8 +229,8 @@ def setupUi(self, ConnectivityForm): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.wifi_button.sizePolicy().hasHeightForWidth()) self.wifi_button.setSizePolicy(sizePolicy) - self.wifi_button.setMinimumSize(QtCore.QSize(154, 80)) - self.wifi_button.setMaximumSize(QtCore.QSize(154, 80)) + self.wifi_button.setMinimumSize(QtCore.QSize(100, 80)) + self.wifi_button.setMaximumSize(QtCore.QSize(100, 80)) self.wifi_button.setBaseSize(QtCore.QSize(80, 80)) self.wifi_button.setTabletTracking(True) self.wifi_button.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus) diff --git a/BlocksScreen/lib/utils/icon_button.py b/BlocksScreen/lib/utils/icon_button.py index a60a7f1d..beb85dc1 100644 --- a/BlocksScreen/lib/utils/icon_button.py +++ b/BlocksScreen/lib/utils/icon_button.py @@ -3,7 +3,7 @@ class IconButton(QtWidgets.QPushButton): - def __init__(self, parent: QtWidgets.QWidget) -> None: + def __init__(self, parent: QtWidgets.QWidget = None) -> None: super().__init__(parent) self.icon_pixmap: QtGui.QPixmap = QtGui.QPixmap() @@ -13,7 +13,7 @@ def __init__(self, parent: QtWidgets.QWidget) -> None: self._name: str = "" self.text_color: QtGui.QColor = QtGui.QColor(255, 255, 255) self.setAttribute(QtCore.Qt.WidgetAttribute.WA_AcceptTouchEvents, True) - + self.pressed_bg_color = QtGui.QColor(223, 223, 223,70) # Set to solid white @property def name(self): """Widget name""" @@ -42,6 +42,10 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None: painter.setRenderHint(painter.RenderHint.SmoothPixmapTransform, True) painter.setRenderHint(painter.RenderHint.LosslessImageRendering, True) + if self.isDown(): + painter.setBrush(QtGui.QBrush(self.pressed_bg_color)) + painter.setPen(QtCore.Qt.PenStyle.NoPen) + painter.drawRoundedRect(self.rect().toRectF(), 6, 6) _pen = QtGui.QPen() _pen.setStyle(QtCore.Qt.PenStyle.NoPen) _pen.setColor(self.text_color) @@ -49,38 +53,34 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None: painter.setPen(_pen) - # bg_color = ( - # QtGui.QColor(164, 164, 164) - # if self.isDown() - # else QtGui.QColor(223, 223, 223) - # ) - - # * Build icon - x = y = 15.0 if self.text_formatting else 5.0 - _icon_rect = QtCore.QRectF(0.0, 0.0, (self.width() - x), (self.height() - y)) - - _icon_scaled = self.icon_pixmap.scaled( - _icon_rect.size().toSize(), - QtCore.Qt.AspectRatioMode.KeepAspectRatio, - QtCore.Qt.TransformationMode.SmoothTransformation, - ) - # Calculate the actual QRect for the scaled pixmap (centering it if needed) - scaled_width = _icon_scaled.width() - scaled_height = _icon_scaled.height() - adjusted_x = (_icon_rect.width() - scaled_width) / 2.0 - adjusted_y = (_icon_rect.height() - scaled_height) / 2.0 - adjusted_icon_rect = QtCore.QRectF( - _icon_rect.x() + adjusted_x, - _icon_rect.y() + adjusted_y, - scaled_width, - scaled_height, - ) - - painter.drawPixmap( - adjusted_icon_rect, # Target area (center adjusted) - _icon_scaled, # Scaled pixmap - _icon_scaled.rect().toRectF(), # Entire source (scaled) pixmap - ) + y = 15.0 if self.text_formatting else 5.0 + if self.isDown(): + _icon_rect = QtCore.QRectF(2.5, 2.5, (self.width() - 5 ), (self.height() - 5 - y)) + else: + _icon_rect = QtCore.QRectF(0.0, 0.0, (self.width()), (self.height() - y)) + + if not self.icon_pixmap.isNull(): + _icon_scaled = self.icon_pixmap.scaled( + _icon_rect.size().toSize(), + QtCore.Qt.AspectRatioMode.KeepAspectRatio, + QtCore.Qt.TransformationMode.SmoothTransformation, + ) + scaled_width = _icon_scaled.width() + scaled_height = _icon_scaled.height() + adjusted_x = (_icon_rect.width() - scaled_width) / 2.0 + adjusted_y = (_icon_rect.height() - scaled_height) / 2.0 + adjusted_icon_rect = QtCore.QRectF( + _icon_rect.x() + adjusted_x, + _icon_rect.y() + adjusted_y, + scaled_width, + scaled_height, + ) + + painter.drawPixmap( + adjusted_icon_rect, + _icon_scaled, + _icon_scaled.rect().toRectF(), + ) if self.has_text: painter.setCompositionMode( @@ -99,9 +99,9 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None: scaled_height, ) elif self.text_formatting == "bottom": - adjusted_x = (_icon_rect.width() - self.width() + 5.0) / 2.0 + # adjusted_x = 0#(_icon_rect.width() - self.width() + 5.0) / 2.0 adjusted_rectF = QtCore.QRectF( - _icon_rect.x() + adjusted_x, + 0, _icon_rect.height(), self.width(), self.height() - _icon_rect.height(), @@ -113,11 +113,9 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None: painter.drawText( adjusted_rectF, QtCore.Qt.TextFlag.TextSingleLine - | QtCore.Qt.AlignmentFlag.AlignHCenter - | QtCore.Qt.AlignmentFlag.AlignVCenter, + | QtCore.Qt.AlignmentFlag.AlignCenter, str(self.text()), ) - painter.setPen(QtCore.Qt.PenStyle.NoPen) painter.end()