def save(self): enabled_gems = [op.value for op in self.gem_select_model.values] for module, man in self.gem_map.items(): enabled = module in enabled_gems man.set_enabled(enabled) self.config.enabled_gems = enabled_gems save(self.config) self.manager.reset_cache() self.manager.prepare() self.window.verify_warnings() self.window.refresh_apps() self.close()
def save(self): enabled_gems = [op.value for op in self.gem_select_model.values] for module, man in self.gem_map.items(): enabled = module in enabled_gems man.set_enabled(enabled) self.config['gems'] = enabled_gems save(self.config) self.manager.reset_cache() self.manager.prepare() self.window.verify_warnings() self.window.types_changed = True self.window.begin_refresh_packages() self.close()
def change_style(self, idx: int): if dialog.ask_confirmation( self.i18n['style.change.title'], self.i18n['style.change.question'].format(bold(__app_name__)), self.i18n): self.last_index = idx style = self.styles[idx] user_config = config.read() user_config.style = style config.save(user_config) util.restart_app(self.show_panel_after_restart) else: self.blockSignals(True) self.setCurrentIndex(self.last_index) self.blockSignals(False)
def _save_settings(self, general: PanelComponent, advanced: PanelComponent, backup: PanelComponent, ui: PanelComponent, tray: PanelComponent, gems_panel: PanelComponent) -> Tuple[bool, List[str]]: core_config = config.read_config() # general general_form = general.components[0] locale = general_form.get_component('locale').get_selected() if locale != self.i18n.current_key: core_config['locale'] = locale core_config['system']['notifications'] = general_form.get_component('sys_notify').get_selected() core_config['suggestions']['enabled'] = general_form.get_component('sugs_enabled').get_selected() core_config['store_root_password'] = general_form.get_component('store_pwd').get_selected() sugs_by_type = general_form.get_component('sugs_by_type').get_int_value() core_config['suggestions']['by_type'] = sugs_by_type core_config['updates']['ask_for_reboot'] = general_form.get_component('ask_for_reboot').get_selected() # advanced adv_form = advanced.components[0] download_mthreaded = adv_form.get_component('down_mthread').get_selected() core_config['download']['multithreaded'] = download_mthreaded mthread_client = adv_form.get_component('mthread_client').get_selected() core_config['download']['multithreaded_client'] = mthread_client if isinstance(self.file_downloader, AdaptableFileDownloader): self.file_downloader.multithread_client = mthread_client self.file_downloader.multithread_enabled = download_mthreaded single_dep_check = adv_form.get_component('dep_check').get_selected() core_config['system']['single_dependency_checking'] = single_dep_check data_exp = adv_form.get_component('data_exp').get_int_value() core_config['memory_cache']['data_expiration'] = data_exp icon_exp = adv_form.get_component('icon_exp').get_int_value() core_config['memory_cache']['icon_expiration'] = icon_exp core_config['disk']['trim']['after_upgrade'] = adv_form.get_component('trim_after_upgrade').get_selected() # backup if backup: bkp_form = backup.components[0] core_config['backup']['enabled'] = bkp_form.get_component('enabled').get_selected() core_config['backup']['mode'] = bkp_form.get_component('mode').get_selected() core_config['backup']['type'] = bkp_form.get_component('type').get_selected() core_config['backup']['install'] = bkp_form.get_component('install').get_selected() core_config['backup']['uninstall'] = bkp_form.get_component('uninstall').get_selected() core_config['backup']['upgrade'] = bkp_form.get_component('upgrade').get_selected() core_config['backup']['downgrade'] = bkp_form.get_component('downgrade').get_selected() # tray tray_form = tray.components[0] core_config['updates']['check_interval'] = tray_form.get_component('updates_interval').get_int_value() def_icon_path = tray_form.get_component('def_icon').file_path core_config['ui']['tray']['default_icon'] = def_icon_path if def_icon_path else None up_icon_path = tray_form.get_component('up_icon').file_path core_config['ui']['tray']['updates_icon'] = up_icon_path if up_icon_path else None # ui ui_form = ui.components[0] core_config['download']['icons'] = ui_form.get_component('down_icons').get_selected() core_config['ui']['hdpi'] = ui_form.get_component('hdpi').get_selected() previous_autoscale = core_config['ui']['auto_scale'] core_config['ui']['auto_scale'] = ui_form.get_component('auto_scale').get_selected() if previous_autoscale and not core_config['ui']['auto_scale']: self.logger.info("Deleting environment variable QT_AUTO_SCREEN_SCALE_FACTOR") del os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] core_config['ui']['scale_factor'] = ui_form.get_component('scalef').value / 100 core_config['ui']['table']['max_displayed'] = ui_form.get_component('table_max').get_int_value() style = ui_form.get_component('style').get_selected() cur_style = core_config['ui']['style'] if core_config['ui']['style'] else QApplication.instance().style().objectName().lower() if style != cur_style: core_config['ui']['style'] = style # gems checked_gems = gems_panel.components[1].get_component('gems').get_selected_values() for man in self.managers: modname = man.__module__.split('.')[-2] enabled = modname in checked_gems man.set_enabled(enabled) core_config['gems'] = None if core_config['gems'] is None and len(checked_gems) == len(self.managers) else checked_gems try: config.save(core_config) return True, None except: return False, [traceback.format_exc()]