From 987d90de1244d13915da732667feaf8fe47190e7 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 20 Jan 2014 12:42:49 -0600 Subject: [PATCH] added options for background progress bar. part of #36 --- resources/language/English/strings.xml | 5 ++++- resources/lib/backup.py | 15 ++++++++++----- resources/settings.xml | 2 +- scheduler.py | 11 ++++++++--- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 4f04fa7..979df3c 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -14,7 +14,7 @@ Type Path Browse Remote Path Backup Folder Name - Run Silent + Progress Display Mode Type Remote Path Remote Path Type @@ -73,4 +73,7 @@ Just Today Profiles Scheduler will run again on + Progress Bar + Background Progress Bar + None (Silent) diff --git a/resources/lib/backup.py b/resources/lib/backup.py index 1e3d45e..28ef76a 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -70,7 +70,7 @@ class XbmcBackup: def skipAdvanced(self): self.skip_advanced = True - def run(self,mode=-1,runSilent=False): + def run(self,mode=-1,progressOverride=False): #append backup folder name progressBarTitle = utils.getString(30010) + " - " if(mode == self.Backup and self.remote_vfs.root_path != ''): @@ -88,8 +88,13 @@ class XbmcBackup: utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path) #check if we should use the progress bar - if(utils.getSetting('run_silent') == 'false' and not runSilent): - self.progressBar = xbmcgui.DialogProgress() + if(int(utils.getSetting('progress_mode')) != 2): + #check if background or normal + if(int(utils.getSetting('progress_mode')) == 0 and not progressOverride): + self.progressBar = xbmcgui.DialogProgress() + else: + self.progressBar = xbmcgui.DialogProgressBG() + self.progressBar.create(progressBarTitle,utils.getString(30049) + "......") if(mode == self.Backup): @@ -296,7 +301,7 @@ class XbmcBackup: #call update addons to refresh everything xbmc.executebuiltin('UpdateLocalAddons') - if(utils.getSetting('run_silent') == 'false' and not runSilent): + if(self.progressBar != None): self.progressBar.close() def backupFiles(self,fileList,source,dest): @@ -342,7 +347,7 @@ class XbmcBackup: def _checkCancel(self): result = False - if(self.progressBar != None): + if(self.progressBar != None and type(self.progressBar) is xbmcgui.DialogProgress): result = self.progressBar.iscanceled() return result diff --git a/resources/settings.xml b/resources/settings.xml index e14e466..21d98d1 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -7,7 +7,7 @@ - + diff --git a/scheduler.py b/scheduler.py index d2df48e..39b23b9 100644 --- a/scheduler.py +++ b/scheduler.py @@ -46,13 +46,18 @@ class BackupScheduler: now = time.time() if(self.next_run <= now): - if(utils.getSetting('run_silent') == 'false'): + progress_mode = int(utils.getSetting('progress_mode')) + if(progress_mode != 2): utils.showNotification(utils.getString(30053)) - #run the job in backup mode, hiding the dialog box + backup = XbmcBackup() if(backup.remoteConfigured()): - backup.run(XbmcBackup.Backup,True) + + if(int(utils.getSetting('progress_mode')) in [0,1]): + backup.run(XbmcBackup.Backup,True) + else: + backup.run(XbmcBackup.Backup,False) #check if this is a "one-off" if(int(utils.getSetting("schedule_interval")) == 0):