UI/ErrorLogDialog.py

Sat, 31 Mar 2012 12:52:45 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Mar 2012 12:52:45 +0200
changeset 1745
74c05a1ca2bc
parent 1740
6a92ffd41de8
child 2302
f29e9405c851
permissions
-rw-r--r--

Fixed an issue with the new error log dialog.

# -*- coding: utf-8 -*-

# Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to display an error log.
"""

import os

from PyQt4.QtCore import pyqtSlot
from PyQt4.QtGui import QDialog, QStyle

from .Ui_ErrorLogDialog import Ui_ErrorLogDialog


class ErrorLogDialog(QDialog, Ui_ErrorLogDialog):
    """
    Class implementing a dialog to display an error log.
    """
    def __init__(self, logFile, parent=None):
        """
        Constructor
        
        @param logFile name of the log file containing the error info (string)
        @param parent reference to the parent widget (QWidget)
        """
        super().__init__(parent)
        self.setupUi(self)
        
        pixmap = self.style().standardIcon(QStyle.SP_MessageBoxQuestion).pixmap(32, 32)
        self.icon.setPixmap(pixmap)
        
        self.__ui = parent
        self.__logFile = logFile
        
        try:
            f = open(logFile, "r", encoding="utf-8")
            txt = f.read()
            f.close()
            self.logEdit.setPlainText(txt)
        except IOError:
            pass
    
    @pyqtSlot()
    def on_emailButton_clicked(self):
        """
        Private slot to send an email.
        """
        self.accept()
        self.__ui.showEmailDialog("bug",
            attachFile=self.__logFile, deleteAttachFile=True)
    
    @pyqtSlot()
    def on_deleteButton_clicked(self):
        """
        Private slot to delete the log file.
        """
        if os.path.exists(self.__logFile):
            os.remove(self.__logFile)
        self.accept()
    
    @pyqtSlot()
    def on_keepButton_clicked(self):
        """
        Private slot to just do nothing.
        """
        self.accept()

eric ide

mercurial