mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-12-23 06:27:55 +01:00
55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
import xbmcgui
|
|
from . import utils as utils
|
|
|
|
|
|
class BackupProgressBar:
|
|
NONE = 2
|
|
DIALOG = 0
|
|
BACKGROUND = 1
|
|
|
|
mode = 2
|
|
progressBar = None
|
|
override = False
|
|
|
|
def __init__(self, progressOverride):
|
|
self.override = progressOverride
|
|
|
|
# check if we should use the progress bar
|
|
if(utils.getSettingInt('progress_mode') != 2):
|
|
# check if background or normal
|
|
if(utils.getSettingInt('progress_mode') == 0 and not self.override):
|
|
self.mode = self.DIALOG
|
|
self.progressBar = xbmcgui.DialogProgress()
|
|
else:
|
|
self.mode = self.BACKGROUND
|
|
self.progressBar = xbmcgui.DialogProgressBG()
|
|
|
|
def create(self, heading, message):
|
|
if(self.mode != self.NONE):
|
|
self.progressBar.create(heading, message)
|
|
|
|
def updateProgress(self, percent, message=None):
|
|
|
|
# update the progress bar
|
|
if(self.mode != self.NONE):
|
|
if(message is not None):
|
|
# need different calls for dialog and background bars
|
|
if(self.mode == self.DIALOG):
|
|
self.progressBar.update(percent, message)
|
|
else:
|
|
self.progressBar.update(percent, message=message)
|
|
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()
|