2010-09-07 20:42:33 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-04-13 13:00:22 +00:00
|
|
|
##########################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# ---------------------------------------------------------------------- #
|
2020-12-30 21:42:49 +00:00
|
|
|
# Copyright (c) 2008-2021 OpenLP Developers #
|
2019-04-13 13:00:22 +00:00
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# This program is free software: you can redistribute it and/or modify #
|
|
|
|
# it under the terms of the GNU General Public License as published by #
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or #
|
|
|
|
# (at your option) any later version. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, #
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
|
# GNU General Public License for more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License #
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
|
|
|
##########################################################################
|
2013-02-01 19:58:18 +00:00
|
|
|
"""
|
|
|
|
The GUI widgets of the exception dialog.
|
|
|
|
"""
|
2010-09-07 20:42:33 +00:00
|
|
|
|
2018-10-27 01:40:20 +00:00
|
|
|
from PyQt5 import QtWidgets
|
2010-09-07 20:42:33 +00:00
|
|
|
|
2018-04-10 19:26:56 +00:00
|
|
|
from openlp.core.common.i18n import translate
|
2012-04-02 00:19:16 +00:00
|
|
|
from openlp.core.lib.ui import create_button, create_button_box
|
2018-10-02 04:39:42 +00:00
|
|
|
from openlp.core.ui.icons import UiIcons
|
2010-09-07 20:42:33 +00:00
|
|
|
|
2013-02-01 19:58:18 +00:00
|
|
|
|
2010-09-07 20:42:33 +00:00
|
|
|
class Ui_ExceptionDialog(object):
|
2013-02-01 19:58:18 +00:00
|
|
|
"""
|
|
|
|
The GUI widgets of the exception dialog.
|
|
|
|
"""
|
2018-09-12 05:43:27 +00:00
|
|
|
def setup_ui(self, exception_dialog):
|
2013-02-01 19:58:18 +00:00
|
|
|
"""
|
|
|
|
Set up the UI.
|
|
|
|
"""
|
2013-08-31 18:17:38 +00:00
|
|
|
exception_dialog.setObjectName('exception_dialog')
|
2018-04-21 19:57:51 +00:00
|
|
|
exception_dialog.setWindowIcon(UiIcons().main_icon)
|
2015-11-07 00:49:40 +00:00
|
|
|
self.exception_layout = QtWidgets.QVBoxLayout(exception_dialog)
|
2013-08-31 18:17:38 +00:00
|
|
|
self.exception_layout.setObjectName('exception_layout')
|
2015-11-07 00:49:40 +00:00
|
|
|
self.message_layout = QtWidgets.QHBoxLayout()
|
2013-08-31 18:17:38 +00:00
|
|
|
self.message_layout.setObjectName('messageLayout')
|
2016-04-09 23:51:41 +00:00
|
|
|
# Set margin to make the box a bit wider so the traceback is easier to read. (left, top, right, bottom)
|
|
|
|
self.message_layout.setContentsMargins(0, 0, 50, 0)
|
2013-03-05 14:02:56 +00:00
|
|
|
self.message_layout.addSpacing(12)
|
2015-11-07 00:49:40 +00:00
|
|
|
self.bug_label = QtWidgets.QLabel(exception_dialog)
|
2018-06-10 19:29:00 +00:00
|
|
|
self.bug_label.setPixmap(UiIcons().exception.pixmap(40, 40))
|
2015-11-07 00:49:40 +00:00
|
|
|
self.bug_label.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
|
2013-08-31 18:17:38 +00:00
|
|
|
self.bug_label.setObjectName('bug_label')
|
2013-03-05 14:02:56 +00:00
|
|
|
self.message_layout.addWidget(self.bug_label)
|
|
|
|
self.message_layout.addSpacing(12)
|
2015-11-07 00:49:40 +00:00
|
|
|
self.message_label = QtWidgets.QLabel(exception_dialog)
|
2013-03-05 14:02:56 +00:00
|
|
|
self.message_label.setWordWrap(True)
|
2013-08-31 18:17:38 +00:00
|
|
|
self.message_label.setObjectName('message_label')
|
2013-03-05 14:02:56 +00:00
|
|
|
self.message_layout.addWidget(self.message_label)
|
|
|
|
self.exception_layout.addLayout(self.message_layout)
|
2015-11-07 00:49:40 +00:00
|
|
|
self.description_explanation = QtWidgets.QLabel(exception_dialog)
|
2013-08-31 18:17:38 +00:00
|
|
|
self.description_explanation.setObjectName('description_explanation')
|
2013-03-05 14:02:56 +00:00
|
|
|
self.exception_layout.addWidget(self.description_explanation)
|
2015-11-07 00:49:40 +00:00
|
|
|
self.description_text_edit = QtWidgets.QPlainTextEdit(exception_dialog)
|
2013-08-31 18:17:38 +00:00
|
|
|
self.description_text_edit.setObjectName('description_text_edit')
|
2013-03-05 14:02:56 +00:00
|
|
|
self.exception_layout.addWidget(self.description_text_edit)
|
2015-11-07 00:49:40 +00:00
|
|
|
self.description_word_count = QtWidgets.QLabel(exception_dialog)
|
2013-08-31 18:17:38 +00:00
|
|
|
self.description_word_count.setObjectName('description_word_count')
|
2013-03-05 14:02:56 +00:00
|
|
|
self.exception_layout.addWidget(self.description_word_count)
|
2015-11-07 00:49:40 +00:00
|
|
|
self.exception_text_edit = QtWidgets.QPlainTextEdit(exception_dialog)
|
2013-03-05 14:02:56 +00:00
|
|
|
self.exception_text_edit.setReadOnly(True)
|
2013-08-31 18:17:38 +00:00
|
|
|
self.exception_text_edit.setObjectName('exception_text_edit')
|
2013-03-05 14:02:56 +00:00
|
|
|
self.exception_layout.addWidget(self.exception_text_edit)
|
2013-08-31 18:17:38 +00:00
|
|
|
self.send_report_button = create_button(exception_dialog, 'send_report_button',
|
2018-04-17 20:50:27 +00:00
|
|
|
icon=UiIcons().email,
|
2013-12-24 11:32:38 +00:00
|
|
|
click=self.on_send_report_button_clicked)
|
2013-08-31 18:17:38 +00:00
|
|
|
self.save_report_button = create_button(exception_dialog, 'save_report_button',
|
2018-04-07 19:41:00 +00:00
|
|
|
icon=UiIcons().save,
|
2013-12-24 11:32:38 +00:00
|
|
|
click=self.on_save_report_button_clicked)
|
2019-03-03 09:49:01 +00:00
|
|
|
self.attach_file_button = create_button(exception_dialog, 'attach_file_button',
|
2018-04-13 18:54:42 +00:00
|
|
|
icon=UiIcons().open,
|
2013-12-24 11:32:38 +00:00
|
|
|
click=self.on_attach_file_button_clicked)
|
2014-03-20 19:10:31 +00:00
|
|
|
self.button_box = create_button_box(exception_dialog, 'button_box', ['close'],
|
2019-03-03 09:49:01 +00:00
|
|
|
[self.send_report_button, self.save_report_button, self.attach_file_button])
|
2013-03-05 14:02:56 +00:00
|
|
|
self.exception_layout.addWidget(self.button_box)
|
2010-12-11 15:39:12 +00:00
|
|
|
|
2018-09-12 05:43:27 +00:00
|
|
|
self.retranslate_ui(exception_dialog)
|
2013-03-05 14:05:19 +00:00
|
|
|
self.description_text_edit.textChanged.connect(self.on_description_updated)
|
2010-09-07 20:42:33 +00:00
|
|
|
|
2018-09-12 05:43:27 +00:00
|
|
|
def retranslate_ui(self, exception_dialog):
|
2013-02-01 19:58:18 +00:00
|
|
|
"""
|
|
|
|
Translate the widgets on the fly.
|
|
|
|
"""
|
2018-04-17 20:50:27 +00:00
|
|
|
# Note that bugs mail is not clickable, but it adds the blue color and underlining and makes the test copyable.
|
2016-05-10 11:13:41 +00:00
|
|
|
exception_dialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred'))
|
2016-05-10 00:53:14 +00:00
|
|
|
# Explanation text, adds a small space before: If possible, write in English.
|
2014-04-12 20:19:22 +00:00
|
|
|
self.description_explanation.setText(
|
2016-04-09 23:51:41 +00:00
|
|
|
translate('OpenLP.ExceptionDialog', '<strong>Please describe what you were trying to do.</strong> '
|
|
|
|
' If possible, write in English.'))
|
2016-05-10 11:06:00 +00:00
|
|
|
exception_part1 = (translate('OpenLP.ExceptionDialog',
|
2016-09-09 07:57:11 +00:00
|
|
|
'<strong>Oops, OpenLP hit a problem and couldn\'t recover!<br><br>'
|
|
|
|
'You can help </strong> the OpenLP developers to <strong>fix this</strong>'
|
|
|
|
' by<br> sending them a <strong>bug report to {email}</strong>{newlines}'
|
2020-01-06 21:15:11 +00:00
|
|
|
).format(email='<a href = "mailto:bugs3@openlp.org" > bugs3@openlp.org</a>',
|
2016-05-10 11:06:00 +00:00
|
|
|
newlines='<br><br>'))
|
2014-04-12 20:19:22 +00:00
|
|
|
self.message_label.setText(
|
2016-05-10 01:55:26 +00:00
|
|
|
translate('OpenLP.ExceptionDialog', '{first_part}'
|
2016-04-09 23:51:41 +00:00
|
|
|
'<strong>No email app? </strong> You can <strong>save</strong> this '
|
|
|
|
'information to a <strong>file</strong> and<br>'
|
2016-08-03 21:19:14 +00:00
|
|
|
'send it from your <strong>mail on browser</strong> via an <strong>attachment.</strong><br><br>'
|
2016-09-02 16:54:00 +00:00
|
|
|
'<strong>Thank you</strong> for being part of making OpenLP better!<br>'
|
2016-05-10 11:13:41 +00:00
|
|
|
).format(first_part=exception_part1))
|
2013-03-05 14:02:56 +00:00
|
|
|
self.send_report_button.setText(translate('OpenLP.ExceptionDialog', 'Send E-Mail'))
|
|
|
|
self.save_report_button.setText(translate('OpenLP.ExceptionDialog', 'Save to File'))
|
2019-03-03 09:49:01 +00:00
|
|
|
self.attach_file_button.setText(translate('OpenLP.ExceptionDialog', 'Attach File'))
|