Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/176'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
marmarek committed May 6, 2019
2 parents e997b47 + cb70b9b commit af555fa
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 40 deletions.
7 changes: 4 additions & 3 deletions qubesmanager/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ def __init_updates__(self):
self.dom0_updates_file_path = '/var/lib/qubes/updates/disable-updates'

try:
self.updates_dom0_val = self.qvm_collection.domains[
'dom0'].features['service.qubes-update-check']
self.updates_dom0_val = bool(self.qvm_collection.domains[
'dom0'].features['service.qubes-update-check'])
except KeyError:
self.updates_dom0_val =\
not os.path.isfile(self.dom0_updates_file_path)
Expand Down Expand Up @@ -284,7 +284,8 @@ def __apply_updates__(self):
'service.qubes-update-check'] = \
self.updates_dom0.isChecked()

self.qvm_collection.check_updates_vm = self.updates_vm.isChecked()
if self.qvm_collection.check_updates_vm != self.updates_vm.isChecked():
self.qvm_collection.check_updates_vm = self.updates_vm.isChecked()

def reject(self):
self.done(0)
Expand Down
81 changes: 45 additions & 36 deletions qubesmanager/qube_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,17 @@ def __init__(self, qt_app, qubes_app, dispatcher, parent=None):
self.connect(self.action_toolbar, QtCore.SIGNAL("toggled(bool)"),
self.showhide_toolbar)

self.load_manager_settings()
try:
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()

Expand Down Expand Up @@ -504,7 +514,7 @@ def __init__(self, qt_app, qubes_app, dispatcher, parent=None):
# Check Updates Timer
timer = QtCore.QTimer(self)
timer.timeout.connect(self.check_updates)
timer.start(1000 * 30) # 30s
timer.start(1000 * 30) # 30s
self.check_updates()

def keyPressEvent(self, event): # pylint: disable=invalid-name
Expand Down Expand Up @@ -604,15 +614,16 @@ def on_domain_changed(self, vm, event, **_kwargs):
return # the VM was deleted before its status could be updated

def load_manager_settings(self):
# visible columns
self.visible_columns_count = 0
for col in self.columns_indices:
col_no = self.columns_indices[col]
visible = self.manager_settings.value(
'columns/%s' % col,
defaultValue="true")
self.columns_actions[col_no].setChecked(visible == "true")
self.visible_columns_count += 1
if col == 'Name':
# 'Name' column should be always visible
self.columns_actions[col_no].setChecked(True)
else:
visible = self.manager_settings.value(
'columns/%s' % col,
defaultValue="true")
self.columns_actions[col_no].setChecked(visible == "true")

self.sort_by_column = str(
self.manager_settings.value("view/sort_column",
Expand Down Expand Up @@ -641,8 +652,6 @@ def load_manager_settings(self):
self.resize(self.manager_settings.value("window_size",
QtCore.QSize(1100, 600)))

self.settings_loaded = True

def get_vms_list(self):
return [vm for vm in self.qubes_app.domains]

Expand Down Expand Up @@ -758,6 +767,8 @@ def table_selection_changed(self):
self.action_run_command_in_vm.setEnabled(False)
self.action_set_keyboard_layout.setEnabled(False)

self.update_logs_menu()

# noinspection PyArgumentList
@QtCore.pyqtSlot(name='on_action_createvm_triggered')
def action_createvm_triggered(self): # pylint: disable=no-self-use
Expand Down Expand Up @@ -852,6 +863,15 @@ def action_clonevm_triggered(self):
if not ok or clone_name == "":
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.tr(
"Cloning Qube..."), "", 0, 0)
Expand Down Expand Up @@ -1152,22 +1172,6 @@ def showhide_toolbar(self, checked):
def showhide_column(self, col_num, 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:
col_name = [name for name in self.columns_indices if
self.columns_indices[name] == col_num][0]
Expand Down Expand Up @@ -1231,8 +1235,7 @@ def createPopupMenu(self): # pylint: disable=invalid-name
def open_tools_context_menu(self, widget, point):
self.tools_context_menu.exec_(widget.mapToGlobal(point))

@QtCore.pyqtSlot('const QPoint&')
def open_context_menu(self, point):
def update_logs_menu(self):
try:
vm = self.get_selected_vm()

Expand All @@ -1258,15 +1261,21 @@ def open_context_menu(self, point):
menu_empty = False

self.logs_menu.setEnabled(not menu_empty)
if vm.qid == 0:
self.dom0_context_menu.exec_(self.table.mapToGlobal(
point + QtCore.QPoint(10, 0)))
else:
self.context_menu.exec_(self.table.mapToGlobal(
point + QtCore.QPoint(10, 0)))

except exc.QubesPropertyAccessError:
pass

@QtCore.pyqtSlot('const QPoint&')
def open_context_menu(self, point):
vm = self.get_selected_vm()

if vm.qid == 0:
self.dom0_context_menu.exec_(self.table.mapToGlobal(
point + QtCore.QPoint(10, 0)))
else:
self.context_menu.exec_(self.table.mapToGlobal(
point + QtCore.QPoint(10, 0)))

@QtCore.pyqtSlot('QAction *')
def show_log(self, action):
log = str(action.data())
Expand Down Expand Up @@ -1335,7 +1344,7 @@ def main():
asyncio.ensure_future(dispatcher.listen_for_events()))
except asyncio.CancelledError:
pass
except Exception: # pylint: disable=broad-except
except Exception: # pylint: disable=broad-except
loop_shutdown()
exc_type, exc_value, exc_traceback = sys.exc_info()[:3]
handle_exception(exc_type, exc_value, exc_traceback)
Expand Down
1 change: 0 additions & 1 deletion ui/qubemanager.ui
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ DisposableVMs</string>
</property>
<addaction name="action_vm_type"/>
<addaction name="action_label"/>
<addaction name="action_name"/>
<addaction name="action_state"/>
<addaction name="action_template"/>
<addaction name="action_netvm"/>
Expand Down

0 comments on commit af555fa

Please sign in to comment.