Enabled selecting paths for backup/restore without mounting a device.

This commit is contained in:
Agnieszka Kostrzewa 2012-03-02 02:50:12 +01:00
parent 41ba80d5c9
commit b915d725bc
4 changed files with 29 additions and 17 deletions

View File

@ -178,7 +178,7 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QProgressBar" name="progress_bar">
<property name="value">
<number>24</number>
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>

View File

@ -173,9 +173,17 @@ class BackupVMsWindow(Ui_Backup, QWizard):
if not self.thread_monitor.success:
QMessageBox.warning (None, "Backup error!", "ERROR: {1}".format(self.vm.name, self.thread_monitor.error_msg))
umount_device(self.dev_mount_path)
if self.dev_mount_path != None:
umount_device(self.dev_mount_path)
self.button(self.FinishButton).setEnabled(True)
def reject(self):
if self.dev_mount_path != None:
umount_device(self.dev_mount_path)
self.done(0)
def has_selected_vms(self):
return self.select_vms_widget.selected_list.count() > 0

View File

@ -81,8 +81,7 @@ def fill_devs_list(dialog):
dialog.dev_combobox.setCurrentIndex(0) #current selected is null ""
dialog.prev_dev_idx = 0
dialog.dir_line_edit.clear()
dialog.dir_line_edit.setEnabled(False)
dialog.select_path_button.setEnabled(False)
enable_dir_line_edit(dialog, True)
def enable_dir_line_edit(dialog, boolean):
@ -100,12 +99,10 @@ def dev_combobox_activated(dialog, idx):
if dialog.dev_mount_path != None:
dialog.dev_mount_path = umount_device(dialog.dev_mount_path)
if dialog_dev_mount_path != None:
if dialog.dev_mount_path != None:
dialog.dev_combobox.setCurrentIndex(dialog.prev_dev_idx)
return
enable_dir_line_edit(dialog, False)
if dialog.dev_combobox.currentText() != "None": #An existing device chosen
dev_name = str(dialog.dev_combobox.itemData(idx).toString())
@ -123,16 +120,13 @@ def dev_combobox_activated(dialog, idx):
#check if device mounted
dialog.dev_mount_path = check_if_mounted(dev_path)
if dialog.dev_mount_path != None:
enable_dir_line_edit(dialog, True)
else:
if dialog.dev_mount_path == None:
dialog.dev_mount_path = mount_device(dev_path)
if dialog.dev_mount_path != None:
enable_dir_line_edit(dialog, True)
else:
if dialog.dev_mount_path == None:
dialog.dev_combobox.setCurrentIndex(0) #if couldn't mount - set current device to "None"
dialog.prev_dev_idx = 0
return
dialog.prev_dev_idx = idx
dialog.select_dir_page.emit(SIGNAL("completeChanged()"))
@ -141,7 +135,12 @@ def select_path_button_clicked(dialog):
dialog.backup_dir = dialog.dir_line_edit.text()
file_dialog = QFileDialog()
file_dialog.setReadOnly(True)
new_path = file_dialog.getExistingDirectory(dialog, "Select backup directory.", dialog.dev_mount_path)
if dialog.dev_mount_path != None:
new_path = file_dialog.getExistingDirectory(dialog, "Select backup directory.", dialog.dev_mount_path)
else:
new_path = file_dialog.getExistingDirectory(dialog, "Select backup directory.", "~")
if new_path:
dialog.dir_line_edit.setText(new_path)
dialog.backup_dir = new_path

View File

@ -97,7 +97,6 @@ class RestoreVMsWindow(Ui_Restore, QWizard):
def dev_combobox_activated(self, idx):
dev_combobox_activated(self, idx)
@pyqtSlot(name='on_select_path_button_clicked')
def select_path_button_clicked(self):
select_path_button_clicked(self)
@ -209,8 +208,14 @@ class RestoreVMsWindow(Ui_Restore, QWizard):
#if not self.thread_monitor.success:
#QMessageBox.warning (None, "Backup error!", "ERROR: {1}".format(self.vm.name, self.thread_monitor.error_msg))
umount_device(self.dev_mount_path)
if self.dev_mount_path != None:
umount_device(self.dev_mount_path)
self.button(self.FinishButton).setEnabled(True)
def reject(self):
if self.dev_mount_path != None:
umount_device(self.dev_mount_path)
self.done(0)