Update context menu

Also add the option to disable the context menu within the add-on
settings >  extras
This commit is contained in:
angelblue05 2016-09-17 06:12:37 -05:00
parent 2a6ad7bd11
commit 89fe64d019
8 changed files with 213 additions and 11 deletions

View file

@ -20,16 +20,16 @@
<item> <item>
<label>30401</label> <label>30401</label>
<description>Settings for the Emby Server</description> <description>Settings for the Emby Server</description>
<visible>[!IsEmpty(ListItem.DBID) + !StringCompare(ListItem.DBID,-1)] | !IsEmpty(ListItem.Property(embyid))</visible> <visible>[!IsEmpty(ListItem.DBID) + !StringCompare(ListItem.DBID,-1) | !IsEmpty(ListItem.Property(embyid))] + !IsEmpty(Window(10000).Property(emby_context))</visible>
</item> </item>
</extension> </extension>
<extension point="xbmc.addon.metadata"> <extension point="xbmc.addon.metadata">
<platform>all</platform> <platform>all</platform>
<language>en</language> <language>en</language>
<license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license> <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
<forum></forum> <forum>http://emby.media/community/index.php?/forum/99-kodi/</forum>
<website>http://emby.media/</website> <website>http://emby.media/</website>
<source></source> <source>https://github.com/MediaBrowser/plugin.video.emby</source>
<summary lang="en"></summary> <summary lang="en"></summary>
<description lang="en">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.&#10;&#10;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!</description> <description lang="en">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.&#10;&#10;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!</description>
</extension> </extension>

View file

@ -24,6 +24,7 @@ import read_embyserver as embyserver
import embydb_functions as embydb import embydb_functions as embydb
import musicutils as musicutils import musicutils as musicutils
from utils import settings, dialog, language as lang, kodiSQL from utils import settings, dialog, language as lang, kodiSQL
from dialogs import context
################################################################################################# #################################################################################################
@ -130,9 +131,13 @@ class ContextMenu(object):
# Addon settings # Addon settings
options.append(OPTIONS['Addon']) options.append(OPTIONS['Addon'])
resp = dialog(type_="select", heading=lang(30401), list=options) addon = xbmcaddon.Addon('plugin.video.emby')
if resp > -1: XML_PATH = (addon.getAddonInfo('path'), "default", "1080i")
self._selected_option = options[resp] 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 return self._selected_option

View file

@ -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)

View file

@ -49,6 +49,11 @@ class KodiMonitor(xbmc.Monitor):
log.info("New log level: %s", current_log_level) log.info("New log level: %s", current_log_level)
window('emby_logLevel', value=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): def onNotification(self, sender, method, data):
if method not in ('Playlist.OnAdd', 'Player.OnStop', 'Player.OnClear'): if method not in ('Playlist.OnAdd', 'Player.OnStop', 'Player.OnClear'):

View file

@ -63,7 +63,8 @@
<category label="30235"><!-- Extras --> <category label="30235"><!-- Extras -->
<setting id="enableCoverArt" type="bool" label="30157" default="true" /> <setting id="enableCoverArt" type="bool" label="30157" default="true" />
<setting id="ignoreSpecialsNextEpisodes" type="bool" label="30527" default="false" /> <setting id="ignoreSpecialsNextEpisodes" type="bool" label="30527" default="false" />
<setting id="skipContextMenu" type="bool" label="30520" default="false" /> <setting id="enableContext" type="bool" label="Enable the Emby context menu" default="true" />
<setting id="skipContextMenu" type="bool" label="30520" default="false" visible="eq(-1,true)" subsetting="true" />
<setting id="additionalUsers" type="text" label="30528" default="" /> <setting id="additionalUsers" type="text" label="30528" default="" />
<setting type="lsep" label="30534" /> <setting type="lsep" label="30534" />
<setting id="connectMsg" type="bool" label="30249" default="true" /> <setting id="connectMsg" type="bool" label="30249" default="true" />

View file

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<window>
<defaultcontrol always="true">155</defaultcontrol>
<zorder>0</zorder>
<include>dialogeffect</include>
<controls>
<control type="image">
<description>Background fade</description>
<width>100%</width>
<height>100%</height>
<texture>emby-bg-fade.png</texture>
</control>
<control type="group">
<width>450</width>
<left>38%</left>
<top>36%</top>
<control type="image">
<description>Background box</description>
<texture colordiffuse="ff111111">white.png</texture>
<height>90</height>
</control>
<control type="image">
<description>Emby logo</description>
<texture>emby-icon.png</texture>
<aspectratio>keep</aspectratio>
<height>40</height>
<top>15</top>
<left>370</left>
</control>
<control type="image">
<description>separator</description>
<width>100%</width>
<height>0.5</height>
<top>70</top>
<left>-5</left>
<texture colordiffuse="ff484848" border="90,3,90,3">emby-separator.png</texture>
</control>
<control type="group">
<width>450</width>
<top>90</top>
<control type="list" id="155">
<width>100%</width>
<height>100%</height>
<align>center</align>
<onup>155</onup>
<ondown>155</ondown>
<onleft>155</onleft>
<onright>155</onright>
<scrolltime>200</scrolltime>
<itemlayout height="55">
<control type="image">
<description>Background box</description>
<width>450</width>
<texture colordiffuse="ff111111">white.png</texture>
</control>
<control type="label">
<width>400</width>
<font>font11</font>
<textcolor>ff525252</textcolor>
<left>25</left>
<align>center</align>
<aligny>center</aligny>
<info>ListItem.Label</info>
</control>
</itemlayout>
<focusedlayout height="55">
<control type="image">
<description>Background box</description>
<width>450</width>
<texture colordiffuse="ff111111">white.png</texture>
</control>
<control type="image">
<width>400</width>
<left>25</left>
<align>center</align>
<texture border="5" colordiffuse="ff222222">white.png</texture>
<visible>Control.HasFocus(155)</visible>
<animation effect="fade" time="300">Visible</animation>
<animation effect="fade" time="300">Hidden</animation>
</control>
<control type="label">
<width>400</width>
<font>font11</font>
<textcolor>white</textcolor>
<left>25</left>
<align>center</align>
<aligny>center</aligny>
<info>ListItem.Label</info>
</control>
</focusedlayout>
</control>
</control>
</control>
</controls>
</window>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -60,6 +60,8 @@ class Service(object):
window('emby_logLevel', value=str(log_level)) window('emby_logLevel', value=str(log_level))
window('emby_kodiProfile', value=xbmc.translatePath('special://profile')) window('emby_kodiProfile', value=xbmc.translatePath('special://profile'))
context_menu = "true" if settings('enableContext') == "true" else ""
window('emby_context', value=context_menu)
# Initial logging # Initial logging
log.warn("======== START %s ========", self.addon_name) log.warn("======== START %s ========", self.addon_name)