Skip to content

Commit

Permalink
Merge pull request #78 from Thisal-D/v5.0.1
Browse files Browse the repository at this point in the history
v5.0.1
  • Loading branch information
Thisal-D authored Jan 7, 2025
2 parents ba02205 + a8710ea commit ce2de89
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '5.0.0'
VERSION = '5.0.1'
2 changes: 1 addition & 1 deletion utils/settings_validate_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ def validate_chunk_size_value(value: str) -> bool:

# Validate the range in bytes
min_size = 50 * 1024 # 50KB in bytes
max_size = 100 * 1024 * 1024 # 100MB in bytes
max_size = 11 * 1024 * 1024 # 11MB in bytes

return min_size <= size_in_bytes <= max_size
16 changes: 11 additions & 5 deletions widgets/setting_panels/downloads_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(
master=self,
command=self.change_chunk_size,
from_=51200, # 50KB
to=104857600,
to=11534336,
)

self.chunk_size_value_entry = ctk.CTkEntry(
Expand Down Expand Up @@ -181,6 +181,7 @@ def __init__(

# track values validity
self.download_path_valid: bool = True
self.chunk_size_valid: bool = True

self.chunk_size_entry_previous_value: str = ""

Expand Down Expand Up @@ -221,7 +222,7 @@ def set_value_to_entry(self, entry: ctk.CTkEntry, value: str) -> None:

def cancel_chunk_size_settings_resetting(self):
self.chunk_size_change_slider.set(GeneralSettings.settings["chunk_size"])
self.set_value_to_entry(self.chunk_size_value_entry, f"{ValueConvertUtility.convert_size(GeneralSettings.settings["chunk_size"], decimal_points=2)}")
self.set_value_to_entry(self.chunk_size_value_entry, f"{ValueConvertUtility.convert_size(GeneralSettings.settings["chunk_size"], decimal_points=3)}")
self.chunk_size_changed = False

def set_downloads_settings(self):
Expand Down Expand Up @@ -259,13 +260,14 @@ def set_apply_button_state(self):
self.create_sep_path_for_playlists_state_changed, self.create_sep_path_for_qualities_state_changed,
self.chunk_size_changed))
and
all((self.download_path_valid,))):
all((self.download_path_valid, self.chunk_size_valid))):
self.apply_changes_button.configure(state="normal")
else:
self.apply_changes_button.configure(state="disabled")

def change_chunk_size(self, chunk_size: int | float) -> None:
self.set_value_to_entry(self.chunk_size_value_entry, f"{ValueConvertUtility.convert_size(chunk_size, decimal_points=2)}")
self.chunk_size_valid = True
self.set_value_to_entry(self.chunk_size_value_entry, f"{ValueConvertUtility.convert_size(chunk_size, decimal_points=3)}")
if chunk_size != GeneralSettings.settings["chunk_size"]:
self.chunk_size_changed = True
else:
Expand All @@ -280,9 +282,13 @@ def validate_chunk_size_value(self, _event):
text = self.chunk_size_value_entry.get()
value = text.strip().replace(" ", "")
if SettingsValidateUtility.validate_chunk_size_value(value):
self.chunk_size_valid = True
value = ValueConvertUtility.MB_KB_to_Bytes(value)
self.chunk_size_change_slider.set(value)
self.change_chunk_size(value)
else:
self.chunk_size_valid = False
self.set_apply_button_state()

def download_path_validate(self, _event):
path = FileUtility.format_path(self.download_path_entry.get())
Expand Down Expand Up @@ -351,7 +357,7 @@ def configure_values(self):
self.create_sep_path_for_playlists_switch_state.set(False)

self.chunk_size_change_slider.set(GeneralSettings.settings["chunk_size"])
self.set_value_to_entry(self.chunk_size_value_entry, f"{ValueConvertUtility.convert_size(GeneralSettings.settings["chunk_size"],decimal_points=2)}")
self.set_value_to_entry(self.chunk_size_value_entry, f"{ValueConvertUtility.convert_size(GeneralSettings.settings["chunk_size"],decimal_points=3)}")

def bind_widgets_events(self):
self.download_path_entry.bind("<KeyRelease>", self.download_path_validate)
Expand Down

0 comments on commit ce2de89

Please sign in to comment.