From d1346b2cd604482cd63a147cc3dc79ab1e55fa7c Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 16 Jul 2017 16:57:57 +0200 Subject: [PATCH] Dialog: manual PMS entry --- .../resource.language.en_gb/strings.po | 27 ++++++++++++- resources/lib/connectmanager.py | 2 +- resources/lib/dialogs/servermanual.py | 27 +++++++------ ... => script-plex-connect-server-manual.xml} | 39 ++++++++++--------- 4 files changed, 61 insertions(+), 34 deletions(-) rename resources/skins/default/1080i/{script-emby-connect-server-manual.xml => script-plex-connect-server-manual.xml} (80%) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index e48a9645..453aa50b 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -83,10 +83,35 @@ msgctxt "#30017" msgid "Unauthorized for PMS" msgstr "" +# Title of dialog for manual PMS connection +msgctxt "#30018" +msgid "Manually connect to PMS" +msgstr "" + +# Button text for connect dialog +msgctxt "#30019" +msgid "PMS IP address or host name" +msgstr "" + +# Button text for connect dialog +msgctxt "#30020" +msgid "Connect" +msgstr "" + +# Button text for connect dialog +msgctxt "#30021" +msgid "Please fill in both server and port" +msgstr "" + msgctxt "#30022" msgid "Advanced" msgstr "" +# Used to show that PKC is currently trying to connect to a PMS +msgctxt "#30023" +msgid "Connecting to" +msgstr "" + msgctxt "#30024" msgid "Username" msgstr "" @@ -96,7 +121,7 @@ msgid "Display message if PMS goes offline" msgstr "" msgctxt "#30030" -msgid "Port Number" +msgid "Port number" msgstr "" msgctxt "#30031" diff --git a/resources/lib/connectmanager.py b/resources/lib/connectmanager.py index b5f674f8..62c2a524 100644 --- a/resources/lib/connectmanager.py +++ b/resources/lib/connectmanager.py @@ -160,7 +160,7 @@ class ConnectManager(object): dia.set_connect_manager(self.__connect) dia.doModal() - if dia._is_connected(): + if dia.is_connected(): return dia.get_server() else: raise RuntimeError("Server is not connected") diff --git a/resources/lib/dialogs/servermanual.py b/resources/lib/dialogs/servermanual.py index 47339b99..a4518bbc 100644 --- a/resources/lib/dialogs/servermanual.py +++ b/resources/lib/dialogs/servermanual.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- ############################################################################### from logging import getLogger -import os +from os.path import join import xbmcgui -import xbmcaddon import connect.connectionmanager as connectionmanager -from utils import language as lang +from utils import language as lang, tryEncode +import variables as v ############################################################################### log = getLogger("PLEX."+__name__) -addon = xbmcaddon.Addon('plugin.video.plexkodiconnect') CONN_STATE = connectionmanager.CONNECTIONSTATE ACTION_PARENT_DIR = 9 @@ -54,10 +53,10 @@ class ServerManual(xbmcgui.WindowXMLDialog): self.cancel_button = self.getControl(CANCEL) self.error_toggle = self.getControl(ERROR_TOGGLE) self.error_msg = self.getControl(ERROR_MSG) - self.host_field = self._add_editcontrol(725, 400, 40, 500) - self.port_field = self._add_editcontrol(725, 525, 40, 500) + self.host_field = self._add_editcontrol(725, 325, 40, 500) + self.port_field = self._add_editcontrol(725, 450, 40, 500) - self.port_field.setText('8096') + self.port_field.setText('32400') self.setFocus(self.host_field) self.host_field.controlUp(self.cancel_button) @@ -78,7 +77,7 @@ class ServerManual(xbmcgui.WindowXMLDialog): if not server or not port: # Display error - self._error(ERROR['Empty'], lang(30617)) + self._error(ERROR['Empty'], lang(30021)) log.error("Server or port cannot be null") elif self._connect_to_server(server, port): @@ -97,14 +96,14 @@ class ServerManual(xbmcgui.WindowXMLDialog): self.close() def _add_editcontrol(self, x, y, height, width): - - media = os.path.join(addon.getAddonInfo('path'), 'resources', 'skins', 'default', 'media') + media = tryEncode(join( + v.ADDON_PATH, 'resources', 'skins', 'default', 'media')) control = xbmcgui.ControlEdit(0, 0, 0, 0, label="User", font="font10", textColor="ffc2c2c2", - focusTexture=os.path.join(media, "button-focus.png"), - noFocusTexture=os.path.join(media, "button-focus.png")) + focusTexture=join(media, "button-focus.png"), + noFocusTexture=join(media, "button-focus.png")) control.setPosition(x, y) control.setHeight(height) control.setWidth(width) @@ -115,11 +114,11 @@ class ServerManual(xbmcgui.WindowXMLDialog): def _connect_to_server(self, server, port): server_address = "%s:%s" % (server, port) - self._message("%s %s..." % (lang(30610), server_address)) + self._message("%s %s..." % (lang(30023), server_address)) result = self.connect_manager.connectToAddress(server_address) if result['State'] == CONN_STATE['Unavailable']: - self._message(lang(30609)) + self._message(lang(30204)) return False else: self._server = result['Servers'][0] diff --git a/resources/skins/default/1080i/script-emby-connect-server-manual.xml b/resources/skins/default/1080i/script-plex-connect-server-manual.xml similarity index 80% rename from resources/skins/default/1080i/script-emby-connect-server-manual.xml rename to resources/skins/default/1080i/script-plex-connect-server-manual.xml index 27e50037..7c8693ac 100644 --- a/resources/skins/default/1080i/script-emby-connect-server-manual.xml +++ b/resources/skins/default/1080i/script-plex-connect-server-manual.xml @@ -43,34 +43,37 @@ - Emby logo + Plex logo logo-white.png keep 120 49 - 30 - 25 + 20 + 0 + left + left 500 50 - Connect to server - + Connect to PMS + white font12 top - center + left 100% - 100 + 30 + 60 - 150 + 75 - Host - + PMS IP address or host name + ffa6a6a6 font10 top @@ -87,7 +90,7 @@ Host example - + ff464646 font10 top @@ -97,10 +100,10 @@ Port - 275 + 200 - Port label - + Port Number + ffa6a6a6 font10 top @@ -121,9 +124,9 @@ 380 Connect - box.png - box.png - + box.png + box.png + font10 ffa6a6a6 white @@ -137,7 +140,7 @@ Cancel box.png box.png - + font10 ffa6a6a6 white