# Path: reggata/gui/my_message_box.py
# class MyMessageBox(QtGui.QMessageBox):
#     '''
#         This MessageBox window can be resized with a mouse. Standard QMessageBox
#     could not. Solution was taken from here:
#     http://stackoverflow.com/questions/2655354/how-to-allow-resizing-of-qmessagebox-in-pyqt4
#     '''
#     def __init__(self, parent=None):
#         super(MyMessageBox, self).__init__(parent)
#         self.setSizeGripEnabled(True)
#         self.addButton(QtGui.QMessageBox.Ok)
#         self.setDefaultButton(QtGui.QMessageBox.Ok)
#         self.setEscapeButton(QtGui.QMessageBox.Ok)
# 
#     def event(self, e):
#         result = QtGui.QMessageBox.event(self, e)
# 
#         self.setMinimumHeight(0)
#         self.setMaximumHeight(16777215)
#         self.setMinimumWidth(0)
#         self.setMaximumWidth(16777215)
#         self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
# 
#         textEdit = self.findChild(QtGui.QTextEdit)
#         if textEdit != None :
#             textEdit.setMinimumHeight(0)
#             textEdit.setMaximumHeight(16777215)
#             textEdit.setMinimumWidth(0)
#             textEdit.setMaximumWidth(16777215)
#             textEdit.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
# 
#         return result


import PyQt4.QtGui as QtGui
import PyQt4.QtCore as QtCore
import traceback
import os
import hashlib
import platform
import math
import logging
import reggata.consts as consts
from PyQt4.QtCore import Qt
from PyQt4.QtCore import QCoreApplication
from reggata.gui.my_message_box import MyMessageBox

Module contains various helper global functions.
'''


logger = logging.getLogger(__name__)


#def tr(text):
#    '''Translates text of GUI to foreign languages.'''
#    s = QCoreApplication.translate("@default", str(text), None, QCoreApplication.UnicodeUTF8)
#    return s


# TODO: move this function to DialogsFacade
# TODO: split this function to several functions with less arguments...
def show_exc_info(parent, ex, tracebk=True, details=None, title=None):
    '''
        Shows a MyMessageBox dialog with information about given exception.
        parent --- Qt parent of the dialog to be shown.
        ex --- an exception to be described in the dialog.
        tracebk --- when tracebk is True the dialog would contain a DetailedText
    button. When user presses that button --- an info with stack trace is shown in
    the dialog.
        details --- when details is not None, then it is displayed in the DetailedText
    area of the dialog (instead of stack trace). In this case value of tracebk is
    ignored.
        title --- set different title to the dialog. When title is None, the dialog
    has a default title.
    '''

# Path: reggata/gui/my_message_box.py
# class MyMessageBox(QtGui.QMessageBox):
#     '''
#         This MessageBox window can be resized with a mouse. Standard QMessageBox
#     could not. Solution was taken from here:
#     http://stackoverflow.com/questions/2655354/how-to-allow-resizing-of-qmessagebox-in-pyqt4
#     '''
#     def __init__(self, parent=None):
#         super(MyMessageBox, self).__init__(parent)
#         self.setSizeGripEnabled(True)
#         self.addButton(QtGui.QMessageBox.Ok)
#         self.setDefaultButton(QtGui.QMessageBox.Ok)
#         self.setEscapeButton(QtGui.QMessageBox.Ok)
# 
#     def event(self, e):
#         result = QtGui.QMessageBox.event(self, e)
# 
#         self.setMinimumHeight(0)
#         self.setMaximumHeight(16777215)
#         self.setMinimumWidth(0)
#         self.setMaximumWidth(16777215)
#         self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
# 
#         textEdit = self.findChild(QtGui.QTextEdit)
#         if textEdit != None :
#             textEdit.setMinimumHeight(0)
#             textEdit.setMaximumHeight(16777215)
#             textEdit.setMinimumWidth(0)
#             textEdit.setMaximumWidth(16777215)
#             textEdit.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
# 
#         return result


# Path: reggata/helpers.py
import PyQt4.QtGui as QtGui
import PyQt4.QtCore as QtCore
import traceback
import os
import hashlib
import platform
import math
import logging
import reggata.consts as consts
from PyQt4.QtCore import Qt
from PyQt4.QtCore import QCoreApplication
from reggata.gui.my_message_box import MyMessageBox


Module contains various helper global functions.
'''


logger = logging.getLogger(__name__)


#def tr(text):
#    '''Translates text of GUI to foreign languages.'''
#    s = QCoreApplication.translate("@default", str(text), None, QCoreApplication.UnicodeUTF8)
#    return s


# TODO: move this function to DialogsFacade
# TODO: split this function to several functions with less arguments...
def show_exc_info(parent, ex, tracebk=True, details=None, title=None):
    '''
        Shows a MyMessageBox dialog with information about given exception.
        parent --- Qt parent of the dialog to be shown.
        ex --- an exception to be described in the dialog.
        tracebk --- when tracebk is True the dialog would contain a DetailedText
    button. When user presses that button --- an info with stack trace is shown in
    the dialog.
        details --- when details is not None, then it is displayed in the DetailedText
    area of the dialog (instead of stack trace). In this case value of tracebk is
    ignored.
        title --- set different title to the dialog. When title is None, the dialog
    has a default title.
    '''

    mb = MyMessageBox(parent)