Skip to content

Commit 319610a

Browse files
authored
Merge branch 'dev' into bugfix/fans-button-not-clickable
2 parents 563f31e + d013f12 commit 319610a

14 files changed

Lines changed: 1096 additions & 929 deletions

‎BlocksScreen/helper_methods.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,32 @@ def check_file_on_path(
324324
"""Check if file exists on path. Returns true if file exists on that specified directory"""
325325
_filepath = os.path.join(path, filename)
326326
return os.path.exists(_filepath)
327+
328+
329+
def get_file_loc(filename) -> pathlib.Path: ...
330+
331+
332+
def get_file_name(filename: typing.Optional[str]) -> str:
333+
# If filename is None or empty, return empty string instead of None
334+
if not filename:
335+
return ""
336+
# Remove trailing slashes or backslashes
337+
filename = filename.rstrip("/\\")
338+
339+
# Normalize Windows backslashes to forward slashes
340+
filename = filename.replace("\\", "/")
341+
342+
parts = filename.split("/")
343+
344+
# Split and return the last path component
345+
return parts[-1] if filename else ""
346+
347+
348+
# def get_hash(data) -> hashlib._Hash:
349+
# hash = hashlib.sha256()
350+
# hash.update(data.encode())
351+
# hash.digest()
352+
# return hash
353+
354+
355+
def digest_hash() -> None: ...

‎BlocksScreen/lib/files.py‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ def __init__(
5454

5555
@property
5656
def file_list(self):
57-
"""Get the current list of files"""
57+
"""Available files list"""
5858
return self.files
5959

6060
def handle_message_received(self, method: str, data, params: dict) -> None:
6161
"""Handle file related messages received by moonraker"""
6262
if "server.files.list" in method:
63-
# Get all files in root and its subdirectories and
64-
# request their metadata
6563
self.files.clear()
6664
self.files = data
6765
[self.request_file_metadata.emit(item["path"]) for item in self.files]
@@ -73,8 +71,6 @@ def handle_message_received(self, method: str, data, params: dict) -> None:
7371
else:
7472
self.files_metadata[data["filename"]] = data
7573
elif "server.files.get_directory" in method:
76-
# Emit here the files for each directory so the
77-
# ui can build the files list
7874
self.directories = data.get("dirs", {})
7975
self.files.clear()
8076
self.files = data.get("files", [])
@@ -99,7 +95,7 @@ def on_request_fileinfo(self, filename: str) -> None:
9995
"""Requests metadata for a file
10096
10197
Args:
102-
filename (str): file
98+
filename (str): file to get metadata from
10399
"""
104100
_data: dict = {
105101
"thumbnail_images": list,
@@ -134,7 +130,6 @@ def on_request_fileinfo(self, filename: str) -> None:
134130
)
135131
_thumbnail_images = list(map(lambda path: QtGui.QImage(path), _thumbnail_paths))
136132
_data.update({"thumbnail_images": _thumbnail_images})
137-
138133
_data.update({"filament_total": _file_metadata.get("filament_total", "?")})
139134
_data.update({"estimated_time": _file_metadata.get("estimated_time", 0)})
140135
_data.update({"layer_count": _file_metadata.get("layer_count", -1.0)})
@@ -165,18 +160,15 @@ def on_request_fileinfo(self, filename: str) -> None:
165160
self.fileinfo.emit(_data)
166161

167162
def eventFilter(self, a0: QtCore.QObject, a1: QtCore.QEvent) -> bool:
168-
"""Filter Klippy related events"""
163+
"""Handle Websocket and Klippy events"""
164+
if a1.type() == events.WebSocketOpen.type():
165+
self.request_file_list.emit()
166+
self.request_dir_info[str, bool].emit("", False)
167+
return False
169168
if a1.type() == events.KlippyDisconnected.type():
170169
self.files_metadata.clear()
171170
self.files.clear()
172171
return False
173-
if a1.type() == events.KlippyReady.type():
174-
# Request all files including in subdirectories
175-
# in order to get all metadata
176-
self.request_file_list.emit()
177-
# List and directory build is depended only on this signal
178-
self.request_dir_info[str, bool].emit("", False)
179-
return False
180172
return super().eventFilter(a0, a1)
181173

182174
def event(self, a0: QtCore.QEvent) -> bool:

‎BlocksScreen/lib/panels/widgets/babystepPage.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from lib.utils.blocks_button import BlocksCustomButton
44
from lib.utils.blocks_label import BlocksLabel
55
from lib.utils.icon_button import IconButton
6-
from lib.utils.group_button import GroupButton
6+
from lib.utils.check_button import BlocksCustomCheckButton
77
from PyQt6 import QtCore, QtGui, QtWidgets
88

99

@@ -212,7 +212,7 @@ def setupUI(self):
212212
self.bbp_offset_steps_buttons.setObjectName("bbp_offset_steps_buttons")
213213

214214
# 0.1mm button
215-
self.bbp_nozzle_offset_1 = GroupButton(
215+
self.bbp_nozzle_offset_1 = BlocksCustomCheckButton(
216216
parent=self.bbp_offset_steps_buttons_group_box
217217
)
218218
self.bbp_nozzle_offset_1.setMinimumSize(QtCore.QSize(100, 70))
@@ -237,7 +237,7 @@ def setupUI(self):
237237
# Line separator for 0.1mm - set size policy to expanding horizontally
238238

239239
# 0.01mm button
240-
self.bbp_nozzle_offset_01 = GroupButton(
240+
self.bbp_nozzle_offset_01 = BlocksCustomCheckButton(
241241
parent=self.bbp_offset_steps_buttons_group_box
242242
)
243243
self.bbp_nozzle_offset_01.setMinimumSize(QtCore.QSize(100, 70))
@@ -261,7 +261,7 @@ def setupUI(self):
261261
)
262262

263263
# 0.05mm button
264-
self.bbp_nozzle_offset_05 = GroupButton(
264+
self.bbp_nozzle_offset_05 = BlocksCustomCheckButton(
265265
parent=self.bbp_offset_steps_buttons_group_box
266266
)
267267
self.bbp_nozzle_offset_05.setMinimumSize(QtCore.QSize(100, 70))
@@ -285,7 +285,7 @@ def setupUI(self):
285285
)
286286

287287
# 0.025mm button
288-
self.bbp_nozzle_offset_025 = GroupButton(
288+
self.bbp_nozzle_offset_025 = BlocksCustomCheckButton(
289289
parent=self.bbp_offset_steps_buttons_group_box
290290
)
291291
self.bbp_nozzle_offset_025.setMinimumSize(QtCore.QSize(100, 70))

‎BlocksScreen/lib/panels/widgets/confirmPage.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class ConfirmWidget(QtWidgets.QWidget):
1313
on_accept: typing.ClassVar[QtCore.pyqtSignal] = QtCore.pyqtSignal(
14-
str, list, name="on_accept"
14+
str, name="on_accept"
1515
)
1616
request_back: typing.ClassVar[QtCore.pyqtSignal] = QtCore.pyqtSignal(
1717
name="request-back"
@@ -31,7 +31,7 @@ def __init__(self, parent) -> None:
3131
self.filename = ""
3232
self.confirm_button.clicked.connect(
3333
lambda: self.on_accept.emit(
34-
str(os.path.join(self.directory, self.filename)), self._thumbnails
34+
str(os.path.join(self.directory, self.filename))
3535
)
3636
)
3737
self.back_btn.clicked.connect(self.request_back.emit)

0 commit comments

Comments
 (0)