2019-11-22 14:53:20 -06:00
|
|
|
import xbmcgui
|
2019-08-27 14:55:22 -05:00
|
|
|
from . import utils as utils
|
2015-06-26 15:32:22 -05:00
|
|
|
|
2019-11-25 15:56:59 -06:00
|
|
|
|
2015-06-26 15:32:22 -05:00
|
|
|
class BackupProgressBar:
|
|
|
|
NONE = 2
|
|
|
|
DIALOG = 0
|
|
|
|
BACKGROUND = 1
|
|
|
|
|
|
|
|
mode = 2
|
|
|
|
progressBar = None
|
|
|
|
override = False
|
2019-11-25 15:33:34 -06:00
|
|
|
|
2019-11-25 15:45:41 -06:00
|
|
|
def __init__(self, progressOverride):
|
2015-06-26 15:32:22 -05:00
|
|
|
self.override = progressOverride
|
2019-11-25 15:33:34 -06:00
|
|
|
|
2019-11-25 15:19:57 -06:00
|
|
|
# check if we should use the progress bar
|
2019-11-27 14:19:41 -06:00
|
|
|
if(utils.getSettingInt('progress_mode') != 2):
|
2019-11-25 15:19:57 -06:00
|
|
|
# check if background or normal
|
2019-11-27 14:19:41 -06:00
|
|
|
if(utils.getSettingInt('progress_mode') == 0 and not self.override):
|
2015-06-26 15:32:22 -05:00
|
|
|
self.mode = self.DIALOG
|
|
|
|
self.progressBar = xbmcgui.DialogProgress()
|
|
|
|
else:
|
|
|
|
self.mode = self.BACKGROUND
|
|
|
|
self.progressBar = xbmcgui.DialogProgressBG()
|
|
|
|
|
2019-11-25 15:45:41 -06:00
|
|
|
def create(self, heading, message):
|
2015-06-26 15:32:22 -05:00
|
|
|
if(self.mode != self.NONE):
|
2019-11-25 15:45:41 -06:00
|
|
|
self.progressBar.create(heading, message)
|
2015-06-26 15:32:22 -05:00
|
|
|
|
2019-11-25 15:45:41 -06:00
|
|
|
def updateProgress(self, percent, message=None):
|
2019-11-25 15:33:34 -06:00
|
|
|
|
2019-11-25 15:19:57 -06:00
|
|
|
# update the progress bar
|
2015-06-26 15:32:22 -05:00
|
|
|
if(self.mode != self.NONE):
|
2019-11-25 15:56:59 -06:00
|
|
|
if(message is not None):
|
2019-11-25 15:19:57 -06:00
|
|
|
# need different calls for dialog and background bars
|
2015-06-26 15:32:22 -05:00
|
|
|
if(self.mode == self.DIALOG):
|
2019-11-25 15:45:41 -06:00
|
|
|
self.progressBar.update(percent, message)
|
2015-06-26 15:32:22 -05:00
|
|
|
else:
|
2019-11-25 15:45:41 -06:00
|
|
|
self.progressBar.update(percent, message=message)
|
2015-06-26 15:32:22 -05:00
|
|
|
else:
|
|
|
|
self.progressBar.update(percent)
|
|
|
|
|
|
|
|
def checkCancel(self):
|
|
|
|
result = False
|
|
|
|
|
|
|
|
if(self.mode == self.DIALOG):
|
|
|
|
result = self.progressBar.iscanceled()
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
if(self.mode != self.NONE):
|
|
|
|
self.progressBar.close()
|