Skip to content
Open
1 change: 1 addition & 0 deletions BlocksScreen/lib/panels/controlTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(
self.printer: Printer = printer
self.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight)
self.timers = []
self.ztilt_state = False
self.extruder_info: dict = {}
self.bed_info: dict = {}
self.toolhead_info: dict = {}
Expand Down
44 changes: 24 additions & 20 deletions BlocksScreen/lib/panels/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from lib.moonrakerComm import MoonWebSocket
from lib.panels.controlTab import ControlTab
from lib.panels.filamentTab import FilamentTab
from lib.panels.widgets.notificationPage import NotificationPage
from lib.panels.networkWindow import NetworkControlWindow
from lib.panels.printTab import PrintTab
from lib.panels.utilitiesTab import UtilitiesTab
from lib.panels.widgets.connectionPage import ConnectionPage
from lib.panels.widgets.popupDialogWidget import Popup
from lib.printer import Printer
from lib.ui.mainWindow_ui import Ui_MainWindow # With header
from lib.panels.widgets.updatePage import UpdatePage
Expand Down Expand Up @@ -61,10 +61,15 @@ class MainWindow(QtWidgets.QMainWindow):
gcode_response = QtCore.pyqtSignal(list, name="gcode_response")
handle_error_response = QtCore.pyqtSignal(list, name="handle_error_response")
call_network_panel = QtCore.pyqtSignal(name="call-network-panel")
call_notification_panel = QtCore.pyqtSignal(name="call-notification-panel")
call_update_panel = QtCore.pyqtSignal(name="call-update-panel")
on_update_message: typing.ClassVar[QtCore.pyqtSignal] = QtCore.pyqtSignal(
dict, name="on-update-message"
)
show_notifications: typing.ClassVar[QtCore.pyqtSignal] = QtCore.pyqtSignal(
str, str, int, bool, name="show-notifications"
)

call_load_panel = QtCore.pyqtSignal(bool, str, name="call-load-panel")

def __init__(self):
Expand All @@ -75,8 +80,8 @@ def __init__(self):
self.screensaver = ScreenSaver(self)
self._popup_toggle: bool = False
self.ui.main_content_widget.setCurrentIndex(0)
self.popup = Popup(self)
self.ws = MoonWebSocket(self)
self.notiPage = NotificationPage(self)
self.mc = MachineControl(self)
self.file_data = Files(self, self.ws)
self.index_stack = deque(maxlen=4)
Expand Down Expand Up @@ -104,6 +109,8 @@ def __init__(self):
self.printPanel.request_back.connect(slot=self.global_back)
self.printPanel.on_cancel_print.connect(slot=self.on_cancel_print)

self.show_notifications.connect(self.notiPage.new_notication)

self.printPanel.request_change_page.connect(slot=self.global_change_page)
self.filamentPanel.request_back.connect(slot=self.global_back)
self.filamentPanel.request_change_page.connect(slot=self.global_change_page)
Expand All @@ -112,6 +119,7 @@ def __init__(self):
self.utilitiesPanel.request_back.connect(slot=self.global_back)
self.utilitiesPanel.request_change_page.connect(slot=self.global_change_page)
self.utilitiesPanel.update_available.connect(self.on_update_available)
self.ui.notification_btn.clicked.connect(self.notiPage.show_notification_panel)
self.ui.extruder_temp_display.clicked.connect(
lambda: self.global_change_page(
self.ui.main_content_widget.indexOf(self.ui.controlTab),
Expand Down Expand Up @@ -154,7 +162,11 @@ def __init__(self):
self.printer.heater_bed_update.connect(self.on_heater_bed_update)
self.ui.main_content_widget.currentChanged.connect(slot=self.reset_tab_indexes)
self.call_network_panel.connect(self.networkPanel.show_network_panel)
self.call_notification_panel.connect(self.notiPage.show_notification_panel)
self.conn_window.wifi_button_clicked.connect(self.call_network_panel.emit)
self.conn_window.notification_btn_clicked.connect(
self.call_notification_panel.emit
)
self.ui.wifi_button.clicked.connect(self.call_network_panel.emit)
self.handle_error_response.connect(
self.controlPanel.probe_helper_page.handle_error_response
Expand Down Expand Up @@ -591,9 +603,13 @@ def _handle_notify_service_state_changed_message(
return
service_entry: dict = entry[0]
service_name, service_info = service_entry.popitem()
self.popup.new_message(
message_type=Popup.MessageType.INFO,
message=f"{service_name} service changed state to \n{service_info.get('sub_state')}",
self.show_notifications.emit(
"mainwindow",
str(
f"{service_name} service changed state to \n{service_info.get('sub_state')}"
),
1,
False,
)

@api_handler
Expand All @@ -608,12 +624,7 @@ def _handle_notify_gcode_response_message(self, method, data, metadata) -> None:
popupWhitelist = ["filament runout", "no filament"]
if _message.lower() not in popupWhitelist or _gcode_msg_type != "!!":
return

self.popup.new_message(
message_type=Popup.MessageType.ERROR,
message=str(_message),
userInput=True,
)
self.show_notifications.emit("mainwindow", _message, 3, True)

@api_handler
def _handle_error_message(self, method, data, metadata) -> None:
Expand All @@ -630,21 +641,14 @@ def _handle_error_message(self, method, data, metadata) -> None:
text = f"{data['message']}"
else:
text = data
self.popup.new_message(
message_type=Popup.MessageType.ERROR,
message=str(text),
userInput=True,
)
self.show_notifications.emit("mainwindow", str(text), 3, True)

@api_handler
def _handle_notify_cpu_throttled_message(self, method, data, metadata) -> None:
"""Handle websocket cpu throttled messages"""
if self._popup_toggle:
return
self.popup.new_message(
message_type=Popup.MessageType.WARNING,
message=f"CPU THROTTLED: {data} | {metadata}",
)
self.show_notifications.emit("mainwindow", data, 2, False)

@api_handler
def _handle_notify_status_update_message(self, method, data, metadata) -> None:
Expand Down
2 changes: 2 additions & 0 deletions BlocksScreen/lib/panels/widgets/connectionPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ConnectionPage(QtWidgets.QFrame):
restart_klipper_clicked = QtCore.pyqtSignal(name="restart_klipper_clicked")
firmware_restart_clicked = QtCore.pyqtSignal(name="firmware_restart_clicked")
update_button_clicked = QtCore.pyqtSignal(bool, name="show-update-page")
notification_btn_clicked = QtCore.pyqtSignal(name="notification_btn_clicked")
call_load_panel = QtCore.pyqtSignal(bool, str, name="call-load-panel")

def __init__(self, parent: QtWidgets.QWidget, ws: MoonWebSocket, /):
Expand Down Expand Up @@ -43,6 +44,7 @@ def __init__(self, parent: QtWidgets.QWidget, ws: MoonWebSocket, /):
self.retry_connection_clicked.emit
)
self.panel.wifi_button.clicked.connect(self.wifi_button_clicked.emit)
self.panel.notification_btn.clicked.connect(self.notification_btn_clicked.emit)
self.panel.FirmwareRestartButton.clicked.connect(
self.firmware_restart_clicked.emit
)
Expand Down
Loading
Loading