# Path: qcrash/_forms/dlg_report_bug_ui.py
# class Ui_Dialog(object):
#     def setupUi(self, Dialog):
#     def retranslateUi(self, Dialog):
# 
# Path: qcrash/_dialogs/review.py
# class DlgReview(QtWidgets.QDialog):
#     """
#     Dialog for reviewing the final report.
#     """
#     def __init__(self, content, log, parent, window_icon):
#         """
#         :param content: content of the final report, before review
#         :param parent: parent widget
#         """
#         super(DlgReview, self).__init__(parent)
#         self.ui = dlg_review_ui.Ui_Dialog()
#         self.ui.setupUi(self)
#         self.ui.tabWidget.setCurrentIndex(0)
#         self.ui.edit_main.setPlainText(content)
#         self.ui.edit_main.installEventFilter(self)
#         self.ui.edit_log.installEventFilter(self)
#         self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
#         self.setWindowIcon(
#             QtGui.QIcon.fromTheme('document-edit')
#             if window_icon is None else window_icon)
#         if log:
#             self.ui.edit_log.setPlainText(log)
#         else:
#             self.ui.tabWidget.tabBar().hide()
#         self.ui.edit_main.setFocus()
# 
#     def eventFilter(self, obj, event):
#         interesting_objects = [self.ui.edit_log, self.ui.edit_main]
#         if obj in interesting_objects and event.type() == QtCore.QEvent.KeyPress:
#             if event.key() == QtCore.Qt.Key_Return and \
#                     event.modifiers() & QtCore.Qt.ControlModifier:
#                 self.accept()
#                 return True
#         return False
# 
#     @classmethod
#     def review(cls, content, log, parent, window_icon):  # pragma: no cover
#         """
#         Reviews the final bug report.
# 
#         :param content: content of the final report, before review
#         :param parent: parent widget
# 
#         :returns: the reviewed report content or None if the review was
#                   canceled.
#         """
#         dlg = DlgReview(content, log, parent, window_icon)
#         if dlg.exec_():
#             return dlg.ui.edit_main.toPlainText(), \
#                 dlg.ui.edit_log.toPlainText()
#         return None, None


import logging
from qcrash._forms import dlg_report_bug_ui
from qcrash.qt import QtCore, QtGui, QtWidgets
from qcrash._dialogs.review import DlgReview
        from qcrash import api

LOG_LIMIT = 100  # keep only the last 100 lines


class DlgReport(QtWidgets.QDialog):
    """
    A qt dialog for reporting an issue on github or via email.

    The dialog let the user choose whether he wants to report an issue or
    propose an enhancement. Depending on its choice the issue title will be
    prefixed by "[Bug]" or "Enhancement". The user must write a description
    of the issue. User can choose to send the report via email or on github
    (using the user's credentials).

    The client code can specify some additional information to be included in
    the report (but hidden in thr dialog).

        - sys_infos: information about the system
        - traceback: the traceback of an unhandled exception
        - log: the application log (will be truncated).

    """

    def __init__(self, backends, window_title='Report an issue...',
                 window_icon=None, traceback=None, issue_title='',
                 issue_description='', include_log=True, include_sys_info=True,
                 **kwargs):
        super(DlgReport, self).__init__(**kwargs)
        self._traceback = traceback
        self.window_icon = window_icon

# Path: qcrash/_forms/dlg_report_bug_ui.py
# class Ui_Dialog(object):
#     def setupUi(self, Dialog):
#     def retranslateUi(self, Dialog):
# 
# Path: qcrash/_dialogs/review.py
# class DlgReview(QtWidgets.QDialog):
#     """
#     Dialog for reviewing the final report.
#     """
#     def __init__(self, content, log, parent, window_icon):
#         """
#         :param content: content of the final report, before review
#         :param parent: parent widget
#         """
#         super(DlgReview, self).__init__(parent)
#         self.ui = dlg_review_ui.Ui_Dialog()
#         self.ui.setupUi(self)
#         self.ui.tabWidget.setCurrentIndex(0)
#         self.ui.edit_main.setPlainText(content)
#         self.ui.edit_main.installEventFilter(self)
#         self.ui.edit_log.installEventFilter(self)
#         self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
#         self.setWindowIcon(
#             QtGui.QIcon.fromTheme('document-edit')
#             if window_icon is None else window_icon)
#         if log:
#             self.ui.edit_log.setPlainText(log)
#         else:
#             self.ui.tabWidget.tabBar().hide()
#         self.ui.edit_main.setFocus()
# 
#     def eventFilter(self, obj, event):
#         interesting_objects = [self.ui.edit_log, self.ui.edit_main]
#         if obj in interesting_objects and event.type() == QtCore.QEvent.KeyPress:
#             if event.key() == QtCore.Qt.Key_Return and \
#                     event.modifiers() & QtCore.Qt.ControlModifier:
#                 self.accept()
#                 return True
#         return False
# 
#     @classmethod
#     def review(cls, content, log, parent, window_icon):  # pragma: no cover
#         """
#         Reviews the final bug report.
# 
#         :param content: content of the final report, before review
#         :param parent: parent widget
# 
#         :returns: the reviewed report content or None if the review was
#                   canceled.
#         """
#         dlg = DlgReview(content, log, parent, window_icon)
#         if dlg.exec_():
#             return dlg.ui.edit_main.toPlainText(), \
#                 dlg.ui.edit_log.toPlainText()
#         return None, None


# Path: qcrash/_dialogs/report.py
import logging
from qcrash._forms import dlg_report_bug_ui
from qcrash.qt import QtCore, QtGui, QtWidgets
from qcrash._dialogs.review import DlgReview
        from qcrash import api


LOG_LIMIT = 100  # keep only the last 100 lines


class DlgReport(QtWidgets.QDialog):
    """
    A qt dialog for reporting an issue on github or via email.

    The dialog let the user choose whether he wants to report an issue or
    propose an enhancement. Depending on its choice the issue title will be
    prefixed by "[Bug]" or "Enhancement". The user must write a description
    of the issue. User can choose to send the report via email or on github
    (using the user's credentials).

    The client code can specify some additional information to be included in
    the report (but hidden in thr dialog).

        - sys_infos: information about the system
        - traceback: the traceback of an unhandled exception
        - log: the application log (will be truncated).

    """

    def __init__(self, backends, window_title='Report an issue...',
                 window_icon=None, traceback=None, issue_title='',
                 issue_description='', include_log=True, include_sys_info=True,
                 **kwargs):
        super(DlgReport, self).__init__(**kwargs)
        self._traceback = traceback
        self.window_icon = window_icon

        self.ui = dlg_report_bug_ui.Ui_Dialog()