Switch to Plex style dialogs

This commit is contained in:
croneter 2018-09-18 16:26:40 +02:00
parent e9e1b7b7de
commit e3328ad061
8 changed files with 48 additions and 65 deletions

View file

@ -106,7 +106,7 @@ class Main():
elif mode in ('manualsync', 'repair'): elif mode in ('manualsync', 'repair'):
if pickler.pickl_window('plex_online') != 'true': if pickler.pickl_window('plex_online') != 'true':
# Server is not online, do not run the sync # Server is not online, do not run the sync
utils.dialog('ok', utils.lang(29999), utils.lang(39205)) utils.messageDialog(utils.lang(29999), utils.lang(39205))
log.error('Not connected to a PMS.') log.error('Not connected to a PMS.')
else: else:
if mode == 'repair': if mode == 'repair':
@ -190,12 +190,12 @@ class Main():
deviceId = clientinfo.getDeviceId(reset=True) deviceId = clientinfo.getDeviceId(reset=True)
except Exception as e: except Exception as e:
log.error('Failed to generate a new device Id: %s' % e) log.error('Failed to generate a new device Id: %s' % e)
utils.dialog('ok', utils.lang(29999), utils.lang(33032)) utils.messageDialog(utils.lang(29999), utils.lang(33032))
else: else:
log.info('Successfully removed old device ID: %s New deviceId:' log.info('Successfully removed old device ID: %s New deviceId:'
'%s' % (deviceId_old, deviceId)) '%s' % (deviceId_old, deviceId))
# 'Kodi will now restart to apply the changes' # 'Kodi will now restart to apply the changes'
utils.dialog('ok', utils.lang(29999), utils.lang(33033)) utils.messageDialog(utils.lang(29999), utils.lang(33033))
executebuiltin('RestartApp') executebuiltin('RestartApp')

View file

@ -173,13 +173,13 @@ class Artwork():
This method will sync all Kodi artwork to textures13.db This method will sync all Kodi artwork to textures13.db
and cache them locally. This takes diskspace! and cache them locally. This takes diskspace!
""" """
if not utils.dialog('yesno', "Image Texture Cache", utils.lang(39250)): if not utils.yesno_dialog("Image Texture Cache", utils.lang(39250)):
return return
LOG.info("Doing Image Cache Sync") LOG.info("Doing Image Cache Sync")
# ask to rest all existing or not # ask to rest all existing or not
if utils.dialog('yesno', "Image Texture Cache", utils.lang(39251)): if utils.yesno_dialog("Image Texture Cache", utils.lang(39251)):
LOG.info("Resetting all cache data first") LOG.info("Resetting all cache data first")
# Remove all existing textures first # Remove all existing textures first
path = path_ops.translate_path('special://thumbnails/') path = path_ops.translate_path('special://thumbnails/')

View file

@ -95,8 +95,7 @@ def reset_authorization():
""" """
User tried login and failed too many times. Reset # of logins User tried login and failed too many times. Reset # of logins
""" """
resp = utils.dialog('yesno', heading="{plex}", line1=utils.lang(39206)) if utils.yesno_dialog(utils.lang(29999), utils.lang(39206)):
if resp == 1:
LOG.info("Reset login attempts.") LOG.info("Reset login attempts.")
utils.plex_command('PMS_STATUS', 'Auth') utils.plex_command('PMS_STATUS', 'Auth')
else: else:
@ -968,11 +967,10 @@ def create_new_pms():
Opens dialogs for the user the plug in the PMS details Opens dialogs for the user the plug in the PMS details
""" """
# "Enter your Plex Media Server's IP or URL. Examples are:" # "Enter your Plex Media Server's IP or URL. Examples are:"
utils.dialog('ok', utils.messageDialog(utils.lang(29999),
utils.lang(29999), '%s\n%s\n%s' % (utils.lang(39215),
utils.lang(39215), '192.168.1.2',
'192.168.1.2', 'plex.myServer.org'))
'plex.myServer.org')
address = utils.dialog('input', "Enter PMS IP or URL") address = utils.dialog('input', "Enter PMS IP or URL")
if address == '': if address == '':
return return
@ -982,7 +980,7 @@ def create_new_pms():
url = '%s:%s' % (address, port) url = '%s:%s' % (address, port)
# "Does your Plex Media Server support SSL connections? # "Does your Plex Media Server support SSL connections?
# (https instead of http)" # (https instead of http)"
https = utils.dialog('yesno', utils.lang(29999), utils.lang(39217)) https = utils.yesno_dialog(utils.lang(29999), utils.lang(39217))
if https: if https:
url = 'https://%s' % url url = 'https://%s' % url
else: else:
@ -992,11 +990,10 @@ def create_new_pms():
if machine_identifier is None: if machine_identifier is None:
# "Error contacting url # "Error contacting url
# Abort (Yes) or save address anyway (No)" # Abort (Yes) or save address anyway (No)"
if utils.dialog('yesno', if utils.yesno_dialog(utils.lang(29999),
utils.lang(29999), '%s %s. %s' % (utils.lang(39218),
'%s %s. %s' % (utils.lang(39218), url,
url, utils.lang(39219))):
utils.lang(39219))):
return return
else: else:
utils.settings('plex_machineIdentifier', '') utils.settings('plex_machineIdentifier', '')
@ -1048,7 +1045,7 @@ def _log_out():
while utils.window('plex_dbScan') == 'true': while utils.window('plex_dbScan') == 'true':
if counter > 200: if counter > 200:
# Failed to reset PMS and plex.tv connects. Try to restart Kodi. # Failed to reset PMS and plex.tv connects. Try to restart Kodi.
utils.dialog('ok', utils.lang(29999), utils.lang(39208)) utils.messageDialog(utils.lang(29999), utils.lang(39208))
# Resuming threads, just in case # Resuming threads, just in case
utils.plex_command('SUSPEND_LIBRARY_THREAD', 'False') utils.plex_command('SUSPEND_LIBRARY_THREAD', 'False')
LOG.error("Could not stop library sync, aborting") LOG.error("Could not stop library sync, aborting")
@ -1065,7 +1062,7 @@ def _log_out():
while utils.window('plex_serverStatus') == "401": while utils.window('plex_serverStatus') == "401":
if counter > 100: if counter > 100:
# 'Failed to reset PKC. Try to restart Kodi.' # 'Failed to reset PKC. Try to restart Kodi.'
utils.dialog('ok', utils.lang(29999), utils.lang(39208)) utils.messageDialog(utils.lang(29999), utils.lang(39208))
LOG.error("Could not sign out user, aborting") LOG.error("Could not sign out user, aborting")
return False return False
counter += 1 counter += 1

View file

@ -293,13 +293,13 @@ class LibrarySync(Thread):
if utils.window('plex_scancrashed') == 'true': if utils.window('plex_scancrashed') == 'true':
# Show warning if itemtypes.py crashed at some point # Show warning if itemtypes.py crashed at some point
utils.dialog('ok', heading='{plex}', line1=utils.lang(39408)) utils.messageDialog(utils.lang(29999), utils.lang(39408))
utils.window('plex_scancrashed', clear=True) utils.window('plex_scancrashed', clear=True)
elif utils.window('plex_scancrashed') == '401': elif utils.window('plex_scancrashed') == '401':
utils.window('plex_scancrashed', clear=True) utils.window('plex_scancrashed', clear=True)
if state.PMS_STATUS not in ('401', 'Auth'): if state.PMS_STATUS not in ('401', 'Auth'):
# Plex server had too much and returned ERROR # Plex server had too much and returned ERROR
utils.dialog('ok', heading='{plex}', line1=utils.lang(39409)) utils.messageDialog(utils.lang(29999), utils.lang(39409))
return True return True
def _process_view(self, folder_item, kodi_db, plex_db, totalnodes): def _process_view(self, folder_item, kodi_db, plex_db, totalnodes):
@ -1464,11 +1464,11 @@ class LibrarySync(Thread):
elif state.RUN_LIB_SCAN == 'fanart': elif state.RUN_LIB_SCAN == 'fanart':
# Only look for missing fanart (No) # Only look for missing fanart (No)
# or refresh all fanart (Yes) # or refresh all fanart (Yes)
refresh = utils.dialog('yesno', from .windows import optionsdialog
heading='{plex}', refresh = optionsdialog.show(utils.lang(29999),
line1=utils.lang(39223), utils.lang(39223),
nolabel=utils.lang(39224), utils.lang(39224), # refresh all
yeslabel=utils.lang(39225)) utils.lang(39225)) == 0
self.sync_fanart(missing_only=not refresh, refresh=refresh) self.sync_fanart(missing_only=not refresh, refresh=refresh)
elif state.RUN_LIB_SCAN == 'textures': elif state.RUN_LIB_SCAN == 'textures':
state.DB_SCAN = True state.DB_SCAN = True
@ -1492,7 +1492,7 @@ class LibrarySync(Thread):
import traceback import traceback
LOG.error("Traceback:\n%s", traceback.format_exc()) LOG.error("Traceback:\n%s", traceback.format_exc())
# Library sync thread has crashed # Library sync thread has crashed
utils.dialog('ok', heading='{plex}', line1=utils.lang(39400)) utils.messageDialog(utils.lang(29999), utils.lang(39400))
raise raise
def _run_internal(self): def _run_internal(self):
@ -1516,7 +1516,7 @@ class LibrarySync(Thread):
LOG.error('Current Kodi version: %s', utils.try_decode( LOG.error('Current Kodi version: %s', utils.try_decode(
xbmc.getInfoLabel('System.BuildVersion'))) xbmc.getInfoLabel('System.BuildVersion')))
# "Current Kodi version is unsupported, cancel lib sync" # "Current Kodi version is unsupported, cancel lib sync"
utils.dialog('ok', heading='{plex}', line1=utils.lang(39403)) utils.messageDialog(utils.lang(29999), utils.lang(39403))
return return
# Do some initializing # Do some initializing
@ -1587,16 +1587,13 @@ class LibrarySync(Thread):
LOG.warn("Db version out of date: %s minimum version " LOG.warn("Db version out of date: %s minimum version "
"required: %s", current_version, v.MIN_DB_VERSION) "required: %s", current_version, v.MIN_DB_VERSION)
# DB out of date. Proceed to recreate? # DB out of date. Proceed to recreate?
resp = utils.dialog('yesno', if not utils.yesno_dialog(utils.lang(29999),
heading=utils.lang(29999), utils.lang(39401)):
line1=utils.lang(39401))
if not resp:
LOG.warn("Db version out of date! USER IGNORED!") LOG.warn("Db version out of date! USER IGNORED!")
# PKC may not work correctly until reset # PKC may not work correctly until reset
utils.dialog('ok', utils.messageDialog(utils.lang(29999),
heading='{plex}', '%s%s' % (utils.lang(29999),
line1='%s%s' % (utils.lang(29999), utils.lang(39402)))
utils.lang(39402)))
else: else:
utils.reset(ask_user=False) utils.reset(ask_user=False)
break break

View file

@ -200,10 +200,7 @@ def _playback_init(plex_id, plex_type, playqueue, pos):
utils.settings('enableCinema') == "true"): utils.settings('enableCinema') == "true"):
if utils.settings('askCinema') == "true": if utils.settings('askCinema') == "true":
# "Play trailers?" # "Play trailers?"
trailers = utils.dialog('yesno', trailers = utils.yesno_dialog(utils.lang(29999), utils.lang(33016))
utils.lang(29999),
utils.lang(33016))
trailers = True if trailers else False
else: else:
trailers = True trailers = True
LOG.debug('Playing trailers: %s', trailers) LOG.debug('Playing trailers: %s', trailers)

View file

@ -1787,10 +1787,7 @@ class API(object):
LOG.warn('Cannot access file: %s', url) LOG.warn('Cannot access file: %s', url)
# Kodi cannot locate the file #s. Please verify your PKC settings. Stop # Kodi cannot locate the file #s. Please verify your PKC settings. Stop
# syncing? # syncing?
resp = utils.dialog('yesno', return utils.yesno_dialog(utils.lang(29999), utils.lang(39031) % url)
heading='{plex}',
line1=utils.lang(39031) % url)
return resp
@staticmethod @staticmethod
def _set_listitem_artprop(listitem, arttype, path): def _set_listitem_artprop(listitem, arttype, path):

View file

@ -123,12 +123,14 @@ class plexgdm:
"be registered. Change the Plex Companion update port!" "be registered. Change the Plex Companion update port!"
% self.client_update_port) % self.client_update_port)
if utils.settings('companion_show_gdm_port_warning') == 'true': if utils.settings('companion_show_gdm_port_warning') == 'true':
if utils.dialog('yesno', from .windows import optionsdialog
utils.lang(29999), # Plex Companion could not open the GDM port. Please change it
'Port %s' % self.client_update_port, # in the PKC settings.
utils.lang(39079), if optionsdialog.show(utils.lang(29999),
yeslabel=utils.lang(30013), # Never show again 'Port %s\n%s' % (self.client_update_port,
nolabel=utils.lang(30012)): # OK utils.lang(39079)),
utils.lang(30013), # Never show again
utils.lang(186)) == 0:
utils.settings('companion_show_gdm_port_warning', utils.settings('companion_show_gdm_port_warning',
value='false') value='false')
from xbmc import executebuiltin from xbmc import executebuiltin

View file

@ -78,7 +78,7 @@ def reboot_kodi(message=None):
Set optional custom message Set optional custom message
""" """
message = message or lang(33033) message = message or lang(33033)
dialog('ok', heading='{plex}', line1=message) messageDialog(lang(29999), message)
xbmc.executebuiltin('RestartApp') xbmc.executebuiltin('RestartApp')
@ -554,9 +554,7 @@ def reset(ask_user=True):
database and possibly PKC entirely database and possibly PKC entirely
""" """
# Are you sure you want to reset your local Kodi database? # Are you sure you want to reset your local Kodi database?
if ask_user and not dialog('yesno', if ask_user and not yesno_dialog(lang(29999), lang(39600)):
heading='{plex} %s ' % lang(30132),
line1=lang(39600)):
return return
# first stop any db sync # first stop any db sync
@ -567,9 +565,7 @@ def reset(ask_user=True):
count -= 1 count -= 1
if count == 0: if count == 0:
# Could not stop the database from running. Please try again later. # Could not stop the database from running. Please try again later.
dialog('ok', messageDialog(lang(29999), lang(39601))
heading='{plex} %s' % lang(30132),
line1=lang(39601))
return return
xbmc.sleep(1000) xbmc.sleep(1000)
@ -578,9 +574,7 @@ def reset(ask_user=True):
# Reset all PlexKodiConnect Addon settings? (this is usually NOT # Reset all PlexKodiConnect Addon settings? (this is usually NOT
# recommended and unnecessary!) # recommended and unnecessary!)
if ask_user and dialog('yesno', if ask_user and yesno_dialog(lang(29999), lang(39603)):
heading='{plex} %s ' % lang(30132),
line1=lang(39603)):
# Delete the settings # Delete the settings
LOG.info("Deleting: settings.xml") LOG.info("Deleting: settings.xml")
path_ops.remove("%ssettings.xml" % v.ADDON_PROFILE) path_ops.remove("%ssettings.xml" % v.ADDON_PROFILE)
@ -760,7 +754,7 @@ class XmlKodiSetting(object):
LOG.error('Error parsing %s', self.path) LOG.error('Error parsing %s', self.path)
# "Kodi cannot parse {0}. PKC will not function correctly. Please # "Kodi cannot parse {0}. PKC will not function correctly. Please
# visit {1} and correct your file!" # visit {1} and correct your file!"
dialog('ok', lang(29999), lang(39716).format( messageDialog(lang(29999), lang(39716).format(
self.filename, self.filename,
'http://kodi.wiki')) 'http://kodi.wiki'))
self.__exit__(etree.ParseError, None, None) self.__exit__(etree.ParseError, None, None)
@ -913,7 +907,7 @@ def passwords_xml():
LOG.error('Error parsing %s', xmlpath) LOG.error('Error parsing %s', xmlpath)
# "Kodi cannot parse {0}. PKC will not function correctly. Please visit # "Kodi cannot parse {0}. PKC will not function correctly. Please visit
# {1} and correct your file!" # {1} and correct your file!"
dialog('ok', lang(29999), lang(39716).format( messageDialog(lang(29999), lang(39716).format(
'passwords.xml', 'http://forum.kodi.tv/')) 'passwords.xml', 'http://forum.kodi.tv/'))
return return
else: else:
@ -969,8 +963,7 @@ def passwords_xml():
return return
else: else:
# No credentials added # No credentials added
dialog('ok', messageDialog("Network credentials",
"Network credentials",
'Input the server name or IP address as indicated in your plex ' 'Input the server name or IP address as indicated in your plex '
'library paths. For example, the server name: ' 'library paths. For example, the server name: '
'\\\\SERVER-PC\\path\\ or smb://SERVER-PC/path is SERVER-PC') '\\\\SERVER-PC\\path\\ or smb://SERVER-PC/path is SERVER-PC')