Skip to content

Commit

Permalink
added local backup reminder, local backup now saves to a standalone f…
Browse files Browse the repository at this point in the history
…older
  • Loading branch information
dekuNukem committed Apr 4, 2021
1 parent 86ef178 commit 895a5ef
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions pc_software/duckypad_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import copy
import shutil
import pathlib
from datetime import datetime
import traceback
import duck_objs
import webbrowser
Expand All @@ -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
Expand Down Expand Up @@ -530,14 +531,31 @@ def save_everything(save_path):
save_result_label.unbind("<Button-1>")
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)
Expand Down Expand Up @@ -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="")
Expand Down

0 comments on commit 895a5ef

Please sign in to comment.