diff --git a/qubesmanager/log_dialog.py b/qubesmanager/log_dialog.py
index a5f07b9..f173d70 100644
--- a/qubesmanager/log_dialog.py
+++ b/qubesmanager/log_dialog.py
@@ -20,13 +20,12 @@
#
#
import sys
+import os
+from functools import partial
from PyQt5 import QtWidgets # pylint: disable=import-error
-
+from qubesadmin import Qubes
from . import ui_logdlg # pylint: disable=no-name-in-module
from . import clipboard
-import os
-
-from qubesadmin import Qubes
# Display only this size of log
LOG_DISPLAY_SIZE = 1024*1024
@@ -39,10 +38,9 @@ class LogDialog(ui_logdlg.Ui_LogDialog, QtWidgets.QDialog):
super().__init__(parent)
self.app = app
- self.log_path = log_path
+ self.logfiles = log_path
self.setupUi(self)
- self.setWindowTitle(log_path)
self.copy_to_qubes_clipboard.clicked.connect(
self.copy_to_clipboard_triggered)
@@ -52,8 +50,31 @@ class LogDialog(ui_logdlg.Ui_LogDialog, QtWidgets.QDialog):
self.__init_log_text__()
def __init_log_text__(self):
+ butts_in_row = 3
+ count = 0
+ for log_path in self.logfiles:
+ if os.path.exists(log_path):
+ button = QtWidgets.QPushButton(log_path)
+ button.clicked.connect(partial(self.set_current_log, log_path))
+ self.buttonsLayout.addWidget(button, count / butts_in_row, count % butts_in_row)
+ count += 1
+
+ if count == 0:
+ QtWidgets.QMessageBox.warning(
+ self,
+ self.tr("Error"),
+ self.tr(
+ "No log files where found for current selection"))
+ else:
+ self.buttonsLayout.itemAt(0).widget().click()
+
+ def copy_to_clipboard_triggered(self):
+ clipboard.copy_text_to_qubes_clipboard(self.displayed_text)
+
+ def set_current_log(self, log_path):
+ self.setWindowTitle(log_path)
self.displayed_text = ""
- log = open(self.log_path)
+ log = open(log_path)
log.seek(0, os.SEEK_END)
if log.tell() > LOG_DISPLAY_SIZE:
self.displayed_text = self.tr(
@@ -64,11 +85,6 @@ class LogDialog(ui_logdlg.Ui_LogDialog, QtWidgets.QDialog):
self.displayed_text += log.read()
log.close()
self.log_text.setPlainText(self.displayed_text)
- self.log_text.show()
-
- def copy_to_clipboard_triggered(self):
- clipboard.copy_text_to_qubes_clipboard(self.displayed_text)
-
def main():
qubes_app = Qubes()
diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py
index 91023d1..d2a8312 100644
--- a/qubesmanager/qube_manager.py
+++ b/qubesmanager/qube_manager.py
@@ -689,7 +689,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
self.context_menu.addAction(self.action_removevm)
self.context_menu.addSeparator()
- self.context_menu.addMenu(self.logs_menu)
+ self.context_menu.addAction(self.action_show_logs)
self.context_menu.addSeparator()
self.tools_context_menu = QMenu(self)
@@ -702,7 +702,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
lambda pos: self.open_tools_context_menu(self.toolbar, pos))
self.action_menubar.toggled.connect(self.showhide_menubar)
self.action_toolbar.toggled.connect(self.showhide_toolbar)
- self.logs_menu.triggered.connect(self.show_log)
+ self.action_show_logs.triggered.connect(self.show_log)
self.table.resizeColumnsToContents()
@@ -1030,8 +1030,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
if not vm.updateable and vm.klass != 'AdminVM':
self.action_updatevm.setEnabled(False)
- self.update_logs_menu()
-
# noinspection PyArgumentList
@pyqtSlot(name='on_action_createvm_triggered')
def action_createvm_triggered(self):
@@ -1428,48 +1426,32 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
def open_tools_context_menu(self, widget, point):
self.tools_context_menu.exec_(widget.mapToGlobal(point))
- def update_logs_menu(self):
- self.logs_menu.clear()
- menu_empty = True
-
- try:
- vm_info = self.get_selected_vms()
-
- if len(vm_info) == 1:
- vm = vm_info[0].vm
-
- if vm.klass == 'AdminVM':
- logfiles = ["/var/log/xen/console/hypervisor.log"]
- else:
- logfiles = [
- "/var/log/xen/console/guest-" + vm.name + ".log",
- "/var/log/xen/console/guest-" + vm.name + "-dm.log",
- "/var/log/qubes/guid." + vm.name + ".log",
- "/var/log/qubes/qrexec." + vm.name + ".log",
- ]
-
- for logfile in logfiles:
- if os.path.exists(logfile):
- action = self.logs_menu.addAction(QIcon(":/log.png"),
- logfile)
- action.setData(logfile)
- menu_empty = False
-
- self.logs_menu.setEnabled(not menu_empty)
- except exc.QubesDaemonAccessError:
- pass
-
@pyqtSlot('const QPoint&')
def open_context_menu(self, point):
self.context_menu.exec_(self.table.mapToGlobal(
point + QPoint(10, 0)))
- @pyqtSlot('QAction *')
- def show_log(self, action):
- log = str(action.data())
- log_dlg = log_dialog.LogDialog(self.qt_app, log)
- log_dlg.exec_()
+ def show_log(self):
+ logfiles = []
+ try:
+ for vm_info in self.get_selected_vms():
+ vm = vm_info.vm
+
+ if vm.klass == 'AdminVM':
+ logfiles.append("/var/log/xen/console/hypervisor.log")
+ else:
+ logfiles.extend([
+ "/var/log/xen/console/guest-" + vm.name + ".log",
+ "/var/log/xen/console/guest-" + vm.name + "-dm.log",
+ "/var/log/qubes/guid." + vm.name + ".log",
+ "/var/log/qubes/qrexec." + vm.name + ".log",
+ ])
+
+ log_dlg = log_dialog.LogDialog(self.qt_app, logfiles)
+ log_dlg.exec_()
+ except exc.QubesDaemonAccessError:
+ pass
def main():
manager_utils.run_asynchronous(VmManagerWindow)
diff --git a/ui/logdlg.ui b/ui/logdlg.ui
index 06976f5..b1e69cd 100644
--- a/ui/logdlg.ui
+++ b/ui/logdlg.ui
@@ -14,6 +14,9 @@
Dialog
+ -
+
+
-
diff --git a/ui/qubemanager.ui b/ui/qubemanager.ui
index 47fd249..24175db 100644
--- a/ui/qubemanager.ui
+++ b/ui/qubemanager.ui
@@ -297,7 +297,7 @@ Template
-
+