summaryrefslogtreecommitdiff
path: root/portato/gui/qt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/gui/qt/windows.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py
index 5aa0e24..ba4dcc5 100644
--- a/portato/gui/qt/windows.py
+++ b/portato/gui/qt/windows.py
@@ -32,7 +32,7 @@ from highlighter import EbuildHighlighter
from dialogs import *
from helper import qCheck, qIsChecked
-import types
+import types, logging
UI_DIR = DATA_DIR+"ui/"
@@ -252,6 +252,27 @@ class EbuildDialog (Window):
self.doc.setPlainText("".join(lines))
self.ebuildEdit.setDocument(self.doc)
+class LogDialog (Window, logging.Handler):
+
+ __metaclass__ = WindowMeta
+
+ def __init__ (self, parent):
+ Window.__init__(self, parent)
+
+ self.setAttribute(Qt.Qt.WA_DeleteOnClose, False)
+ logging.Handler.__init__(self, logging.INFO)
+ logging.getLogger("portatoLogger").addHandler(self)
+
+ def format (self, record):
+
+ if (record.levelno > logging.INFO):
+ return "%s: %s" % (record.levelname, record.getMessage())
+ else:
+ return record.getMessage()
+
+ def emit (self, record):
+ self.logView.insertPlainText(self.format(record)+"\n")
+
class PreferenceWindow (Window):
"""Window displaying some preferences."""
@@ -707,6 +728,9 @@ class MainWindow (Window):
self.doUpdate = False
self.pkgDetails = PackageDetails(self)
+ # set the logger as early as possible
+ self.logDialog = LogDialog(self)
+
# package db
self.db = Database()
self.db.populate()
@@ -843,6 +867,10 @@ class MainWindow (Window):
self.systray = None
@Qt.pyqtSignature("")
+ def on_logAction_triggered (self):
+ self.logDialog.show()
+
+ @Qt.pyqtSignature("")
def on_aboutAction_triggered (self):
AboutDialog(self).exec_()