From b6ba643d9e6ab5c012e3571c2e47d4dfebbd03c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moreira?= Date: Tue, 28 Jan 2020 13:40:09 -0300 Subject: [PATCH] [ui][settings] rebooting after changed --- bauh/view/qt/settings.py | 22 ++++++++++++++++++++-- bauh/view/qt/window.py | 2 +- bauh/view/resources/locale/ca | 2 ++ bauh/view/resources/locale/de | 2 ++ bauh/view/resources/locale/en | 2 ++ bauh/view/resources/locale/es | 2 ++ bauh/view/resources/locale/it | 2 ++ bauh/view/resources/locale/pt | 2 ++ 8 files changed, 33 insertions(+), 3 deletions(-) diff --git a/bauh/view/qt/settings.py b/bauh/view/qt/settings.py index 89d53fcd..be12a8a6 100644 --- a/bauh/view/qt/settings.py +++ b/bauh/view/qt/settings.py @@ -5,14 +5,16 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QToolBar, QSizePolicy, QPushBu from bauh.api.abstract.controller import SoftwareManager from bauh.api.abstract.view import MessageType +from bauh.view.core.controller import GenericSoftwareManager from bauh.view.qt import dialog, css from bauh.view.qt.components import to_widget, new_spacer +from bauh.view.util import util from bauh.view.util.translation import I18n class SettingsWindow(QWidget): - def __init__(self, manager: SoftwareManager, i18n: I18n, screen_size: QSize, tray: bool, parent: QWidget = None): + def __init__(self, manager: SoftwareManager, i18n: I18n, screen_size: QSize, tray: bool, window: QWidget, parent: QWidget = None): super(SettingsWindow, self).__init__(parent=parent) self.setWindowTitle(i18n['settings'].capitalize()) self.setLayout(QVBoxLayout()) @@ -20,6 +22,7 @@ class SettingsWindow(QWidget): self.i18n = i18n self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) self.tray = tray + self.window = window self.settings_model = self.manager.get_settings() @@ -48,8 +51,23 @@ class SettingsWindow(QWidget): def _save_settings(self): success, warnings = self.manager.save_settings(self.settings_model) + # Configurações alteradas com sucesso, porém algumas delas só surtirão após a reinicialização + if success: - self.close() + if dialog.ask_confirmation(title=self.i18n['warning'].capitalize(), + body="

{}

{}

".format(self.i18n['settings.changed.success.warning'], + self.i18n['settings.changed.success.reboot']), + i18n=self.i18n): + util.restart_app(self.tray) + else: + if isinstance(self.manager, GenericSoftwareManager): + self.manager.reset_cache() + + self.manager.prepare() + self.window.verify_warnings() + self.window.types_changed = True + self.window.refresh_apps() + self.close() else: msg = StringIO() msg.write("

It was not possible to properly save the settings

") diff --git a/bauh/view/qt/window.py b/bauh/view/qt/window.py index 8c06d76b..9f450789 100755 --- a/bauh/view/qt/window.py +++ b/bauh/view/qt/window.py @@ -1150,7 +1150,7 @@ class ManageWindow(QWidget): self.checkbox_console.setChecked(True) def show_settings_window(self): - self.settings_window = SettingsWindow(self.manager, self.i18n, self.screen_size, bool(self.tray_icon)) + self.settings_window = SettingsWindow(self.manager, self.i18n, self.screen_size, bool(self.tray_icon), self) self.settings_window.setMinimumWidth(int(self.screen_size.width() / 4)) self.settings_window.resize(self.size()) self.settings_window.adjustSize() diff --git a/bauh/view/resources/locale/ca b/bauh/view/resources/locale/ca index 9cff9e9a..665b2792 100644 --- a/bauh/view/resources/locale/ca +++ b/bauh/view/resources/locale/ca @@ -252,6 +252,8 @@ core.config.system.dep_checking.tip=If the availability checking of your system core.config.suggestions.by_type=Suggestions by type core.config.suggestions.by_type.tip=Maximum number of suggestions that should be displayed by application type core.config.types.tip=Check the application types you want to manage +settings.changed.success.warning=Settings successfully changed. Some of them will only take effect after the restart. +settings.changed.success.reboot=Restart now ? locale.en=anglès locale.es=castellà locale.pt=portuguès diff --git a/bauh/view/resources/locale/de b/bauh/view/resources/locale/de index adf959ad..f8886dd8 100644 --- a/bauh/view/resources/locale/de +++ b/bauh/view/resources/locale/de @@ -207,6 +207,8 @@ core.config.system.dep_checking.tip=If the availability checking of your system core.config.suggestions.by_type=Suggestions by type core.config.suggestions.by_type.tip=Maximum number of suggestions that should be displayed by application type core.config.types.tip=Check the application types you want to manage +settings.changed.success.warning=Settings successfully changed. Some of them will only take effect after the restart. +settings.changed.success.reboot=Restart now ? locale.en=englisch locale.es=spanisch locale.pt=portugiesisch diff --git a/bauh/view/resources/locale/en b/bauh/view/resources/locale/en index e8f3cbea..281ba6d8 100644 --- a/bauh/view/resources/locale/en +++ b/bauh/view/resources/locale/en @@ -214,6 +214,8 @@ core.config.system.dep_checking.tip=If the availability checking of your system core.config.suggestions.by_type=Suggestions by type core.config.suggestions.by_type.tip=Maximum number of suggestions that should be displayed by application type core.config.types.tip=Check the application types you want to manage +settings.changed.success.warning=Settings successfully changed. Some of them will only take effect after the restart. +settings.changed.success.reboot=Restart now ? locale.en=english locale.es=spanish locale.pt=portuguese diff --git a/bauh/view/resources/locale/es b/bauh/view/resources/locale/es index e8bdd025..089f77e1 100644 --- a/bauh/view/resources/locale/es +++ b/bauh/view/resources/locale/es @@ -255,6 +255,8 @@ core.config.system.dep_checking.tip=Si la verificación de disponibilidad de las core.config.suggestions.by_type=Sugerencias por tipo core.config.suggestions.by_type.tip=Número máximo de sugerencias que deberían mostrarse por tipo de aplicación core.config.types.tip=Marque los tipos de aplicaciones que desea administrar +settings.changed.success.warning=Las configuraciones se cambiaron con éxito. Algunas solo tendrán efecto después del reinicio. +settings.changed.success.reboot=¿Reiniciar ahora? locale.es=inglés locale.es=español locale.pt=portugués diff --git a/bauh/view/resources/locale/it b/bauh/view/resources/locale/it index ecd3f08a..bc1a2416 100644 --- a/bauh/view/resources/locale/it +++ b/bauh/view/resources/locale/it @@ -207,6 +207,8 @@ core.config.system.dep_checking.tip=If the availability checking of your system core.config.suggestions.by_type=Suggestions by type core.config.suggestions.by_type.tip=Maximum number of suggestions that should be displayed by application type core.config.types.tip=Check the application types you want to manage +settings.changed.success.warning=Settings successfully changed. Some of them will only take effect after the restart. +settings.changed.success.reboot=Restart now ? locale.en=inglese locale.es=spagnolo locale.pt=portoghese diff --git a/bauh/view/resources/locale/pt b/bauh/view/resources/locale/pt index 2726a99d..443bd235 100644 --- a/bauh/view/resources/locale/pt +++ b/bauh/view/resources/locale/pt @@ -258,6 +258,8 @@ core.config.system.dep_checking.tip=Se a verificação da disponibilidade das te core.config.suggestions.by_type=Sugestões por tipo core.config.suggestions.by_type.tip=Número máximo de sugestões que devem ser exibidas por tipo de aplicativo core.config.types.tip=Marque os tipos de aplicativo que você quer gerenciar +settings.changed.success.warning=Configurações alteradas com sucesso ! Algumas delas só surtirão após a reinicialização. +settings.changed.success.reboot=Reiniciar agora ? locale.en=inglês locale.es=espanhol locale.pt=português