[ui][settings] rebooting after changed

This commit is contained in:
Vinícius Moreira
2020-01-28 13:40:09 -03:00
parent 5a6575d8d0
commit b6ba643d9e
8 changed files with 33 additions and 3 deletions

View File

@@ -5,14 +5,16 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QToolBar, QSizePolicy, QPushBu
from bauh.api.abstract.controller import SoftwareManager from bauh.api.abstract.controller import SoftwareManager
from bauh.api.abstract.view import MessageType 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 import dialog, css
from bauh.view.qt.components import to_widget, new_spacer from bauh.view.qt.components import to_widget, new_spacer
from bauh.view.util import util
from bauh.view.util.translation import I18n from bauh.view.util.translation import I18n
class SettingsWindow(QWidget): 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) super(SettingsWindow, self).__init__(parent=parent)
self.setWindowTitle(i18n['settings'].capitalize()) self.setWindowTitle(i18n['settings'].capitalize())
self.setLayout(QVBoxLayout()) self.setLayout(QVBoxLayout())
@@ -20,6 +22,7 @@ class SettingsWindow(QWidget):
self.i18n = i18n self.i18n = i18n
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
self.tray = tray self.tray = tray
self.window = window
self.settings_model = self.manager.get_settings() self.settings_model = self.manager.get_settings()
@@ -48,8 +51,23 @@ class SettingsWindow(QWidget):
def _save_settings(self): def _save_settings(self):
success, warnings = self.manager.save_settings(self.settings_model) 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: if success:
self.close() if dialog.ask_confirmation(title=self.i18n['warning'].capitalize(),
body="<p>{}</p><p>{}</p>".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: else:
msg = StringIO() msg = StringIO()
msg.write("<p>It was not possible to properly save the settings</p>") msg.write("<p>It was not possible to properly save the settings</p>")

View File

@@ -1150,7 +1150,7 @@ class ManageWindow(QWidget):
self.checkbox_console.setChecked(True) self.checkbox_console.setChecked(True)
def show_settings_window(self): 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.setMinimumWidth(int(self.screen_size.width() / 4))
self.settings_window.resize(self.size()) self.settings_window.resize(self.size())
self.settings_window.adjustSize() self.settings_window.adjustSize()

View File

@@ -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=Suggestions by type
core.config.suggestions.by_type.tip=Maximum number of suggestions that should be displayed by application 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 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.en=anglès
locale.es=castellà locale.es=castellà
locale.pt=portuguès locale.pt=portuguès

View File

@@ -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=Suggestions by type
core.config.suggestions.by_type.tip=Maximum number of suggestions that should be displayed by application 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 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.en=englisch
locale.es=spanisch locale.es=spanisch
locale.pt=portugiesisch locale.pt=portugiesisch

View File

@@ -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=Suggestions by type
core.config.suggestions.by_type.tip=Maximum number of suggestions that should be displayed by application 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 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.en=english
locale.es=spanish locale.es=spanish
locale.pt=portuguese locale.pt=portuguese

View File

@@ -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=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.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 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=inglés
locale.es=español locale.es=español
locale.pt=portugués locale.pt=portugués

View File

@@ -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=Suggestions by type
core.config.suggestions.by_type.tip=Maximum number of suggestions that should be displayed by application 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 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.en=inglese
locale.es=spagnolo locale.es=spagnolo
locale.pt=portoghese locale.pt=portoghese

View File

@@ -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=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.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 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.en=inglês
locale.es=espanhol locale.es=espanhol
locale.pt=português locale.pt=português