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
commit 89fe64d019
8 changed files with 213 additions and 11 deletions

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)
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'):

View file

@ -63,7 +63,8 @@
<category label="30235"><!-- Extras -->
<setting id="enableCoverArt" type="bool" label="30157" default="true" />
<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 type="lsep" label="30534" />
<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