create_new_vm: enable/disable "install system" option on template change

When choosing StandaloneVM type, the option to install a system should
be enabled when empty source template is set. Fix this when choosing VM
type first and only then changing template to empty.
This commit is contained in:
Marek Marczykowski-Górecki 2021-01-09 05:53:53 +01:00
parent bc4f1e8d7b
commit 2f48fb33a3
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -168,6 +168,8 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
self.vm_type.currentIndexChanged.connect(self.type_change)
self.template_vm.currentIndexChanged.connect(self.template_change)
self.launch_settings.stateChanged.connect(self.settings_change)
self.install_system.stateChanged.connect(self.install_change)
@ -287,6 +289,17 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
self.template_vm.setCurrentIndex(0)
self.template_type = "template"
def template_change(self):
template = self.template_vm.currentData()
klass = self.vm_type.currentData()
if klass in ['TemplateVM', 'StandaloneVM'] and template is None:
self.install_system.setEnabled(True)
self.install_system.setChecked(True)
else:
self.install_system.setEnabled(False)
self.install_system.setChecked(False)
def install_change(self):
if self.install_system.isChecked():
self.launch_settings.setChecked(False)