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'):
if pickler.pickl_window('plex_online') != 'true':
# 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.')
else:
if mode == 'repair':
@ -190,12 +190,12 @@ class Main():
deviceId = clientinfo.getDeviceId(reset=True)
except Exception as 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:
log.info('Successfully removed old device ID: %s New deviceId:'
'%s' % (deviceId_old, deviceId))
# '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')

View file

@ -173,13 +173,13 @@ class Artwork():
This method will sync all Kodi artwork to textures13.db
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
LOG.info("Doing Image Cache Sync")
# 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")
# Remove all existing textures first
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
"""
resp = utils.dialog('yesno', heading="{plex}", line1=utils.lang(39206))
if resp == 1:
if utils.yesno_dialog(utils.lang(29999), utils.lang(39206)):
LOG.info("Reset login attempts.")
utils.plex_command('PMS_STATUS', 'Auth')
else:
@ -968,11 +967,10 @@ def create_new_pms():
Opens dialogs for the user the plug in the PMS details
"""
# "Enter your Plex Media Server's IP or URL. Examples are:"
utils.dialog('ok',
utils.lang(29999),
utils.lang(39215),
'192.168.1.2',
'plex.myServer.org')
utils.messageDialog(utils.lang(29999),
'%s\n%s\n%s' % (utils.lang(39215),
'192.168.1.2',
'plex.myServer.org'))
address = utils.dialog('input', "Enter PMS IP or URL")
if address == '':
return
@ -982,7 +980,7 @@ def create_new_pms():
url = '%s:%s' % (address, port)
# "Does your Plex Media Server support SSL connections?
# (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:
url = 'https://%s' % url
else:
@ -992,11 +990,10 @@ def create_new_pms():
if machine_identifier is None:
# "Error contacting url
# Abort (Yes) or save address anyway (No)"
if utils.dialog('yesno',
utils.lang(29999),
'%s %s. %s' % (utils.lang(39218),
url,
utils.lang(39219))):
if utils.yesno_dialog(utils.lang(29999),
'%s %s. %s' % (utils.lang(39218),
url,
utils.lang(39219))):
return
else:
utils.settings('plex_machineIdentifier', '')
@ -1048,7 +1045,7 @@ def _log_out():
while utils.window('plex_dbScan') == 'true':
if counter > 200:
# 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
utils.plex_command('SUSPEND_LIBRARY_THREAD', 'False')
LOG.error("Could not stop library sync, aborting")
@ -1065,7 +1062,7 @@ def _log_out():
while utils.window('plex_serverStatus') == "401":
if counter > 100:
# '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")
return False
counter += 1

View file

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

View file

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

View file

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

View file

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

View file

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