Added progress bar to __save_changes__

This commit is contained in:
donoban 2019-02-16 15:56:46 +01:00
parent a9a2022206
commit bb7b8c79ae
No known key found for this signature in database
GPG Key ID: 141310D8E3ED08A5

View File

@ -276,17 +276,30 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
def __save_changes__(self):
ret = []
self.progress = QtGui.QProgressDialog(
self.tr( # Last param should match last setValue()
"Saving changes..."), "", 0, 6)
self.progress.setMinimumDuration(1000)
self.progress.setCancelButton(None)
self.progress.setModal(True)
self.progress.show()
self.progress.setValue(0)
try:
ret_tmp = self.__apply_basic_tab__()
self.progress.setValue(1)
if ret_tmp:
ret += ["Basic tab:"] + ret_tmp
ret_tmp = self.__apply_advanced_tab__()
self.progress.setValue(2)
if ret_tmp:
ret += ["Advanced tab:"] + ret_tmp
ret_tmp = self.__apply_devices_tab__()
self.progress.setValue(3)
if ret_tmp:
ret += ["Devices tab:"] + ret_tmp
ret_tmp = self.__apply_services_tab__()
self.progress.setValue(4)
if ret_tmp:
ret += ["Sevices tab:"] + ret_tmp
except qubesadmin.exc.QubesException as qex:
@ -294,6 +307,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except Exception as ex: # pylint: disable=broad-except
ret.append(repr(ex))
self.progress.setValue(4)
try:
if self.policy_allow_radio_button.isEnabled():
self.fw_model.apply_rules(
@ -305,6 +320,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except Exception as ex: # pylint: disable=broad-except
ret += [self.tr("Firewall tab:"), repr(ex)]
self.progress.setValue(5)
try:
if self.tabWidget.isTabEnabled(self.tabs_indices["applications"]):
self.app_list_manager.save_appmenu_select_changes()
@ -313,6 +330,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except Exception as ex: # pylint: disable=broad-except
ret += [self.tr("Applications tab:"), repr(ex)]
self.progress.setValue(6) # match progress constructor
utils.debug('\n'.join(ret))
return ret