diff --git a/addon.xml b/addon.xml index 97ef4e0d..b37f1adc 100644 --- a/addon.xml +++ b/addon.xml @@ -17,19 +17,19 @@ - - + + Settings for the Emby Server - [!IsEmpty(ListItem.DBID) + !StringCompare(ListItem.DBID,-1)] | !IsEmpty(ListItem.Property(embyid)) - - + [!IsEmpty(ListItem.DBID) + !StringCompare(ListItem.DBID,-1) | !IsEmpty(ListItem.Property(embyid))] + !IsEmpty(Window(10000).Property(emby_context)) + + all en GNU GENERAL PUBLIC LICENSE. Version 2, June 1991 - + http://emby.media/community/index.php?/forum/99-kodi/ http://emby.media/ - + https://github.com/MediaBrowser/plugin.video.emby Welcome to Emby for Kodi A whole new way to manage and view your media library. The Emby addon for Kodi combines the best of Kodi - ultra smooth navigation, beautiful UIs and playback of any file under the sun, and Emby - the most powerful fully open source multi-client media metadata indexer and server. Emby for Kodi is the absolute best way to enjoy the incredible Kodi playback engine combined with the power of Emby's centralized database. Features: Direct integration with the Kodi library for native Kodi speed Instant synchronization with the Emby server Full support for Movie, TV and Music collections Emby Server direct stream and transcoding support - use Kodi when you are away from home! diff --git a/contextmenu.py b/contextmenu.py index 08efa137..5e90058d 100644 --- a/contextmenu.py +++ b/contextmenu.py @@ -24,6 +24,7 @@ import read_embyserver as embyserver import embydb_functions as embydb import musicutils as musicutils from utils import settings, dialog, language as lang, kodiSQL +from dialogs import context ################################################################################################# @@ -130,9 +131,13 @@ class ContextMenu(object): # Addon settings options.append(OPTIONS['Addon']) - resp = dialog(type_="select", heading=lang(30401), list=options) - if resp > -1: - self._selected_option = options[resp] + addon = xbmcaddon.Addon('plugin.video.emby') + XML_PATH = (addon.getAddonInfo('path'), "default", "1080i") + dialog = context.ContextMenu("script-emby-context.xml", *XML_PATH) + dialog.set_options(options) + dialog.doModal() + if dialog.is_selected(): + self._selected_option = dialog.get_selected() return self._selected_option diff --git a/resources/lib/dialogs/context.py b/resources/lib/dialogs/context.py new file mode 100644 index 00000000..670d6463 --- /dev/null +++ b/resources/lib/dialogs/context.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- + +################################################################################################## + +import logging +import os + +import xbmcgui +import xbmcaddon + +from utils import language as lang + +################################################################################################## + +log = logging.getLogger("EMBY."+__name__) +addon = xbmcaddon.Addon('plugin.video.emby') + +ACTION_PARENT_DIR = 9 +ACTION_PREVIOUS_MENU = 10 +ACTION_BACK = 92 +ACTION_SELECT_ITEM = 7 +ACTION_MOUSE_LEFT_CLICK = 100 +LIST = 155 + +################################################################################################## + + +class ContextMenu(xbmcgui.WindowXMLDialog): + + _options = [] + selected_option = None + + + def __init__(self, *args, **kwargs): + + xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs) + + def set_options(self, options=[]): + self._options = options + + def is_selected(self): + return True if self.selected_option else False + + def get_selected(self): + return self.selected_option + + def onInit(self): + + height = 479 + (len(self._options) * 55) + log.info("options: %s", self._options) + self.list_ = self.getControl(LIST) + + for option in self._options: + self.list_.addItem(self._add_listitem(option)) + + self.background = self._add_editcontrol(730, height, 30, 450) + self.setFocus(self.list_) + + def onAction(self, action): + + if action in (ACTION_BACK, ACTION_PARENT_DIR, ACTION_PREVIOUS_MENU): + self.close() + + if action in (ACTION_SELECT_ITEM, ACTION_MOUSE_LEFT_CLICK): + + if self.getFocusId() == LIST: + option = self.list_.getSelectedItem() + self.selected_option = option.getLabel() + log.info('option selected: %s', self.selected_option) + + self.close() + + def _add_editcontrol(self, x, y, height, width, password=0): + + media = os.path.join(addon.getAddonInfo('path'), 'resources', 'skins', 'default', 'media') + control = xbmcgui.ControlImage(0, 0, 0, 0, + filename=os.path.join(media, "white.png"), + aspectRatio=0, + colorDiffuse="ff111111") + control.setPosition(x, y) + control.setHeight(height) + control.setWidth(width) + + self.addControl(control) + return control + + @classmethod + def _add_listitem(cls, label): + return xbmcgui.ListItem(label) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 35efa40f..da15013d 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -49,6 +49,11 @@ class KodiMonitor(xbmc.Monitor): log.info("New log level: %s", current_log_level) window('emby_logLevel', value=current_log_level) + current_context = "true" if settings('enableContext') == "true" else "" + if window('emby_context') != current_context: + log.info("New context setting: %s", current_context) + window('emby_context', value=current_context) + def onNotification(self, sender, method, data): if method not in ('Playlist.OnAdd', 'Player.OnStop', 'Player.OnClear'): diff --git a/resources/settings.xml b/resources/settings.xml index f7787d3e..7eae30e8 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -63,7 +63,8 @@ - + + diff --git a/resources/skins/default/1080i/script-emby-context.xml b/resources/skins/default/1080i/script-emby-context.xml new file mode 100644 index 00000000..276f4940 --- /dev/null +++ b/resources/skins/default/1080i/script-emby-context.xml @@ -0,0 +1,100 @@ + + + 155 + 0 + dialogeffect + + + Background fade + 100% + 100% + emby-bg-fade.png + + + + 450 + 38% + 36% + + Background box + white.png + 90 + + + + Emby logo + emby-icon.png + keep + 40 + 15 + 370 + + + + separator + 100% + 0.5 + 70 + -5 + emby-separator.png + + + + 450 + 90 + + 100% + 100% + center + 155 + 155 + 155 + 155 + 200 + + + Background box + 450 + white.png + + + 400 + font11 + ff525252 + 25 + center + center + ListItem.Label + + + + + + Background box + 450 + white.png + + + 400 + 25 + center + white.png + Control.HasFocus(155) + Visible + Hidden + + + 400 + font11 + white + 25 + center + center + ListItem.Label + + + + + + + \ No newline at end of file diff --git a/resources/skins/default/media/emby-icon.png b/resources/skins/default/media/emby-icon.png new file mode 100644 index 00000000..cb7c85ca Binary files /dev/null and b/resources/skins/default/media/emby-icon.png differ diff --git a/service.py b/service.py index 1e241927..944500d7 100644 --- a/service.py +++ b/service.py @@ -60,6 +60,8 @@ class Service(object): window('emby_logLevel', value=str(log_level)) window('emby_kodiProfile', value=xbmc.translatePath('special://profile')) + context_menu = "true" if settings('enableContext') == "true" else "" + window('emby_context', value=context_menu) # Initial logging log.warn("======== START %s ========", self.addon_name)