def get_player_choices(self): current_value = self.get_player() current_choice_index = -1 supported_players, default_player = backends.getSettingsList( self.get_engine(), Settings.PLAYER) if supported_players is None: supported_players = [] default_choice_index = -1 choices = [] for player_id in supported_players: player_label = Players.get_label(player_id) list_item = xbmcgui.ListItem(player_label) list_item.setLabel2(player_id) list_item.setPath('') choices.append(list_item) if player_id == current_value: current_choice_index = len(choices) - 1 if player_id == default_player: default_choice_index = len(choices) - 1 if current_choice_index < 0: current_choice_index = default_choice_index return choices, current_choice_index
def get_language_choices(self): current_value = self.getSetting(Settings.LANGUAGE, 'unknown') languages, default_setting = backends.getSettingsList( self.get_engine(), Settings.LANGUAGE) current_choice_index = -1 choices = [] if languages is None: languages = [] languages = sorted(languages, key=lambda entry: entry[0]) default_setting_index = -1 for display_value, setting_value in languages: list_item = xbmcgui.ListItem(display_value) list_item.setLabel2(setting_value) list_item.setPath('') choices.append(list_item) if setting_value == current_value: current_choice_index = len(choices) - 1 if setting_value == default_setting: default_setting_index = len(choices) - 1 if current_choice_index == -1: current_choice_index = default_setting_index return choices, current_choice_index
def selectSetting(cls, provider, setting, *args): import backends settingsList = backends.getSettingsList(provider, setting, *args) if not settingsList: xbmcgui.Dialog().ok(T(32182), T(32186)) return displays = [] for ID, display in settingsList: displays.append(display) # xbmcgui.Dialog().select((heading, list[, autoclose, preselect, # useDetails]) auto_close = -1 current_value = Settings.getSetting(setting) current_index = -1 if current_value is not None: current_index = displays.index(str(current_value)) idx = xbmcgui.Dialog().select(T(32187), displays, auto_close, current_index) if idx < 0: return choice = displays[idx] cls._logger.info('Setting {0} for {1} set to: {2}'.format( setting, provider, choice)) Settings.setSetting('{0}.{1}'.format(setting, provider), choice)
def selectSetting(provider,setting,*args): import xbmcgui import backends settingsList = backends.getSettingsList(provider,setting,*args) if not settingsList: xbmcgui.Dialog().ok(T(32182),T(32186)) return ids = [] displays = [] for ID,display in settingsList: ids.append(ID) displays.append(display) idx = xbmcgui.Dialog().select(T(32187),displays) if idx < 0: return choice = ids[idx] LOG('Setting {0} for {1} set to: {2}'.format(setting,provider,choice)) setSetting('{0}.{1}'.format(setting,provider),choice)
def selectSetting(provider, setting, *args): import xbmcgui import backends settingsList = backends.getSettingsList(provider, setting, *args) if not settingsList: xbmcgui.Dialog().ok(T(32182), T(32186)) return ids = [] displays = [] for ID, display in settingsList: ids.append(ID) displays.append(display) idx = xbmcgui.Dialog().select(T(32187), displays) if idx < 0: return choice = ids[idx] LOG('Setting {0} for {1} set to: {2}'.format(setting, provider, choice)) setSetting('{0}.{1}'.format(setting, provider), choice)
def get_voice_choices(self): current_value = self.getSetting(Settings.VOICE, 'unknown') current_choice_index = -1 voices = backends.getSettingsList(self.get_engine(), Settings.VOICE) choices = [] if voices is None: voices = [] voices = sorted(voices, key=lambda entry: entry[0]) for display_value, setting_value in voices: list_item = xbmcgui.ListItem(display_value) list_item.setLabel2(setting_value) list_item.setPath('') choices.append(list_item) if setting_value == current_value: current_choice_index = len(choices) - 1 return choices, current_choice_index
def get_gender_choices(self): current_value = self.get_gender() current_choice_index = -1 # Fetch settings on every access because it can change engine = self.get_engine() supported_genders = backends.getSettingsList(engine, Settings.GENDER) if supported_genders is None: supported_genders = [] choices = [] for gender_id in supported_genders: display_value = Genders.get_label(gender_id) list_item = xbmcgui.ListItem(display_value) list_item.setLabel2(gender_id) list_item.setPath('') choices.append(list_item) if gender_id == current_value: current_choice_index = len(choices) - 1 return choices, current_choice_index