def _gen_general_settings(self, core_config: dict, screen_width: int, screen_height: int) -> TabComponent: default_width = floor(0.11 * screen_width) locale_opts = [InputOption(label=self.i18n['locale.{}'.format(k)].capitalize(), value=k) for k in translation.get_available_keys()] current_locale = None if core_config['locale']: current_locale = [l for l in locale_opts if l.value == core_config['locale']] if not current_locale: if self.i18n.current_key: current_locale = [l for l in locale_opts if l.value == self.i18n.current_key] if not current_locale: current_locale = [l for l in locale_opts if l.value == self.i18n.default_key] current_locale = current_locale[0] if current_locale else None select_locale = SingleSelectComponent(label=self.i18n['core.config.locale.label'], options=locale_opts, default_option=current_locale, type_=SelectViewType.COMBO, max_width=default_width, id_='locale') select_store_pwd = self._gen_bool_component(label=self.i18n['core.config.store_password'].capitalize(), tooltip=self.i18n['core.config.store_password.tip'].capitalize(), id_="store_pwd", max_width=default_width, value=bool(core_config['store_root_password'])) select_sysnotify = self._gen_bool_component(label=self.i18n['core.config.system.notifications'].capitalize(), tooltip=self.i18n['core.config.system.notifications.tip'].capitalize(), value=bool(core_config['system']['notifications']), max_width=default_width, id_="sys_notify") select_sugs = self._gen_bool_component(label=self.i18n['core.config.suggestions.activated'].capitalize(), tooltip=self.i18n['core.config.suggestions.activated.tip'].capitalize(), id_="sugs_enabled", max_width=default_width, value=bool(core_config['suggestions']['enabled'])) inp_sugs = TextInputComponent(label=self.i18n['core.config.suggestions.by_type'], tooltip=self.i18n['core.config.suggestions.by_type.tip'], value=str(core_config['suggestions']['by_type']), only_int=True, max_width=default_width, id_="sugs_by_type") inp_reboot = self._gen_select(label=self.i18n['core.config.updates.reboot'], tip=self.i18n['core.config.updates.reboot.tip'], id_='ask_for_reboot', max_width=default_width, value=bool(core_config['updates']['ask_for_reboot']), opts=[(self.i18n['ask'].capitalize(), True, None), (self.i18n['no'].capitalize(), False, None)]) sub_comps = [FormComponent([select_locale, select_store_pwd, select_sysnotify, select_sugs, inp_sugs, inp_reboot], spaces=False)] return TabComponent(self.i18n['core.config.tab.general'].capitalize(), PanelComponent(sub_comps), None, 'core.gen')
def _gen_general_settings(self, core_config: dict) -> TabComponent: locale_keys = translation.get_available_keys() locale_opts = [ InputOption(label=self.i18n[f'locale.{k}'].capitalize(), value=k) for k in locale_keys ] current_locale = None if core_config['locale']: current_locale = [ loc for loc in locale_opts if loc.value == core_config['locale'] ] if not current_locale: if self.i18n.current_key: current_locale = [ loc for loc in locale_opts if loc.value == self.i18n.current_key ] if not current_locale: current_locale = [ loc for loc in locale_opts if loc.value == self.i18n.default_key ] current_locale = current_locale[0] if current_locale else None sel_locale = SingleSelectComponent( label=self.i18n['core.config.locale.label'], options=locale_opts, default_option=current_locale, type_=SelectViewType.COMBO, alignment=ViewComponentAlignment.CENTER, id_='locale') sel_store_pwd = self._gen_bool_component( label=self.i18n['core.config.store_password'].capitalize(), tooltip=self.i18n['core.config.store_password.tip'].capitalize(), id_="store_pwd", value=bool(core_config['store_root_password'])) notify_tip = self.i18n[ 'core.config.system.notifications.tip'].capitalize() sel_sys_notify = self._gen_bool_component( label=self.i18n['core.config.system.notifications'].capitalize(), tooltip=notify_tip, value=bool(core_config['system']['notifications']), id_="sys_notify") sel_load_apps = self._gen_bool_component( label=self.i18n['core.config.boot.load_apps'], tooltip=self.i18n['core.config.boot.load_apps.tip'], value=bool(core_config['boot']['load_apps']), id_='boot.load_apps') sel_sugs = self._gen_bool_component( label=self.i18n['core.config.suggestions.activated'].capitalize(), tooltip=self.i18n['core.config.suggestions.activated.tip']. capitalize(), id_="sugs_enabled", value=bool(core_config['suggestions']['enabled'])) inp_sugs = TextInputComponent( label=self.i18n['core.config.suggestions.by_type'], tooltip=self.i18n['core.config.suggestions.by_type.tip'], value=str(core_config['suggestions']['by_type']), only_int=True, id_="sugs_by_type") inp_reboot = new_select( label=self.i18n['core.config.updates.reboot'], tip=self.i18n['core.config.updates.reboot.tip'], id_='ask_for_reboot', max_width=None, value=bool(core_config['updates']['ask_for_reboot']), opts=[(self.i18n['ask'].capitalize(), True, None), (self.i18n['no'].capitalize(), False, None)]) inputs = [ sel_locale, sel_store_pwd, sel_sys_notify, sel_load_apps, inp_reboot, sel_sugs, inp_sugs ] panel = PanelComponent([FormComponent(inputs, spaces=False)], id_='general') return TabComponent(self.i18n['core.config.tab.general'].capitalize(), panel, None, 'core.gen')