Merge remote-tracking branch 'qubesos/pr/46'

* qubesos/pr/46:
  Style fixes
  Fixed travis.yml
  Added Clone VM button
  Added Remove VM button

Fixes QubesOS/qubes-issues#3242
Fixes QubesOS/qubes-issues#3154
This commit is contained in:
Marek Marczykowski-Górecki 2017-11-06 20:03:38 +01:00
commit 2f3d60b27a
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 106 additions and 21 deletions

View File

@ -4,4 +4,4 @@ language: generic
install: git clone https://github.com/QubesOS/qubes-builder ~/qubes-builder
script: ~/qubes-builder/scripts/travis-build
env:
- DIST_DOM0=fc23 USE_QUBES_REPO_VERSION=3.2 USE_QUBES_REPO_TESTING=1
- DIST_DOM0=fc25 USE_QUBES_REPO_VERSION=4.0 USE_QUBES_REPO_TESTING=1

View File

@ -86,6 +86,8 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
###### basic tab
self.__init_basic_tab__()
self.rename_vm_button.clicked.connect(self.rename_vm)
self.delete_vm_button.clicked.connect(self.remove_vm)
self.clone_vm_button.clicked.connect(self.clone_vm)
###### advanced tab
self.__init_advanced_tab__()
@ -237,6 +239,11 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
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())
self.delete_vm_button.setEnabled(not self.vm.is_running())
if self.vm.is_running():
self.delete_vm_button.setText(self.tr('Delete VM '
'(cannot delete a running VM)'))
if self.vm.qid == 0:
self.vmlabel.setVisible(False)
@ -401,6 +408,23 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
"allowed value."))
self.init_mem.setValue(self.max_mem_size.value() / 10)
def _run_in_thread(self, func, *args):
t_monitor = thread_monitor.ThreadMonitor()
thread = threading.Thread(target=func, args=(t_monitor, *args,))
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!"),
self.tr("ERROR: {}").format(
t_monitor.error_msg))
def _rename_vm(self, t_monitor, name):
try:
self.vm.app.clone_vm(self.vm, name)
@ -414,27 +438,68 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
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)'))
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._run_in_thread(self._rename_vm, new_vm_name)
self.done(0)
def _remove_vm(self, t_monitor):
try:
del self.vm.app.domains[self.vm.name]
except Exception as ex:
t_monitor.set_error_msg(str(ex))
t_monitor.set_finished()
def remove_vm(self):
answer, ok = QInputDialog.getText(
self,
self.tr('Delete VM'),
self.tr('Are you absolutely sure you want to delete this VM? '
'<br/> All VM settings and data will be irrevocably'
' deleted. <br/> If you are sure, please enter this '
'VM\'s name below.'))
if ok and answer == self.vm.name:
self._run_in_thread(self._remove_vm)
self.done(0)
elif ok:
QMessageBox.warning(
None,
self.tr("Removal cancelled"),
self.tr("The VM will not be removed."))
def _clone_vm(self, t_monitor, name):
try:
self.vm.app.clone_vm(self.vm, name)
except Exception as ex:
t_monitor.set_error_msg(str(ex))
t_monitor.set_finished()
def clone_vm(self):
cloned_vm_name, ok = QInputDialog.getText(
self,
self.tr('Clone VM'),
self.tr('Name for the cloned VM:'))
if ok:
self._run_in_thread(self._clone_vm, cloned_vm_name)
QMessageBox.warning(
None,
self.tr("Success"),
self.tr("The VM was cloned successfully."))
######### advanced tab
def __init_advanced_tab__(self):

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>773</width>
<height>573</height>
<height>581</height>
</rect>
</property>
<property name="windowTitle">
@ -29,7 +29,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="basic_tab">
<property name="locale">
@ -170,7 +170,7 @@
</layout>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -373,6 +373,26 @@
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="delete_vm_button">
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:pad, x1:1, y1:1, x2:1, y2:0, stop:0 rgba(255, 179, 179, 255), stop:1 rgba(255, 108, 108, 255));
border-color: rgb(170, 0, 0);
border-style: solid;
border-width: 1px;</string>
</property>
<property name="text">
<string>Delete VM</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="clone_vm_button">
<property name="text">
<string>Clone VM</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="advanced_tab">