commit part 1 canvas edit right left on default settings

This commit is contained in:
2025-08-27 23:43:32 +02:00
parent 1b4fcc8a1c
commit 6d55a476fd
9 changed files with 61 additions and 36 deletions

View File

@@ -204,10 +204,13 @@ class Msg:
"back": _("Back"),
"active": _("Active"),
"source": _("Source"),
"select_source": _("Select Source"),
"sources": _("Sources"),
"destination": _("Destination"),
"system_backup_info": _("System Backup"),
"system_restore_info": _("System Restore"),
"system_restore": _("System Restore"),
"select_source_first": _("Please select a source first"),
"user_backup_info": _("User Backup"),
"user_restore_info": _("User Restore"),
"select_destination_first": _("Please select a destination first"),

View File

@@ -249,14 +249,9 @@ class MainApplication(tk.Tk):
target_label_frame, text="0.00 GB / 0.00 GB")
self.target_size_label.pack(side=tk.RIGHT)
self.restore_size_frame = ttk.Frame(self.content_frame)
self.restore_size_frame.grid(row=4, column=0, sticky="ew", padx=10, pady=5, rowspan=2)
self.restore_size_frame.grid_columnconfigure(0, weight=1)
self.restore_size_frame.grid_remove()
self.restore_size_frame_before = ttk.LabelFrame(
self.restore_size_frame, text="Before Restoration", padding=10)
self.restore_size_frame_before.grid(row=0, column=0, sticky="ew", padx=10, pady=5)
self.content_frame, text="Before Restoration", padding=10)
self.restore_size_frame_before.grid(row=4, column=0, sticky="ew", padx=10, pady=5)
self.restore_size_frame_before.grid_columnconfigure(0, weight=1)
self.restore_size_canvas_before = tk.Canvas(
@@ -270,8 +265,8 @@ class MainApplication(tk.Tk):
self.restore_size_label_before.pack(side=tk.RIGHT)
self.restore_size_frame_after = ttk.LabelFrame(
self.restore_size_frame, text="After Restoration", padding=10)
self.restore_size_frame_after.grid(row=1, column=0, sticky="ew", padx=10, pady=5)
self.content_frame, text="After Restoration", padding=10)
self.restore_size_frame_after.grid(row=5, column=0, sticky="ew", padx=10, pady=5)
self.restore_size_frame_after.grid_columnconfigure(0, weight=1)
self.restore_size_canvas_after = tk.Canvas(
@@ -289,6 +284,9 @@ class MainApplication(tk.Tk):
restore_label_frame_after, text="")
self.restore_size_label_diff.pack(side=tk.RIGHT)
self.restore_size_frame_before.grid_remove()
self.restore_size_frame_after.grid_remove()
self._load_state_and_initialize()
self.update_backup_options_from_config() # Add this call
self.protocol("WM_DELETE_WINDOW", self.on_closing)
@@ -351,10 +349,6 @@ class MainApplication(tk.Tk):
'folder', 'Computer')
self.after(100, self.actions.on_sidebar_button_click,
restore_dest_folder)
else:
# Default action if no specific state to restore
self.after(100, self.actions.on_sidebar_button_click, "Computer")
self.data_processing.process_queue()
def _setup_log_window(self):

View File

@@ -100,6 +100,18 @@ class Actions:
self.app.drawing.redraw_left_canvas()
return
if self.app.mode == 'restore' and not self.app.right_canvas_data.get('path_display'):
self.app.left_canvas_data.update({
'icon': icon_name,
'folder': button_text,
'path_display': folder_path,
'size': Msg.STR["select_source_first"],
'calculating': False,
'extra_info': extra_info
})
self.app.drawing.redraw_left_canvas()
return
if self.app.calculation_thread and self.app.calculation_thread.is_alive():
self.app.calculation_stop_event.set()
@@ -237,7 +249,10 @@ class Actions:
self.app.start_pause_button.config(state="disabled")
# Clear the canvases and reset the UI to its initial state for the current mode
self.app.drawing.reset_all_canvases()
self.app.backup_left_canvas_data.clear()
self.app.backup_right_canvas_data.clear()
self.app.restore_left_canvas_data.clear()
self.app.restore_right_canvas_data.clear()
with message_box_animation(self.app.animated_icon):
MessageDialog(master=self.app, message_type="info",

View File

@@ -14,9 +14,9 @@ class Navigation:
self.app.calculation_stop_event.set()
if self.app.right_calculation_thread and self.app.right_calculation_thread.is_alive():
self.app.right_calculation_stop_event.set()
# Stop all calculation animations and update UI
self.app.drawing._stop_calculating_animation() # Stops both left and right
self.app.drawing._stop_calculating_animation() # Stops both left and right
if self.app.left_canvas_data:
self.app.left_canvas_data['calculating'] = False
if self.app.right_canvas_data:
@@ -35,7 +35,8 @@ class Navigation:
active_index = 0
# Restore backup destination disk metrics
backup_dest_path = self.app.backup_right_canvas_data.get('path_display')
backup_dest_path = self.app.backup_right_canvas_data.get(
'path_display')
if backup_dest_path and os.path.isdir(backup_dest_path):
try:
total, used, free = shutil.disk_usage(backup_dest_path)
@@ -54,7 +55,8 @@ class Navigation:
active_index = 1
# Restore restore destination disk metrics
restore_dest_path = self.app.restore_left_canvas_data.get('path_display')
restore_dest_path = self.app.restore_left_canvas_data.get(
'path_display')
if restore_dest_path and os.path.isdir(restore_dest_path):
try:
total, used, free = shutil.disk_usage(restore_dest_path)
@@ -77,11 +79,11 @@ class Navigation:
'path_display': '',
'size': ''
})
else: # In restore mode, left is destination
else: # In restore mode, left is destination
self.app.left_canvas_data.update({
'icon': 'computer_extralarge', # Default icon
'folder': Msg.STR["select_destination"],
'path_display': '',
'icon': 'computer_extralarge',
'folder': Msg.STR["select_source_first"],
'path_display': Msg.STR["system_restore"],
'size': ''
})
@@ -89,7 +91,7 @@ class Navigation:
# Right canvas is always the destination/HDD view conceptually
self.app.right_canvas_data.update({
'icon': 'hdd_extralarge',
'folder': Msg.STR["select_destination"] if mode == 'backup' else Msg.STR["source"],
'folder': Msg.STR["select_destination"] if mode == 'backup' else Msg.STR["select_source"],
'path_display': '',
'size': ''
})
@@ -98,28 +100,34 @@ class Navigation:
if mode == "backup":
self.app.source_size_frame.grid()
self.app.target_size_frame.grid()
self.app.restore_size_frame.grid_remove()
self.app.mode_button_icon = self.app.image_manager.get_icon("forward_extralarge")
self.app.restore_size_frame_before.grid_remove()
self.app.restore_size_frame_after.grid_remove()
self.app.mode_button_icon = self.app.image_manager.get_icon(
"forward_extralarge")
self.app.info_label.config(text=Msg.STR["backup_mode_info"])
self.app.full_backup_cb.config(state="normal")
self.app.incremental_cb.config(state="normal")
self.app.compressed_cb.config(state="normal")
self.app.encrypted_cb.config(state="normal")
self.app.bypass_security_cb.config(state='disabled') # This one is mode-dependent
self.app.bypass_security_cb.config(
state='disabled') # This one is mode-dependent
# Let the central config function handle the state of these checkboxes
self.app.update_backup_options_from_config()
else: # restore
self.app.source_size_frame.grid_remove()
self.app.target_size_frame.grid_remove()
self.app.restore_size_frame.grid()
self.app.mode_button_icon = self.app.image_manager.get_icon("back_extralarge")
self.app.restore_size_frame_before.grid()
self.app.restore_size_frame_after.grid()
self.app.mode_button_icon = self.app.image_manager.get_icon(
"back_extralarge")
self.app.info_label.config(text=Msg.STR["restore_mode_info"])
self.app.full_backup_cb.config(state='disabled')
self.app.incremental_cb.config(state='disabled')
self.app.compressed_cb.config(state='disabled')
self.app.encrypted_cb.config(state='disabled')
self.app.bypass_security_cb.config(state='normal') # This one is mode-dependent
self.app.bypass_security_cb.config(
state='normal') # This one is mode-dependent
self.app.mode_button.config(image=self.app.mode_button_icon)
self.app.drawing.update_nav_buttons(active_index)
self.app.drawing.redraw_left_canvas()
@@ -157,8 +165,9 @@ class Navigation:
if trigger_calculation:
# Always trigger the calculation for the left canvas, which is controlled by the sidebar
current_folder_on_left = self.app.left_canvas_data.get('folder')
if current_folder_on_left:
self.app.actions.on_sidebar_button_click(current_folder_on_left)
if current_folder_on_left and current_folder_on_left in self.app.buttons_map:
self.app.actions.on_sidebar_button_click(
current_folder_on_left)
# Additionally, in restore mode, trigger calculation for the right canvas if a source is set
if self.app.mode == 'restore':
@@ -187,7 +196,8 @@ class Navigation:
self.app.backup_content_frame.hide()
self.app.source_size_frame.grid_remove()
self.app.target_size_frame.grid_remove()
self.app.restore_size_frame.grid_remove()
self.app.restore_size_frame_before.grid_remove()
self.app.restore_size_frame_after.grid_remove()
self.app.log_frame.grid()
self.app.top_bar.grid()
self._update_task_bar_visibility("log")
@@ -203,7 +213,8 @@ class Navigation:
self.app.backup_content_frame.hide()
self.app.source_size_frame.grid_remove()
self.app.target_size_frame.grid_remove()
self.app.restore_size_frame.grid_remove()
self.app.restore_size_frame_before.grid_remove()
self.app.restore_size_frame_after.grid_remove()
self.app.scheduler_frame.show()
self.app.top_bar.grid()
self._update_task_bar_visibility("scheduler")
@@ -219,7 +230,8 @@ class Navigation:
self.app.scheduler_frame.hide()
self.app.source_size_frame.grid_remove()
self.app.target_size_frame.grid_remove()
self.app.restore_size_frame.grid_remove()
self.app.restore_size_frame_before.grid_remove()
self.app.restore_size_frame_after.grid_remove()
self.app.settings_frame.show()
self.app.top_bar.grid()
self._update_task_bar_visibility("settings")
@@ -241,7 +253,8 @@ class Navigation:
self.app.settings_frame.hide()
self.app.source_size_frame.grid_remove()
self.app.target_size_frame.grid_remove()
self.app.restore_size_frame.grid_remove()
self.app.restore_size_frame_before.grid_remove()
self.app.restore_size_frame_after.grid_remove()
self.app.backup_content_frame.show(self.app.destination_path)
self.app.top_bar.grid()
self._update_task_bar_visibility("scheduler")