1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# -*- coding: utf-8 -*-
# Copyright 2017 Leo Moll and Dominik Schlösser
#
# -- Imports ------------------------------------------------
import xbmc, xbmcgui
# -- Classes ------------------------------------------------
class KodiUI( object ):
def __init__( self ):
self.bgdialog = None
def GetEnteredText( self, deftext = '', heading = '', hidden = False ):
keyboard = xbmc.Keyboard( deftext, heading, 1 if hidden else 0 )
keyboard.doModal()
if keyboard.isConfirmed():
return keyboard.getText()
return deftext
def ShowNotification( self, heading, message, icon = xbmcgui.NOTIFICATION_INFO, time = 5000, sound = True ):
xbmcgui.Dialog().notification( heading, message, icon, time, sound )
def ShowWarning( self, heading, message, time = 5000, sound = True ):
xbmcgui.Dialog().notification( heading, message, xbmcgui.NOTIFICATION_WARNING, time, sound )
def ShowError( self, heading, message, time = 5000, sound = True ):
xbmcgui.Dialog().notification( heading, message, xbmcgui.NOTIFICATION_ERROR, time, sound )
def ShowBGDialog( self, heading = None, message = None ):
if self.bgdialog is None:
self.bgdialog = xbmcgui.DialogProgressBG()
self.bgdialog.create( heading, message )
else:
self.bgdialog.update( 0, heading, message )
def UpdateBGDialog( self, percent, heading = None, message = None ):
if self.bgdialog is not None:
self.bgdialog.update( percent, heading, message )
def CloseBGDialog( self ):
if self.bgdialog is not None:
self.bgdialog.close()
del self.bgdialog
self.bgdialog = None
class KodiBGDialog( object ):
def __init__( self ):
self.bgdialog= None
def __del__( self ):
self.Close()
def Create( self, heading = None, message = None ):
if self.bgdialog is None:
self.bgdialog = xbmcgui.DialogProgressBG()
self.bgdialog.create( heading, message )
else:
self.bgdialog.update( 0, heading, message )
def Update( self, percent, heading = None, message = None ):
if self.bgdialog is not None:
self.bgdialog.update( percent, heading, message )
def UrlRetrieveHook( self, blockcount, blocksize, totalsize ):
downloaded = blockcount * blocksize
if totalsize > 0:
percent = int( (downloaded * 100) / totalsize )
if self.bgdialog is not None:
self.bgdialog.update( percent )
def Close( self ):
if self.bgdialog is not None:
self.bgdialog.close()
del self.bgdialog
self.bgdialog = None
|