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: 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.window and self.window.isVisible()) else: if isinstance(self.manager, GenericSoftwareManager): self.manager.reset_cache() self.manager.prepare() if self.window and self.window.isVisible(): self.window.verify_warnings() self.window.types_changed = True self.window.refresh_apps() self.close() else: msg = StringIO() msg.write("<p>{}</p>".format(self.i18n['settings.error'])) for w in warnings: msg.write('<p style="font-weight: bold">* ' + w + '</p><br/>') msg.seek(0) dialog.show_message(title="Warning", body=msg.read(), type_=MessageType.WARNING)
def _save_settings(self): self.tab_group.setEnabled(False) self.bt_change.setEnabled(False) self.bt_close.setEnabled(False) success, warnings = self.manager.save_settings(self.settings_model) if success: if not self.window: dialog.show_message(title=self.i18n['success'].capitalize(), body=self.i18n['settings.changed.success.warning'], type_=MessageType.INFO) QCoreApplication.exit() elif ConfirmationDialog(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).ask(): self.close() util.restart_app() else: self.thread_reload_panel.start() QApplication.setOverrideCursor(Qt.WaitCursor) else: msg = StringIO() msg.write("<p>{}</p>".format(self.i18n['settings.error'])) for w in warnings: msg.write('<p style="font-weight: bold">* ' + w + '</p><br/>') msg.seek(0) dialog.show_message(title=self.i18n['warning'].capitalize(), body=msg.read(), type_=MessageType.WARNING)
def _finish_search(self, res: dict): self.finish_action() if not res['error']: self.ref_bt_upgrade.setVisible(False) self.update_pkgs(res['pkgs_found'], as_installed=False, ignore_updates=True) else: dialog.show_message(title=self.i18n['warning'].capitalize(), body=self.i18n[res['error']], type_=MessageType.WARNING)
def ask_root_password(context: ApplicationContext, i18n: I18n, app_config: dict = None) -> Tuple[str, bool]: cur_config = read_config() if not app_config else app_config store_password = bool(cur_config['store_root_password']) if store_password and context.root_password and validate_password(context.root_password): return context.root_password, True diag = QInputDialog() diag.setStyleSheet("""QLineEdit { border-radius: 5px; font-size: 16px; border: 1px solid lightblue }""") diag.setInputMode(QInputDialog.TextInput) diag.setTextEchoMode(QLineEdit.Password) diag.setWindowIcon(util.get_default_icon()[1]) diag.setWindowTitle(i18n['popup.root.title']) diag.setLabelText('') diag.setOkButtonText(i18n['popup.root.continue'].capitalize()) diag.setCancelButtonText(i18n['popup.button.cancel'].capitalize()) diag.resize(400, 200) for attempt in range(3): ok = diag.exec_() if ok: if not validate_password(diag.textValue()): body = i18n['popup.root.bad_password.body'] if attempt == 2: body += '. ' + i18n['popup.root.bad_password.last_try'] show_message(title=i18n['popup.root.bad_password.title'], body=body, type_=MessageType.ERROR) ok = False diag.setTextValue('') if ok: if store_password: context.root_password = diag.textValue() return diag.textValue(), ok else: break return '', False
def _save_settings(self): success, warnings = self.manager.save_settings(self.settings_model) if success: if not self.window: dialog.show_message( title=self.i18n['success'].capitalize(), body=self.i18n['settings.changed.success.warning'], type_=MessageType.INFO) QCoreApplication.exit() elif ConfirmationDialog( 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).ask(): self.close() util.restart_app() else: if isinstance(self.manager, GenericSoftwareManager): self.manager.reset_cache() self.manager.prepare(task_manager=None, root_password=None, internet_available=None) if self.window and self.window.isVisible(): self.window.update_custom_actions() self.window.verify_warnings() self.window.types_changed = True self.window.begin_refresh_packages() self.close() else: msg = StringIO() msg.write("<p>{}</p>".format(self.i18n['settings.error'])) for w in warnings: msg.write('<p style="font-weight: bold">* ' + w + '</p><br/>') msg.seek(0) dialog.show_message(title=self.i18n['warning'].capitalize(), body=msg.read(), type_=MessageType.WARNING)
def ask_root_password(locale_keys: dict): diag = QInputDialog() diag.setInputMode(QInputDialog.TextInput) diag.setTextEchoMode(QLineEdit.Password) diag.setWindowIcon(QIcon(resource.get_path('img/lock.svg'))) diag.setWindowTitle(locale_keys['popup.root.title']) diag.setLabelText(locale_keys['popup.root.password'] + ':') diag.setCancelButtonText(locale_keys['popup.button.cancel']) diag.resize(400, 200) ok = diag.exec_() if ok: if not validate_password(diag.textValue()): show_message(title=locale_keys['popup.root.bad_password.title'], body=locale_keys['popup.root.bad_password.body'], type_=MessageType.ERROR) ok = False return diag.textValue(), ok
def ask_root_password(i18n: I18n): diag = QInputDialog() diag.setStyleSheet( """QLineEdit { border-radius: 5px; font-size: 16px; border: 1px solid lightblue }""" ) diag.setInputMode(QInputDialog.TextInput) diag.setTextEchoMode(QLineEdit.Password) diag.setWindowIcon(QIcon(resource.get_path('img/lock.png'))) diag.setWindowTitle(i18n['popup.root.title']) diag.setLabelText('') diag.setOkButtonText(i18n['popup.root.continue'].capitalize()) diag.setCancelButtonText(i18n['popup.button.cancel'].capitalize()) diag.resize(400, 200) for attempt in range(3): ok = diag.exec_() if ok: if not validate_password(diag.textValue()): body = i18n['popup.root.bad_password.body'] if attempt == 2: body += '. ' + i18n['popup.root.bad_password.last_try'] show_message(title=i18n['popup.root.bad_password.title'], body=body, type_=MessageType.ERROR) ok = False diag.setTextValue('') if ok: return diag.textValue(), ok else: break return '', False
def _save_settings(self): self.tab_group.setEnabled(False) self.bt_change.setEnabled(False) self.bt_close.setEnabled(False) success, warnings = self.manager.save_settings(self.settings_model) if success: if not self.window: ConfirmationDialog(title=self.i18n['success'].capitalize(), body=f"<p>{self.i18n['settings.changed.success.warning']}</p>", i18n=self.i18n, confirmation_label=self.i18n['ok'], confirmation_icon=False, deny_button=False).ask() QCoreApplication.exit() elif ConfirmationDialog(title=self.i18n['warning'].capitalize(), body=f"<p>{self.i18n['settings.changed.success.warning']}</p>" f"<p>{self.i18n['settings.changed.success.reboot']}</p>", i18n=self.i18n).ask(): self.close() util.restart_app() else: self.thread_reload_panel.start() QApplication.setOverrideCursor(Qt.WaitCursor) else: msg = StringIO() msg.write(f"<p>{self.i18n['settings.error']}</p>") for w in warnings: msg.write(f'<p style="font-weight: bold">* {w}</p><br/>') dialog.show_message(title=self.i18n['warning'].capitalize(), body=msg.getvalue(), type_=MessageType.WARNING) self.tab_group.setEnabled(True) self.bt_change.setEnabled(True) self.bt_close.setEnabled(True)
def ask_root_password(context: ApplicationContext, i18n: I18n, app_config: dict = None) -> Tuple[str, bool]: cur_config = read_config() if not app_config else app_config store_password = bool(cur_config['store_root_password']) if store_password and context.root_password and validate_password( context.root_password): return context.root_password, True diag = QInputDialog(flags=Qt.CustomizeWindowHint | Qt.WindowTitleHint) diag.setStyleSheet( """QLineEdit { border-radius: 5px; font-size: 16px; border: 1px solid lightblue }""" ) diag.setInputMode(QInputDialog.TextInput) diag.setTextEchoMode(QLineEdit.Password) diag.setWindowIcon(util.get_default_icon()[1]) diag.setWindowTitle(i18n['popup.root.title']) diag.setLabelText('') diag.setOkButtonText(i18n['popup.root.continue'].capitalize()) diag.setCancelButtonText(i18n['popup.button.cancel'].capitalize()) bt_box = [c for c in diag.children() if isinstance(c, QDialogButtonBox)][0] for bt in bt_box.buttons(): if bt_box.buttonRole(bt) == QDialogButtonBox.AcceptRole: bt.setStyleSheet(css.OK_BUTTON) bt.setCursor(QCursor(Qt.PointingHandCursor)) bt.setIcon(QIcon()) diag.resize(400, 200) for attempt in range(3): ok = diag.exec_() if ok: if not validate_password(diag.textValue()): body = i18n['popup.root.bad_password.body'] if attempt == 2: body += '. ' + i18n['popup.root.bad_password.last_try'] show_message(title=i18n['popup.root.bad_password.title'], body=body, type_=MessageType.ERROR) ok = False diag.setTextValue('') if ok: if store_password: context.root_password = diag.textValue() return diag.textValue(), ok else: break return '', False
def _show_warnings(self, warnings: List[str]): if warnings: dialog.show_message(title=self.i18n['warning'].capitalize(), body='<p>{}</p>'.format( '<br/><br/>'.join(warnings)), type_=MessageType.WARNING)
def _show_message(self, msg: dict): self.thread_animate_progress.pause() dialog.show_message(title=msg['title'], body=msg['body'], type_=msg['type']) self.thread_animate_progress.animate()