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