'rename VM' button in VM Settings
rename VM button in VM settings: it asks for a new name, and then clones VM under the new name and deletes old one. Renaming VM closes VM settings window without saving any other changes. Changed max size of VM name field to 32 characters.
This commit is contained in:
parent
2dda433fd3
commit
693e1340ed
@ -83,6 +83,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
||||
|
||||
###### basic tab
|
||||
self.__init_basic_tab__()
|
||||
self.rename_vm_button.clicked.connect(self.rename_vm)
|
||||
|
||||
###### advanced tab
|
||||
self.__init_advanced_tab__()
|
||||
@ -232,6 +233,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
||||
self.vmname.setText(self.vm.name)
|
||||
self.vmname.setValidator(QRegExpValidator(QRegExp("[a-zA-Z0-9-]*", Qt.CaseInsensitive), None))
|
||||
self.vmname.setEnabled(False)
|
||||
self.rename_vm_button.setEnabled(not self.vm.is_running())
|
||||
|
||||
if self.vm.qid == 0:
|
||||
self.vmlabel.setVisible(False)
|
||||
@ -397,7 +399,39 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
||||
"allowed value."))
|
||||
self.init_mem.setValue(self.max_mem_size.value() / 10)
|
||||
|
||||
def _rename_vm(self, t_monitor, name):
|
||||
try:
|
||||
self.vm.app.clone_vm(self.vm, name)
|
||||
del self.vm.app.domains[self.vm.name]
|
||||
|
||||
except Exception as ex:
|
||||
t_monitor.set_error_msg(str(ex))
|
||||
|
||||
t_monitor.set_finished()
|
||||
|
||||
|
||||
def rename_vm(self):
|
||||
|
||||
new_vm_name, ok = QInputDialog.getText(self, self.tr('Rename VM'), self.tr('New name: (WARNING: all other changes will be discarded)'))
|
||||
|
||||
if ok:
|
||||
|
||||
t_monitor = thread_monitor.ThreadMonitor()
|
||||
thread = threading.Thread(target=self._rename_vm, args=(t_monitor, new_vm_name,))
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
while not t_monitor.is_finished():
|
||||
self.qapp.processEvents()
|
||||
time.sleep (0.1)
|
||||
|
||||
if not t_monitor.success:
|
||||
QMessageBox.warning(None,
|
||||
self.tr("Error renaming the VM!"),
|
||||
self.tr("ERROR: {}").format(
|
||||
t_monitor.error_msg))
|
||||
|
||||
self.done(0)
|
||||
|
||||
######### advanced tab
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="basic_tab">
|
||||
<property name="locale">
|
||||
@ -39,107 +39,6 @@
|
||||
<string>Basic</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_11">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Name &amp;&amp; label<span style=" color:#ff0000;">*</span>:</p></body></html></string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>vmname</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="vmname">
|
||||
<property name="text">
|
||||
<string>----</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Template<span style=" color:#ff0000;">*</span>:</p></body></html></string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>template_name</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="template_name"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>NetVM:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>netVM</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="netVM"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="vmlabel">
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="include_in_backups">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Include in backups by default</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="run_in_debug_mode">
|
||||
<property name="text">
|
||||
<string>Run in debug mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autostart_vm">
|
||||
<property name="text">
|
||||
<string>Start VM automatically on boot</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="seamless_gui">
|
||||
<property name="text">
|
||||
<string>Seamless GUI</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="enabled">
|
||||
@ -363,6 +262,117 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Name &amp;&amp; label<span style=" color:#ff0000;">*</span>:</p></body></html></string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>vmname</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Template<span style=" color:#ff0000;">*</span>:</p></body></html></string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>template_name</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>NetVM:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>netVM</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QComboBox" name="vmlabel">
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="vmname">
|
||||
<property name="text">
|
||||
<string>----</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>32</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="rename_vm_button">
|
||||
<property name="text">
|
||||
<string>Rename</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="template_name"/>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="netVM"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="include_in_backups">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Include in backups by default</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="run_in_debug_mode">
|
||||
<property name="text">
|
||||
<string>Run in debug mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autostart_vm">
|
||||
<property name="text">
|
||||
<string>Start VM automatically on boot</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="seamless_gui">
|
||||
<property name="text">
|
||||
<string>Seamless GUI</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="advanced_tab">
|
||||
|
Loading…
Reference in New Issue
Block a user