Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/154'
Browse files Browse the repository at this point in the history
* origin/pr/154:
  Fix too long lines
  Moved busy_cursor() inside save_changes()
  Removed unneded calls to Override/Restore cursor
  Removed duplicated call to save_changes()
  Removed unneeded Cursor override/restore
  Added busy_cursor()
  Added BusyCursor for notify manager is working
  Revert "Added progress bar to __save_changes__"
  Revert "Increase progress wait time to 2s"
  Increase progress wait time to 2s
  Added progress bar to __save_changes__
  Remove unneeded slot connections and reject overwrite
  • Loading branch information
marmarek committed Apr 3, 2019
2 parents 5737645 + b7228e8 commit 1d65d69
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
13 changes: 12 additions & 1 deletion qubesmanager/common_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
36 changes: 22 additions & 14 deletions qubesmanager/qube_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ def table_selection_changed(self):
# 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):
Expand Down Expand Up @@ -977,8 +978,9 @@ def action_killvm_triggered(self):
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
Expand All @@ -1004,11 +1006,11 @@ def action_settings_triggered(self):
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):
Expand Down Expand Up @@ -1057,16 +1059,19 @@ def action_set_keyboard_layout_triggered(self):
# 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
Expand All @@ -1086,14 +1091,17 @@ def action_show_network_triggered(self):
# 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
Expand Down
13 changes: 3 additions & 10 deletions qubesmanager/settings.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ def __init__(self, vm, qapp, init_page="basic", parent=None):
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)

Expand Down Expand Up @@ -264,15 +260,12 @@ def keyPressEvent(self, event): # pylint: disable=invalid-name
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(
Expand Down

0 comments on commit 1d65d69

Please sign in to comment.