From 895a5efca130690732996fe828ff116dd8230c13 Mon Sep 17 00:00:00 2001 From: dekunukem Date: Sun, 4 Apr 2021 07:34:36 +0100 Subject: [PATCH] added local backup reminder, local backup now saves to a standalone folder --- pc_software/duckypad_config.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/pc_software/duckypad_config.py b/pc_software/duckypad_config.py index f7722c84..ed367aa0 100644 --- a/pc_software/duckypad_config.py +++ b/pc_software/duckypad_config.py @@ -4,6 +4,7 @@ import copy import shutil import pathlib +from datetime import datetime import traceback import duck_objs import webbrowser @@ -20,7 +21,7 @@ if 'linux' in sys.platform: default_button_color = 'grey' -THIS_VERSION_NUMBER = '0.10.0' +THIS_VERSION_NUMBER = '0.11.0' MAIN_WINDOW_WIDTH = 800 MAIN_WINDOW_HEIGHT = 600 MAIN_COLOUM_HEIGHT = 533 @@ -530,14 +531,31 @@ def save_everything(save_path): save_result_label.unbind("") last_save = time.time() +def current_time_str(): + ret = datetime.utcnow().isoformat(sep='T') + return (ret[:19] + "Z").replace(':', '-') + +def make_default_backup_dir_name(): + return 'duckyPad_backup_' + current_time_str() + +backup_reminder_showed = False + def save_click(): + global backup_reminder_showed save_everything(dp_root_folder_path) + if backup_reminder_showed: + return + yesno = messagebox.askyesno("Local backup", "Done!\n\nWould you like to save a local backup of your profiles too?") + backup_reminder_showed = True + if yesno is False: + return + save_as_click() def save_as_click(): - dir_result = filedialog.askdirectory() + dir_result = filedialog.askdirectory(initialdir=os.path.join(os.path.expanduser('~'), "Desktop")) if len(dir_result) <= 0: return - save_everything(dir_result) + save_everything(os.path.join(dir_result, make_default_backup_dir_name())) def key_button_click_event(event): key_button_click(event.widget) @@ -605,7 +623,7 @@ def key_button_click(button_widget): save_button = Button(root_folder_lf, text="Save", command=save_click, state=DISABLED) save_button.place(x=535, y=0, width=50) -save_as_button = Button(root_folder_lf, text="Save as...", command=save_as_click, state=DISABLED) +save_as_button = Button(root_folder_lf, text="Backup...", command=save_as_click, state=DISABLED) save_as_button.place(x=590, y=0, width=65) save_result_label = Label(master=root_folder_lf, text="")