diff --git a/qubesmanager/common_threads.py b/qubesmanager/common_threads.py index 4f35539..0097082 100644 --- a/qubesmanager/common_threads.py +++ b/qubesmanager/common_threads.py @@ -20,10 +20,21 @@ # -from PyQt4 import QtCore # pylint: disable=import-error +from PyQt4 import QtCore, QtGui # pylint: disable=import-error +from contextlib import contextmanager + from qubesadmin import exc +@contextmanager +def busy_cursor(): + try: + QtGui.QApplication.setOverrideCursor(QtCore.Qt.BusyCursor) + yield + finally: + QtGui.QApplication.restoreOverrideCursor() + + # pylint: disable=too-few-public-methods class RemoveVMThread(QtCore.QThread): def __init__(self, vm): diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 32563ea..b0bfb45 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -741,7 +741,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_createvm_triggered') def action_createvm_triggered(self): # pylint: disable=no-self-use - create_window = create_new_vm.NewVmDlg(self.qt_app, self.qubes_app) + with common_threads.busy_cursor(): + create_window = create_new_vm.NewVmDlg(self.qt_app, self.qubes_app) create_window.exec_() def get_selected_vm(self): @@ -977,8 +978,9 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): def action_settings_triggered(self): vm = self.get_selected_vm() if vm: - settings_window = settings.VMSettingsWindow( - vm, self.qt_app, "basic") + with common_threads.busy_cursor(): + settings_window = settings.VMSettingsWindow( + vm, self.qt_app, "basic") settings_window.exec_() vm_deleted = False @@ -1004,11 +1006,11 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): def action_appmenus_triggered(self): vm = self.get_selected_vm() if vm: - settings_window = settings.VMSettingsWindow( - vm, self.qt_app, "applications") + with common_threads.busy_cursor(): + settings_window = settings.VMSettingsWindow( + vm, self.qt_app, "applications") settings_window.exec_() - # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_updatevm_triggered') def action_updatevm_triggered(self): @@ -1057,16 +1059,19 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_editfwrules_triggered') def action_editfwrules_triggered(self): - vm = self.get_selected_vm() - settings_window = settings.VMSettingsWindow(vm, self.qt_app, "firewall") + with common_threads.busy_cursor(): + vm = self.get_selected_vm() + settings_window = settings.VMSettingsWindow(vm, self.qt_app,\ + "firewall") settings_window.exec_() # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_global_settings_triggered') def action_global_settings_triggered(self): # pylint: disable=invalid-name - global_settings_window = global_settings.GlobalSettingsWindow( - self.qt_app, - self.qubes_app) + with common_threads.busy_cursor(): + global_settings_window = global_settings.GlobalSettingsWindow( + self.qt_app, + self.qubes_app) global_settings_window.exec_() # noinspection PyArgumentList @@ -1086,14 +1091,17 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_restore_triggered') def action_restore_triggered(self): - restore_window = restore.RestoreVMsWindow(self.qt_app, self.qubes_app) + with common_threads.busy_cursor(): + restore_window = restore.RestoreVMsWindow(self.qt_app,\ + self.qubes_app) restore_window.exec_() # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_backup_triggered') def action_backup_triggered(self): - backup_window = backup.BackupVMsWindow(self.qt_app, self.qubes_app, - self.dispatcher, self) + with common_threads.busy_cursor(): + backup_window = backup.BackupVMsWindow(self.qt_app, self.qubes_app, + self.dispatcher, self) backup_window.show() # noinspection PyArgumentList diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py old mode 100755 new mode 100644 index 9be8256..a2c6acf --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -151,10 +151,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): assert idx in range(self.tabWidget.count()) self.tabWidget.setCurrentIndex(idx) - self.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked.connect( - self.save_and_apply) - self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).clicked.connect( - self.reject) self.buttonBox.button(QtGui.QDialogButtonBox.Apply).clicked.connect( self.apply) @@ -264,15 +260,12 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): return super(VMSettingsWindow, self).keyPressEvent(event) - def reject(self): - self.done(0) - - # needed not to close the dialog before applying changes def accept(self): - pass + self.save_and_apply() def save_changes(self): - error = self.__save_changes__() + with common_threads.busy_cursor(): + error = self.__save_changes__() if error: QtGui.QMessageBox.warning(