diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 40a5954..3d9762b 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -53,6 +53,7 @@ from . import create_new_vm from . import log_dialog from . import utils as manager_utils from . import common_threads +from . import clone_vm class SearchBox(QLineEdit): @@ -1045,39 +1046,10 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): def action_clonevm_triggered(self): for vm_info in self.get_selected_vms(): vm = vm_info.vm - name_number = 1 - name_format = vm.name + '-clone-%d' - while name_format % name_number in self.qubes_app.domains.keys(): - name_number += 1 - - (clone_name, ok) = QInputDialog.getText( - self, self.tr('Qubes clone Qube'), - self.tr('Enter name for Qube {} clone:').format(vm.name), - text=(name_format % name_number)) - if not ok or clone_name == "": - return - - name_in_use = clone_name in self.qubes_app.domains - - if name_in_use: - QMessageBox.warning( - self, self.tr("Name already in use!"), - self.tr("There already exists a qube called '{}'. " - "Cloning aborted.").format(clone_name)) - return - - self.progress = QProgressDialog( - self.tr( - "Cloning Qube..."), "", 0, 0) - self.progress.setCancelButton(None) - self.progress.setModal(True) - self.progress.setWindowTitle(self.tr("Cloning qube...")) - self.progress.show() - - thread = common_threads.CloneVMThread(vm, clone_name) - thread.finished.connect(self.clear_threads) - self.threads_list.append(thread) - thread.start() + with common_threads.busy_cursor(): + clone_window = clone_vm.CloneVMDlg( + self.qt_app, self.qubes_app, src_vm=vm) + clone_window.exec_() # noinspection PyArgumentList @pyqtSlot(name='on_action_resumevm_triggered') diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index ef366dc..3723d88 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -36,6 +36,7 @@ from . import utils from . import multiselectwidget from . import common_threads from . import device_list +from . import clone_vm from .appmenu_select import AppmenuSelectManager from . import firewall @@ -653,25 +654,10 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): self.tr("The qube will not be removed.")) def clone_vm(self): - - cloned_vm_name, ok = QtWidgets.QInputDialog.getText( - self, - self.tr('Clone qube'), - self.tr('Name for the cloned qube:')) - - if ok: - thread = common_threads.CloneVMThread(self.vm, cloned_vm_name) - thread.finished.connect(self.clear_threads) - self.threads_list.append(thread) - - self.progress = QtWidgets.QProgressDialog( - self.tr("Cloning Qube..."), "", 0, 0) - self.progress.setCancelButton(None) - self.progress.setModal(True) - self.thread_closes = True - self.progress.show() -# TODO: improvement: maybe this can be refactored into less repetition? - thread.start() + with common_threads.busy_cursor(): + clone_window = clone_vm.CloneVMDlg( + self.qapp, self.qubesapp, src_vm=self.vm) + clone_window.exec_() ######### advanced tab