From 827d31e49569aae141bbf321fc1a39eca6393221 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 22 Apr 2020 14:01:36 -0300 Subject: [PATCH] [improvement][trim] 'disk.trim_after_update' changed to 'disk.trim.after_upgrade' --- CHANGELOG.md | 2 ++ README.md | 4 +++- bauh/view/core/config.py | 4 +++- bauh/view/core/settings.py | 37 ++++++++++++++++++++--------------- bauh/view/qt/thread.py | 11 +++++------ bauh/view/resources/locale/ca | 4 ++-- bauh/view/resources/locale/de | 4 ++-- bauh/view/resources/locale/en | 4 ++-- bauh/view/resources/locale/es | 4 ++-- bauh/view/resources/locale/it | 4 ++-- bauh/view/resources/locale/pt | 4 ++-- bauh/view/resources/locale/ru | 4 ++-- 12 files changed, 48 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c08fb233..2fc67751 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Internet availability checking code - Arch - displaying on the details if the AUR package was successfully upgraded [#89](https://github.com/vinifmor/bauh/issues/89) +- Settings + - **disk.trim_after_update** has changed to **disk.trim.after_upgrade** and accepts 3 possible values: **false** (No): disabled, **true** (Yes): automatically trims, **null** (Ask): displays a confirmation dialog ### Fixes - Arch diff --git a/README.md b/README.md index ca8d3bfc..82690854 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,9 @@ ui: updates: check_interval: 30 # the updates checking interval in SECONDS disk: - trim_after_update: false # it trims the hard disk after a successfull packages upgrade ( `fstrim -a -v` ) + trim: + after_upgrade: false # it trims the hard disk after a successfull packages upgrade ( `fstrim -a -v` ). 'true' will automatically perform the trim and 'null' will display a confirmation dialog + backup: enabled: true # generate timeshift snapshots before an action ( if timeshift is installed on the system ) mode: 'incremental' # incremental=generates a new snapshot based on another pre-exising one. 'only_one'=deletes all pre-existing snapshots and generates a fresh one. diff --git a/bauh/view/core/config.py b/bauh/view/core/config.py index 60bc7f8c..60db6443 100644 --- a/bauh/view/core/config.py +++ b/bauh/view/core/config.py @@ -47,7 +47,9 @@ def read_config(update_file: bool = False) -> dict: }, 'store_root_password': True, 'disk': { - 'trim_after_update': False + 'trim': { + 'after_upgrade': False + } }, 'backup': { 'enabled': True, diff --git a/bauh/view/core/settings.py b/bauh/view/core/settings.py index b0bde420..c15fda9f 100644 --- a/bauh/view/core/settings.py +++ b/bauh/view/core/settings.py @@ -81,7 +81,7 @@ class GenericSettingsManager: return TabGroupComponent(tabs) def _gen_adv_settings(self, core_config: dict, screen_width: int, screen_height: int) -> TabComponent: - default_width = floor(0.11 * screen_width) + default_width = floor(0.22 * screen_width) input_data_exp = TextInputComponent(label=self.i18n['core.config.mem_cache.data_exp'], tooltip=self.i18n['core.config.mem_cache.data_exp.tip'], @@ -97,11 +97,14 @@ class GenericSettingsManager: max_width=default_width, id_="icon_exp") - select_trim_up = self._gen_bool_component(label=self.i18n['core.config.trim_after_update'], - tooltip=self.i18n['core.config.trim_after_update.tip'], - value=bool(core_config['disk']['trim_after_update']), - max_width=default_width, - id_='trim_after_update') + select_trim_up = self._gen_select(label=self.i18n['core.config.trim.after_upgrade'], + tip=self.i18n['core.config.trim.after_upgrade.tip'], + value=core_config['disk']['trim']['after_upgrade'], + max_width=default_width, + opts=[(self.i18n['yes'].capitalize(), True, None), + (self.i18n['no'].capitalize(), False, None), + (self.i18n['ask'].capitalize(), None, None)], + id_='trim_after_upgrade') select_dep_check = self._gen_bool_component(label=self.i18n['core.config.system.dep_checking'], tooltip=self.i18n['core.config.system.dep_checking.tip'], @@ -291,7 +294,7 @@ class GenericSettingsManager: icon_exp = adv_form.get_component('icon_exp').get_int_value() core_config['memory_cache']['icon_expiration'] = icon_exp - core_config['disk']['trim_after_update'] = adv_form.get_component('trim_after_update').get_selected() + core_config['disk']['trim']['after_upgrade'] = adv_form.get_component('trim_after_upgrade').get_selected() # backup if backup: @@ -434,19 +437,21 @@ class GenericSettingsManager: id_='downgrade') mode = self._gen_select(label=self.i18n['core.config.backup.mode'], - tip=None, - value=core_config['backup']['mode'], - opts=[ - (self.i18n['core.config.backup.mode.incremental'], 'incremental', self.i18n['core.config.backup.mode.incremental.tip']), - (self.i18n['core.config.backup.mode.only_one'], 'only_one', self.i18n['core.config.backup.mode.only_one.tip']) - ], - max_width=default_width, - id_='mode') + tip=None, + value=core_config['backup']['mode'], + opts=[ + (self.i18n['core.config.backup.mode.incremental'], 'incremental', + self.i18n['core.config.backup.mode.incremental.tip']), + (self.i18n['core.config.backup.mode.only_one'], 'only_one', + self.i18n['core.config.backup.mode.only_one.tip']) + ], + max_width=default_width, + id_='mode') sub_comps = [FormComponent([enabled_opt, mode, install_mode, uninstall_mode, upgrade_mode, downgrade_mode], spaces=False)] return TabComponent(self.i18n['core.config.tab.backup'].capitalize(), PanelComponent(sub_comps), None, 'core.bkp') - def _gen_select(self, label: str, tip: str, id_: str, opts: List[tuple], value: str, max_width: int, type_: SelectViewType = SelectViewType.RADIO): + def _gen_select(self, label: str, tip: str, id_: str, opts: List[tuple], value: object, max_width: int, type_: SelectViewType = SelectViewType.RADIO): inp_opts = [InputOption(label=o[0].capitalize(), value=o[1], tooltip=o[2]) for o in opts] def_opt = [o for o in inp_opts if o.value == value] return SingleSelectComponent(label=label, diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index 8b708bd2..d87c7e29 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -284,9 +284,8 @@ class UpgradeSelected(AsyncAction): return FormComponent(label=lb, components=comps), (required_size, extra_size) - def _trim_disk(self, root_password: str): - if self.request_confirmation(title=self.i18n['confirmation'].capitalize(), - body=self.i18n['action.trim_disk.ask']): + def _trim_disk(self, root_password: str, ask: bool): + if not ask or self.request_confirmation(title=self.i18n['confirmation'].capitalize(), body=self.i18n['action.trim_disk.ask']): pwd = root_password @@ -296,7 +295,7 @@ class UpgradeSelected(AsyncAction): if not success: return - self.change_status(self.i18n['action.disk_trim'].capitalize()) + self.change_status('{}...'.format(self.i18n['action.disk_trim'].capitalize())) self.change_substatus('') success, output = ProcessHandler(self).handle_simple(SimpleProcess(['fstrim', '/', '-v'], root_password=pwd)) @@ -461,8 +460,8 @@ class UpgradeSelected(AsyncAction): updated = len(requirements.to_upgrade) updated_types.update((req.pkg.__class__ for req in requirements.to_upgrade)) - if bool(app_config['disk']['trim_after_update']): - self._trim_disk(root_password) + if app_config['disk']['trim']['after_upgrade'] is not False: + self._trim_disk(root_password, ask=app_config['disk']['trim']['after_upgrade'] is None) msg = '

{}

{}


{}

'.format(self.i18n['action.update.success.reboot.line1'], self.i18n['action.update.success.reboot.line2'], diff --git a/bauh/view/resources/locale/ca b/bauh/view/resources/locale/ca index 15118223..02820225 100644 --- a/bauh/view/resources/locale/ca +++ b/bauh/view/resources/locale/ca @@ -207,8 +207,8 @@ core.config.tab.general=General core.config.tab.tray=Tray core.config.tab.types=Types core.config.tab.ui=Interface -core.config.trim_after_update=Optimize disc after upgrading -core.config.trim_after_update.tip=It optimizes the disc after a successful upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. +core.config.trim.after_upgrade=Optimize disc after upgrading +core.config.trim.after_upgrade.tip=It optimizes the disc after a successful upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. core.config.types.tip=Check the application types you want to manage core.config.ui.auto_scale=Auto scale core.config.ui.auto_scale.tip=It activates the auto screen scale factor ( {} ). It fixes scaling issues for some desktop environments. diff --git a/bauh/view/resources/locale/de b/bauh/view/resources/locale/de index dffe1dbe..e531de74 100644 --- a/bauh/view/resources/locale/de +++ b/bauh/view/resources/locale/de @@ -206,8 +206,8 @@ core.config.tab.general=Allgemein core.config.tab.tray=Statusleiste core.config.tab.types=Typen core.config.tab.ui=Oberfläche -core.config.trim_after_update=Optimize disc after upgrading -core.config.trim_after_update.tip=It optimizes the disc after a successful upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. +core.config.trim.after_upgrade=Optimize disc after upgrading +core.config.trim.after_upgrade.tip=It optimizes the disc after a successful upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. core.config.types.tip=Wählen Sie die Anwendungstypen, die Sie verwalten wollen core.config.ui.auto_scale=Automatische Skalierung core.config.ui.auto_scale.tip=Aktiviert den automatischen Skalierungsfaktor ({}), welcher bei einigen Umgebungen Skalierungsprobleme behebt diff --git a/bauh/view/resources/locale/en b/bauh/view/resources/locale/en index cbe2ced0..57f6d3b8 100644 --- a/bauh/view/resources/locale/en +++ b/bauh/view/resources/locale/en @@ -206,8 +206,8 @@ core.config.tab.general=General core.config.tab.tray=Tray core.config.tab.types=Types core.config.tab.ui=Interface -core.config.trim_after_update.tip=It optimizes the disc after a successfull upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. -core.config.trim_after_update=Optimize disc after upgrading +core.config.trim.after_upgrade=Optimize disc after upgrading +core.config.trim.after_upgrade.tip=It optimizes the disc after a successful upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. core.config.types.tip=Check the application types you want to manage core.config.ui.auto_scale.tip=It activates the auto screen scale factor ( {} ). It fixes scaling issues for some desktop environments. core.config.ui.auto_scale=Auto scale diff --git a/bauh/view/resources/locale/es b/bauh/view/resources/locale/es index fabd5d18..37aef09c 100644 --- a/bauh/view/resources/locale/es +++ b/bauh/view/resources/locale/es @@ -207,8 +207,8 @@ core.config.tab.general=Generales core.config.tab.tray=Bandeja core.config.tab.types=Tipos core.config.tab.ui=Interfaz -core.config.trim_after_update=Optimizar disco después de actualizar -core.config.trim_after_update.tip=Optimiza el disco después de una actualización exitosa usando "trim". No habilite esta opción si su disco no es un SSD que permita trim. +core.config.trim.after_upgrade=Optimizar disco después de actualizar +core.config.trim.after_upgrade.tip=Optimiza el disco después de una actualización exitosa usando "trim". No habilite esta opción si su disco no es un SSD que permita trim. core.config.types.tip=Marque los tipos de aplicaciones que desea administrar core.config.ui.auto_scale=Escala automática core.config.ui.auto_scale.tip=Activa el factor de escala de pantalla automática ( {} ). Soluciona problemas de escala para algunos ambientes desktop. diff --git a/bauh/view/resources/locale/it b/bauh/view/resources/locale/it index 1a776190..7ae7b7fb 100644 --- a/bauh/view/resources/locale/it +++ b/bauh/view/resources/locale/it @@ -207,8 +207,8 @@ core.config.tab.tray=Tray core.config.tab.types=Types core.config.tab.ui=Interface core.config.tab_label=general -core.config.trim_after_update=Optimize disc after upgrading -core.config.trim_after_update.tip=It optimizes the disc after a successfull upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. +core.config.trim.after_upgrade=Optimize disc after upgrading +core.config.trim.after_upgrade.tip=It optimizes the disc after a successful upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. core.config.types.tip=Check the application types you want to manage core.config.ui.auto_scale=Auto scale core.config.ui.auto_scale.tip=It activates the auto screen scale factor ( {} ). It fixes scaling issues for some desktop environments. diff --git a/bauh/view/resources/locale/pt b/bauh/view/resources/locale/pt index d5806ad6..b9484f8e 100644 --- a/bauh/view/resources/locale/pt +++ b/bauh/view/resources/locale/pt @@ -206,8 +206,8 @@ core.config.tab.general=Gerais core.config.tab.tray=Bandeja core.config.tab.types=Tipos core.config.tab.ui=Interface -core.config.trim_after_update.tip=Otimiza o disco após uma atualização bem sucedida utilizando "trim". Não habilite essa opção se o seu disco não for um SSD que permite trim. -core.config.trim_after_update=Otimizar disco após atualizar +core.config.trim.after_upgrade=Otimizar disco após atualizar +core.config.trim.after_upgrade.tip=Otimiza o disco após uma atualização bem sucedida utilizando "trim". Não habilite essa opção se o seu disco não for um SSD que permite trim. core.config.types.tip=Marque os tipos de aplicativo que você quer gerenciar core.config.ui.auto_scale.tip=Ativa o fator de escala automático ( {} ). Corrige problemas de escala para alguns ambientes desktop. core.config.ui.auto_scale=Escala automática diff --git a/bauh/view/resources/locale/ru b/bauh/view/resources/locale/ru index e7fdd5ee..16820c94 100644 --- a/bauh/view/resources/locale/ru +++ b/bauh/view/resources/locale/ru @@ -206,8 +206,8 @@ core.config.tab.general=Основные core.config.tab.tray=Трей core.config.tab.types=Типы core.config.tab.ui=Интерфейс -core.config.trim_after_update=Optimize disc after upgrading -core.config.trim_after_update.tip=It optimizes the disc after a successfull upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. +core.config.trim.after_upgrade=Optimize disc after upgrading +core.config.trim.after_upgrade.tip=It optimizes the disc after a successful upgrade using "trim". Do not enable this option if your disk is not a SSD that allows trim. core.config.types.tip=Отметьте типы приложений, которыми вы хотите управлять core.config.ui.auto_scale=Автоматическое масштабирование core.config.ui.auto_scale.tip=Он активирует автоматический коэффициент масштабирования экрана ({}),тем самым устраняет проблемы масштабирования для некоторых сред рабочего стола