Fixed opening file dialog at the end
Now, when "open file dialog to unmount" option is enabled, a fie dialog actually opens.
This commit is contained in:
parent
a4a58cc527
commit
14ebf9dc6d
@ -25,7 +25,7 @@ import traceback
|
|||||||
import signal
|
import signal
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from qubesadmin import Qubes, events, exc
|
from qubesadmin import Qubes, exc
|
||||||
from qubesadmin import utils as admin_utils
|
from qubesadmin import utils as admin_utils
|
||||||
from qubes.storage.file import get_disk_usage
|
from qubes.storage.file import get_disk_usage
|
||||||
|
|
||||||
@ -326,16 +326,14 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
|||||||
orig_text + self.tr(
|
orig_text + self.tr(
|
||||||
" Please unmount your backup volume and cancel "
|
" Please unmount your backup volume and cancel "
|
||||||
"the file selection dialog."))
|
"the file selection dialog."))
|
||||||
if self.target_appvm: # FIXME I'm not sure if this works
|
backup_utils.select_path_button_clicked(self, False, True)
|
||||||
self.target_appvm.run(
|
|
||||||
"QUBESRPC %s dom0" % "qubes.SelectDirectory")
|
|
||||||
self.button(self.CancelButton).setEnabled(False)
|
self.button(self.CancelButton).setEnabled(False)
|
||||||
self.button(self.FinishButton).setEnabled(True)
|
self.button(self.FinishButton).setEnabled(True)
|
||||||
self.showFileDialog.setEnabled(False)
|
self.showFileDialog.setEnabled(False)
|
||||||
signal.signal(signal.SIGCHLD, old_sigchld_handler)
|
signal.signal(signal.SIGCHLD, old_sigchld_handler)
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
# cancell clicked while the backup is in progress.
|
# cancel clicked while the backup is in progress.
|
||||||
# calling kill on tar.
|
# calling kill on tar.
|
||||||
if self.currentPage() is self.commit_page:
|
if self.currentPage() is self.commit_page:
|
||||||
pass # TODO: this does nothing
|
pass # TODO: this does nothing
|
||||||
|
@ -51,7 +51,7 @@ def enable_dir_line_edit(dialog, boolean):
|
|||||||
dialog.select_path_button.setEnabled(boolean)
|
dialog.select_path_button.setEnabled(boolean)
|
||||||
|
|
||||||
|
|
||||||
def select_path_button_clicked(dialog, select_file=False):
|
def select_path_button_clicked(dialog, select_file=False, read_only=False):
|
||||||
backup_location = str(dialog.dir_line_edit.text())
|
backup_location = str(dialog.dir_line_edit.text())
|
||||||
file_dialog = QtGui.QFileDialog()
|
file_dialog = QtGui.QFileDialog()
|
||||||
file_dialog.setReadOnly(True)
|
file_dialog.setReadOnly(True)
|
||||||
@ -66,15 +66,18 @@ def select_path_button_clicked(dialog, select_file=False):
|
|||||||
"qubes.SelectFile" if select_file
|
"qubes.SelectFile" if select_file
|
||||||
else "qubes.SelectDirectory")
|
else "qubes.SelectDirectory")
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
QtGui.QMessageBox.warning(
|
if not read_only:
|
||||||
None,
|
QtGui.QMessageBox.warning(
|
||||||
dialog.tr("Nothing selected!"),
|
None,
|
||||||
dialog.tr("No file or directory selected."))
|
dialog.tr("Nothing selected!"),
|
||||||
|
dialog.tr("No file or directory selected."))
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
if new_path:
|
if new_path and not read_only:
|
||||||
dialog.dir_line_edit.setText(new_path)
|
dialog.dir_line_edit.setText(new_path)
|
||||||
|
|
||||||
if new_path and backup_location:
|
if new_path and backup_location and not read_only:
|
||||||
dialog.select_dir_page.emit(QtCore.SIGNAL("completeChanged()"))
|
dialog.select_dir_page.emit(QtCore.SIGNAL("completeChanged()"))
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,9 +71,6 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
|||||||
self.connect(self,
|
self.connect(self,
|
||||||
QtCore.SIGNAL("currentIdChanged(int)"),
|
QtCore.SIGNAL("currentIdChanged(int)"),
|
||||||
self.current_page_changed)
|
self.current_page_changed)
|
||||||
self.connect(self,
|
|
||||||
QtCore.SIGNAL("restore_progress(QString)"),
|
|
||||||
self.commit_text_edit.append)
|
|
||||||
self.dir_line_edit.connect(self.dir_line_edit,
|
self.dir_line_edit.connect(self.dir_line_edit,
|
||||||
QtCore.SIGNAL("textChanged(QString)"),
|
QtCore.SIGNAL("textChanged(QString)"),
|
||||||
self.backup_location_changed)
|
self.backup_location_changed)
|
||||||
@ -140,15 +137,15 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
|||||||
except exc.QubesException as ex:
|
except exc.QubesException as ex:
|
||||||
QtGui.QMessageBox.warning(None, self.tr("Restore error!"), str(ex))
|
QtGui.QMessageBox.warning(None, self.tr("Restore error!"), str(ex))
|
||||||
|
|
||||||
|
def append_output(self, text):
|
||||||
|
self.commit_text_edit.append(text)
|
||||||
|
|
||||||
def restore_error_output(self, text):
|
def restore_error_output(self, text):
|
||||||
self.error_detected.set()
|
self.error_detected.set()
|
||||||
self.feedback_queue.put((QtCore.SIGNAL("restore_progress(QString)"),
|
self.append_output(u'<font color="red">{0}</font>'.format(text))
|
||||||
u'<font color="red">{0}</font>'.format(text)))
|
|
||||||
|
|
||||||
def restore_output(self, text):
|
def restore_output(self, text):
|
||||||
self.feedback_queue.put((
|
self.append_output(u'<font color="black">{0}</font>'.format(text))
|
||||||
QtCore.SIGNAL("restore_progress(QString)"),
|
|
||||||
u'<font color="black">{0}</font>'.format(text)))
|
|
||||||
|
|
||||||
def __do_restore__(self, t_monitor):
|
def __do_restore__(self, t_monitor):
|
||||||
err_msg = []
|
err_msg = []
|
||||||
@ -166,19 +163,16 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
|||||||
"investigate them and/or clean them up"))
|
"investigate them and/or clean them up"))
|
||||||
|
|
||||||
if self.canceled:
|
if self.canceled:
|
||||||
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
self.append_output('<b><font color="red">{0}</font></b>'.format(
|
||||||
'<b><font color="red">{0}</font></b>'
|
self.tr("Restore aborted!")))
|
||||||
.format(self.tr("Restore aborted!")))
|
|
||||||
elif err_msg or self.error_detected.is_set():
|
elif err_msg or self.error_detected.is_set():
|
||||||
if err_msg:
|
if err_msg:
|
||||||
t_monitor.set_error_msg('\n'.join(err_msg))
|
t_monitor.set_error_msg('\n'.join(err_msg))
|
||||||
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
self.append_output('<b><font color="red">{0}</font></b>'.format(
|
||||||
'<b><font color="red">{0}</font></b>'
|
self.tr("Finished with errors!")))
|
||||||
.format(self.tr("Finished with errors!")))
|
|
||||||
else:
|
else:
|
||||||
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
self.append_output('<font color="green">{0}</font>'.format(
|
||||||
'<font color="green">{0}</font>'
|
self.tr("Finished successfully!")))
|
||||||
.format(self.tr("Finished successfully!")))
|
|
||||||
|
|
||||||
t_monitor.set_finished()
|
t_monitor.set_finished()
|
||||||
|
|
||||||
@ -249,24 +243,17 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
|||||||
self.tr("Backup error!"),
|
self.tr("Backup error!"),
|
||||||
self.tr("ERROR: {0}").format(
|
self.tr("ERROR: {0}").format(
|
||||||
self.thread_monitor.error_msg))
|
self.thread_monitor.error_msg))
|
||||||
|
|
||||||
if self.showFileDialog.isChecked(): # TODO: this is not working
|
|
||||||
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
|
||||||
'<b><font color="black">{0}</font></b>'.format(
|
|
||||||
self.tr(
|
|
||||||
"Please unmount your backup volume and cancel"
|
|
||||||
" the file selection dialog.")))
|
|
||||||
if self.target_appvm: # TODO does this work at all?
|
|
||||||
self.target_appvm.run("QUBESRPC %s dom0" %
|
|
||||||
"qubes.SelectDirectory")
|
|
||||||
else:
|
|
||||||
file_dialog = QtGui.QFileDialog()
|
|
||||||
file_dialog.setReadOnly(True)
|
|
||||||
file_dialog.getExistingDirectory(
|
|
||||||
self, self.tr("Detach backup device"),
|
|
||||||
os.path.dirname(self.dir_line_edit.text()))
|
|
||||||
self.progress_bar.setMaximum(100)
|
self.progress_bar.setMaximum(100)
|
||||||
self.progress_bar.setValue(100)
|
self.progress_bar.setValue(100)
|
||||||
|
|
||||||
|
if self.showFileDialog.isChecked():
|
||||||
|
self.append_output(
|
||||||
|
'<b><font color="black">{0}</font></b>'.format(
|
||||||
|
self.tr("Please unmount your backup volume and cancel "
|
||||||
|
"the file selection dialog.")))
|
||||||
|
self.app.processEvents()
|
||||||
|
backup_utils.select_path_button_clicked(self, False, True)
|
||||||
|
|
||||||
self.button(self.FinishButton).setEnabled(True)
|
self.button(self.FinishButton).setEnabled(True)
|
||||||
self.button(self.CancelButton).setEnabled(False)
|
self.button(self.CancelButton).setEnabled(False)
|
||||||
self.showFileDialog.setEnabled(False)
|
self.showFileDialog.setEnabled(False)
|
||||||
@ -284,9 +271,8 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
|||||||
def reject(self): # TODO: probably not working too
|
def reject(self): # TODO: probably not working too
|
||||||
if self.currentPage() is self.commit_page:
|
if self.currentPage() is self.commit_page:
|
||||||
if self.backup_restore.canceled:
|
if self.backup_restore.canceled:
|
||||||
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
self.append_output('<font color="red">{0}</font>'.format(
|
||||||
'<font color="red">{0}</font>'
|
self.tr("Aborting the operation...")))
|
||||||
.format(self.tr("Aborting the operation...")))
|
|
||||||
self.button(self.CancelButton).setDisabled(True)
|
self.button(self.CancelButton).setDisabled(True)
|
||||||
else:
|
else:
|
||||||
self.done(0)
|
self.done(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user