Merge remote-tracking branch 'origin/pr/176'

* origin/pr/176:
  Fixed logs display in Qube Manager
  Protected loading manager settings from malformed config files
  Fixed bug with hiding last visible column
  Added additional check for cloning a VM
  Fixed unnecessary property set in Global Settings
  Fixed bug in Global Settings
This commit is contained in:
Marek Marczykowski-Górecki 2019-05-07 00:09:01 +02:00
commit af555fa9b1
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 49 additions and 40 deletions

View File

@ -239,8 +239,8 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
self.dom0_updates_file_path = '/var/lib/qubes/updates/disable-updates' self.dom0_updates_file_path = '/var/lib/qubes/updates/disable-updates'
try: try:
self.updates_dom0_val = self.qvm_collection.domains[ self.updates_dom0_val = bool(self.qvm_collection.domains[
'dom0'].features['service.qubes-update-check'] 'dom0'].features['service.qubes-update-check'])
except KeyError: except KeyError:
self.updates_dom0_val =\ self.updates_dom0_val =\
not os.path.isfile(self.dom0_updates_file_path) not os.path.isfile(self.dom0_updates_file_path)
@ -284,6 +284,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
'service.qubes-update-check'] = \ 'service.qubes-update-check'] = \
self.updates_dom0.isChecked() self.updates_dom0.isChecked()
if self.qvm_collection.check_updates_vm != self.updates_vm.isChecked():
self.qvm_collection.check_updates_vm = self.updates_vm.isChecked() self.qvm_collection.check_updates_vm = self.updates_vm.isChecked()
def reject(self): def reject(self):

View File

@ -466,7 +466,17 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
self.connect(self.action_toolbar, QtCore.SIGNAL("toggled(bool)"), self.connect(self.action_toolbar, QtCore.SIGNAL("toggled(bool)"),
self.showhide_toolbar) self.showhide_toolbar)
try:
self.load_manager_settings() self.load_manager_settings()
except Exception as ex: # pylint: disable=broad-except
QtGui.QMessageBox.warning(
None,
self.tr("Manager settings unreadable"),
self.tr("Qube Manager settings cannot be parsed. Previously "
"saved display settings may not be restored "
"correctly.\nError: {}".format(str(ex))))
self.settings_loaded = True
self.fill_table() self.fill_table()
@ -604,15 +614,16 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
return # the VM was deleted before its status could be updated return # the VM was deleted before its status could be updated
def load_manager_settings(self): def load_manager_settings(self):
# visible columns
self.visible_columns_count = 0
for col in self.columns_indices: for col in self.columns_indices:
col_no = self.columns_indices[col] col_no = self.columns_indices[col]
if col == 'Name':
# 'Name' column should be always visible
self.columns_actions[col_no].setChecked(True)
else:
visible = self.manager_settings.value( visible = self.manager_settings.value(
'columns/%s' % col, 'columns/%s' % col,
defaultValue="true") defaultValue="true")
self.columns_actions[col_no].setChecked(visible == "true") self.columns_actions[col_no].setChecked(visible == "true")
self.visible_columns_count += 1
self.sort_by_column = str( self.sort_by_column = str(
self.manager_settings.value("view/sort_column", self.manager_settings.value("view/sort_column",
@ -641,8 +652,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
self.resize(self.manager_settings.value("window_size", self.resize(self.manager_settings.value("window_size",
QtCore.QSize(1100, 600))) QtCore.QSize(1100, 600)))
self.settings_loaded = True
def get_vms_list(self): def get_vms_list(self):
return [vm for vm in self.qubes_app.domains] return [vm for vm in self.qubes_app.domains]
@ -758,6 +767,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
self.action_run_command_in_vm.setEnabled(False) self.action_run_command_in_vm.setEnabled(False)
self.action_set_keyboard_layout.setEnabled(False) self.action_set_keyboard_layout.setEnabled(False)
self.update_logs_menu()
# noinspection PyArgumentList # noinspection PyArgumentList
@QtCore.pyqtSlot(name='on_action_createvm_triggered') @QtCore.pyqtSlot(name='on_action_createvm_triggered')
def action_createvm_triggered(self): # pylint: disable=no-self-use def action_createvm_triggered(self): # pylint: disable=no-self-use
@ -852,6 +863,15 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
if not ok or clone_name == "": if not ok or clone_name == "":
return return
name_in_use = clone_name in self.qubes_app.domains
if name_in_use:
QtGui.QMessageBox.warning(
None, self.tr("Name already in use!"),
self.tr("There already exists a qube called '{}'. "
"Cloning aborted.").format(clone_name))
return
self.progress = QtGui.QProgressDialog( self.progress = QtGui.QProgressDialog(
self.tr( self.tr(
"Cloning Qube..."), "", 0, 0) "Cloning Qube..."), "", 0, 0)
@ -1152,22 +1172,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
def showhide_column(self, col_num, show): def showhide_column(self, col_num, show):
self.table.setColumnHidden(col_num, not show) self.table.setColumnHidden(col_num, not show)
val = 1 if show else -1
self.visible_columns_count += val
if self.visible_columns_count == 1:
# disable hiding the last one
for col in self.columns_actions:
if self.columns_actions[col].isChecked():
self.columns_actions[col].setEnabled(False)
break
elif self.visible_columns_count == 2 and val == 1:
# enable hiding previously disabled column
for col in self.columns_actions:
if not self.columns_actions[col].isEnabled():
self.columns_actions[col].setEnabled(True)
break
if self.settings_loaded: if self.settings_loaded:
col_name = [name for name in self.columns_indices if col_name = [name for name in self.columns_indices if
self.columns_indices[name] == col_num][0] self.columns_indices[name] == col_num][0]
@ -1231,8 +1235,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
def open_tools_context_menu(self, widget, point): def open_tools_context_menu(self, widget, point):
self.tools_context_menu.exec_(widget.mapToGlobal(point)) self.tools_context_menu.exec_(widget.mapToGlobal(point))
@QtCore.pyqtSlot('const QPoint&') def update_logs_menu(self):
def open_context_menu(self, point):
try: try:
vm = self.get_selected_vm() vm = self.get_selected_vm()
@ -1258,14 +1261,20 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
menu_empty = False menu_empty = False
self.logs_menu.setEnabled(not menu_empty) self.logs_menu.setEnabled(not menu_empty)
except exc.QubesPropertyAccessError:
pass
@QtCore.pyqtSlot('const QPoint&')
def open_context_menu(self, point):
vm = self.get_selected_vm()
if vm.qid == 0: if vm.qid == 0:
self.dom0_context_menu.exec_(self.table.mapToGlobal( self.dom0_context_menu.exec_(self.table.mapToGlobal(
point + QtCore.QPoint(10, 0))) point + QtCore.QPoint(10, 0)))
else: else:
self.context_menu.exec_(self.table.mapToGlobal( self.context_menu.exec_(self.table.mapToGlobal(
point + QtCore.QPoint(10, 0))) point + QtCore.QPoint(10, 0)))
except exc.QubesPropertyAccessError:
pass
@QtCore.pyqtSlot('QAction *') @QtCore.pyqtSlot('QAction *')
def show_log(self, action): def show_log(self, action):

View File

@ -281,7 +281,6 @@ DisposableVMs</string>
</property> </property>
<addaction name="action_vm_type"/> <addaction name="action_vm_type"/>
<addaction name="action_label"/> <addaction name="action_label"/>
<addaction name="action_name"/>
<addaction name="action_state"/> <addaction name="action_state"/>
<addaction name="action_template"/> <addaction name="action_template"/>
<addaction name="action_netvm"/> <addaction name="action_netvm"/>