diff --git a/lib/windows/dropdown.py b/lib/windows/dropdown.py index ec17afce..e4eaab89 100644 --- a/lib/windows/dropdown.py +++ b/lib/windows/dropdown.py @@ -1,5 +1,5 @@ import kodigui - +import xbmcgui from lib import util SEPARATOR = None @@ -20,6 +20,8 @@ def __init__(self, *args, **kwargs): kodigui.BaseDialog.__init__(self, *args, **kwargs) self.options = kwargs.get('options') self.pos = kwargs.get('pos') + self.lastSelectedItem = 0 + self.roundRobin = kwargs.get('round_robin', True) self.posIsBottom = kwargs.get('pos_is_bottom') self.closeDirection = kwargs.get('close_direction') self.setDropdownProp = kwargs.get('set_dropdown_prop', False) @@ -67,6 +69,26 @@ def onAction(self, action): except: util.ERROR() + if self.roundRobin and action in (xbmcgui.ACTION_MOVE_UP, xbmcgui.ACTION_MOVE_DOWN) and \ + self.getFocusId() == self.OPTIONS_LIST_ID: + to_pos = None + last_index = self.optionsList.size() - 1 + + if last_index > 0: + if action == xbmcgui.ACTION_MOVE_UP and self.lastSelectedItem == 0 and self.optionsList.topHasFocus(): + to_pos = last_index + + elif action == xbmcgui.ACTION_MOVE_DOWN and self.lastSelectedItem == last_index \ + and self.optionsList.bottomHasFocus(): + to_pos = 0 + + if to_pos is not None: + self.optionsList.setSelectedItemByPos(to_pos) + self.lastSelectedItem = to_pos + return + + self.lastSelectedItem = self.optionsList.control.getSelectedPosition() + kodigui.BaseDialog.onAction(self, action) def onClick(self, controlID): diff --git a/lib/windows/episodes.py b/lib/windows/episodes.py index 24258ace..0e4c688d 100644 --- a/lib/windows/episodes.py +++ b/lib/windows/episodes.py @@ -553,7 +553,7 @@ def optionsButtonClicked(self, from_item=False): pos = (1490, 167 + (viewPos * 100)) bottom = False setDropdownProp = True - choice = dropdown.showDropdown(options, pos, pos_is_bottom=bottom, close_direction='top', set_dropdown_prop=setDropdownProp) + choice = dropdown.showDropdown(options, pos, pos_is_bottom=bottom, close_direction='left', set_dropdown_prop=setDropdownProp) if not choice: return diff --git a/lib/windows/kodigui.py b/lib/windows/kodigui.py index ee140ded..c01d008d 100644 --- a/lib/windows/kodigui.py +++ b/lib/windows/kodigui.py @@ -500,6 +500,10 @@ def getSelectedItem(self): return None return self.getListItem(pos) + def setSelectedItemByPos(self, pos): + if self.positionIsValid(pos): + self.control.selectItem(pos) + def removeItem(self, index): old = self.items.pop(index) old.onDestroy() diff --git a/lib/windows/playersettings.py b/lib/windows/playersettings.py index 04b3e20a..bc8d7062 100644 --- a/lib/windows/playersettings.py +++ b/lib/windows/playersettings.py @@ -1,4 +1,5 @@ import xbmc +import xbmcgui import kodigui from lib import util @@ -23,6 +24,8 @@ def __init__(self, *args, **kwargs): self.video = kwargs.get('video') self.viaOSD = kwargs.get('via_osd') self.nonPlayback = kwargs.get('non_playback') + self.roundRobin = kwargs.get('round_robin', True) + self.lastSelectedItem = 0 if not self.video.mediaChoice: playerObject = plexnet.plexplayer.PlexPlayer(self.video) @@ -44,6 +47,24 @@ def onAction(self, action): except: util.ERROR() + if self.roundRobin and action in (xbmcgui.ACTION_MOVE_UP, xbmcgui.ACTION_MOVE_DOWN) and \ + self.getFocusId() == self.SETTINGS_LIST_ID: + to_pos = None + last_index = self.settingsList.size() - 1 + if action == xbmcgui.ACTION_MOVE_UP and self.lastSelectedItem == 0 and self.settingsList.topHasFocus(): + to_pos = last_index + + elif action == xbmcgui.ACTION_MOVE_DOWN and self.lastSelectedItem == last_index \ + and self.settingsList.bottomHasFocus(): + to_pos = 0 + + if to_pos is not None: + self.settingsList.setSelectedItemByPos(to_pos) + self.lastSelectedItem = to_pos + return + + self.lastSelectedItem = self.settingsList.control.getSelectedPosition() + kodigui.BaseDialog.onAction(self, action) def onClick(self, controlID): @@ -159,6 +180,8 @@ def __init__(self, *args, **kwargs): self.selectedIdx = kwargs.get('selected_idx') self.choice = None self.nonPlayback = kwargs.get('non_playback') + self.lastSelectedItem = self.selectedIdx if self.selectedIdx is not None else 0 + self.roundRobin = kwargs.get('round_robin', True) def onFirstInit(self): self.optionsList = kodigui.ManagedControlList(self, self.OPTIONS_LIST_ID, 8) @@ -174,6 +197,26 @@ def onAction(self, action): except: util.ERROR() + if self.roundRobin and action in (xbmcgui.ACTION_MOVE_UP, xbmcgui.ACTION_MOVE_DOWN) and \ + self.getFocusId() == self.OPTIONS_LIST_ID: + to_pos = None + last_index = self.optionsList.size() - 1 + + if last_index > 0: + if action == xbmcgui.ACTION_MOVE_UP and self.lastSelectedItem == 0 and self.optionsList.topHasFocus(): + to_pos = last_index + + elif action == xbmcgui.ACTION_MOVE_DOWN and self.lastSelectedItem == last_index \ + and self.optionsList.bottomHasFocus(): + to_pos = 0 + + if to_pos is not None: + self.optionsList.setSelectedItemByPos(to_pos) + self.lastSelectedItem = to_pos + return + + self.lastSelectedItem = self.optionsList.control.getSelectedPosition() + kodigui.BaseDialog.onAction(self, action) def onClick(self, controlID):