From 5fccadad4e687a1e39875d075b283141175eb8a3 Mon Sep 17 00:00:00 2001 From: shivansh02 Date: Sun, 31 Mar 2024 08:04:21 +0530 Subject: [PATCH 1/5] improved exception dialog --- src/vorta/__main__.py | 21 +-- src/vorta/assets/UI/exceptiondialog.ui | 172 +++++++++++++++++++++++++ src/vorta/assets/icons/alert.svg | 129 +++++++++++++++++++ src/vorta/views/exception_dialog.py | 58 +++++++++ 4 files changed, 366 insertions(+), 14 deletions(-) create mode 100644 src/vorta/assets/UI/exceptiondialog.ui create mode 100644 src/vorta/assets/icons/alert.svg create mode 100644 src/vorta/views/exception_dialog.py diff --git a/src/vorta/__main__.py b/src/vorta/__main__.py index 29d24beb0..664f8d41e 100644 --- a/src/vorta/__main__.py +++ b/src/vorta/__main__.py @@ -8,36 +8,29 @@ # because we will be overriding the modules variables from vorta import config from vorta._version import __version__ -from vorta.i18n import trans_late, translate from vorta.log import init_logger, logger from vorta.store.connection import init_db from vorta.updater import get_updater from vorta.utils import DEFAULT_DIR_FLAG, parse_args +from vorta.views.exception_dialog import ExceptionDialog def main(): def exception_handler(type, value, tb): from traceback import format_exception - from PyQt6.QtWidgets import QMessageBox - logger.critical( "Uncaught exception, file a report at https://github.com/borgbase/vorta/issues/new/choose", exc_info=(type, value, tb), ) full_exception = ''.join(format_exception(type, value, tb)) - title = trans_late('app', 'Fatal Error') - error_message = trans_late( - 'app', - 'Uncaught exception, please file a report with this text at\n' - 'https://github.com/borgbase/vorta/issues/new\n', - ) + if app: - QMessageBox.critical( - None, - translate('app', title), - translate('app', error_message) + full_exception, - ) + exception_dialog = ExceptionDialog(full_exception) + exception_dialog.show() + exception_dialog.raise_() + exception_dialog.activateWindow() + exception_dialog.exec() else: # Crashed before app startup, cannot translate sys.exit(1) diff --git a/src/vorta/assets/UI/exceptiondialog.ui b/src/vorta/assets/UI/exceptiondialog.ui new file mode 100644 index 000000000..952b8bd49 --- /dev/null +++ b/src/vorta/assets/UI/exceptiondialog.ui @@ -0,0 +1,172 @@ + + + Dialog + + + Qt::NonModal + + + + 0 + 0 + 674 + 296 + + + + + 0 + 0 + + + + Fatal Error + + + true + + + + + + 10 + + + 10 + + + 10 + + + 10 + + + + + 0 + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + 0 + + + 0 + + + + + + true + + + + Vorta quit unexpectedly. + + + + + + + <html><head/><body><p>You can report this issue on <a href="https://github.com/borgbase/vorta/issues"><span style=" text-decoration: underline; color:#0984e3;">Github</span></a>. Please search for similar issues before reporting.</p></body></html> + + + true + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 5 + + + + + + + + Crash Report: + + + + + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Ignore + + + + + + + Copy to Clipboard + + + + + + + + + + + + diff --git a/src/vorta/assets/icons/alert.svg b/src/vorta/assets/icons/alert.svg new file mode 100644 index 000000000..557cbcac0 --- /dev/null +++ b/src/vorta/assets/icons/alert.svg @@ -0,0 +1,129 @@ + + + Warning sign + + + + Warning sign + + + + + caution + security + warning + signs_and_symbols + sign + + + + + Thomas Weller + + + + + Thomas Weller + + + + + Thomas Weller + + + + image/svg+xml + + + en + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/vorta/views/exception_dialog.py b/src/vorta/views/exception_dialog.py new file mode 100644 index 000000000..131a38702 --- /dev/null +++ b/src/vorta/views/exception_dialog.py @@ -0,0 +1,58 @@ +import datetime +import platform + +from PyQt6 import uic +from PyQt6.QtWidgets import QApplication + +from vorta._version import __version__ +from vorta.utils import borg_compat +from vorta.views.utils import get_colored_icon + +from ..utils import get_asset + +# Load UI file +uifile = get_asset('UI/exceptiondialog.ui') +ExceptionDialogUI, ExceptionDialogBase = uic.loadUiType(uifile) + + +class ExceptionDetails: + @staticmethod + def get_os_details(): + uname_result = platform.uname() + os_details = f"OS: {uname_result.system}\n" + os_details += f"Node Name: {uname_result.node}\n" + os_details += f"Release: {uname_result.release}\n" + os_details += f"Version: {uname_result.version}" + return os_details + + @staticmethod + def get_exception_details(exception): + os_details = ExceptionDetails.get_os_details() + details = os_details + details += "\nDate and Time: " + str(datetime.datetime.now()) + details += "\nBorg Version: " + borg_compat.version + details += "\nVorta Version: " + __version__ + details += "\nLog:\n" + exception + return details + + +class ExceptionDialog(ExceptionDialogBase, ExceptionDialogUI): + def __init__(self, exception: str): + super().__init__() + self.setupUi(self) + + self.label_2.setOpenExternalLinks(True) + self.ignoreButton.clicked.connect(self.close) + self.copyButton.clicked.connect(self.copy_report_to_clipboard) + + # Set crash details + details = ExceptionDetails.get_exception_details(exception) + self.crashDetails.setPlainText(details) + + # Set alert image + self.alertImage.setPixmap(get_colored_icon('alert', scaled_height=70, return_qpixmap=True)) + + def copy_report_to_clipboard(self): + cb = QApplication.clipboard() + cb.clear(mode=cb.Mode.Clipboard) + cb.setText(self.crashDetails.toPlainText(), mode=cb.Mode.Clipboard) From 51bd451dfa6b071c7bc937749e5af4dfd843ffec Mon Sep 17 00:00:00 2001 From: shivansh02 Date: Tue, 2 Apr 2024 11:38:38 +0530 Subject: [PATCH 2/5] improved label names, added button icons --- src/vorta/assets/UI/exceptiondialog.ui | 14 +++++++------- src/vorta/views/exception_dialog.py | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/vorta/assets/UI/exceptiondialog.ui b/src/vorta/assets/UI/exceptiondialog.ui index 952b8bd49..90e05bdfc 100644 --- a/src/vorta/assets/UI/exceptiondialog.ui +++ b/src/vorta/assets/UI/exceptiondialog.ui @@ -77,7 +77,7 @@ 0 - + true @@ -89,7 +89,7 @@ - + <html><head/><body><p>You can report this issue on <a href="https://github.com/borgbase/vorta/issues"><span style=" text-decoration: underline; color:#0984e3;">Github</span></a>. Please search for similar issues before reporting.</p></body></html> @@ -148,11 +148,11 @@ - - - Ignore - - + + + QDialogButtonBox::Close + + diff --git a/src/vorta/views/exception_dialog.py b/src/vorta/views/exception_dialog.py index 131a38702..716fe9c62 100644 --- a/src/vorta/views/exception_dialog.py +++ b/src/vorta/views/exception_dialog.py @@ -32,7 +32,7 @@ def get_exception_details(exception): details += "\nDate and Time: " + str(datetime.datetime.now()) details += "\nBorg Version: " + borg_compat.version details += "\nVorta Version: " + __version__ - details += "\nLog:\n" + exception + details += exception return details @@ -41,10 +41,12 @@ def __init__(self, exception: str): super().__init__() self.setupUi(self) - self.label_2.setOpenExternalLinks(True) + self.report_to_github_label.setOpenExternalLinks(True) self.ignoreButton.clicked.connect(self.close) self.copyButton.clicked.connect(self.copy_report_to_clipboard) + self.copyButton.setIcon(get_colored_icon('copy')) + # Set crash details details = ExceptionDetails.get_exception_details(exception) self.crashDetails.setPlainText(details) From 96b370003db0adfe92a51fbcce14dfa531a91087 Mon Sep 17 00:00:00 2001 From: shivansh02 Date: Tue, 2 Apr 2024 11:47:33 +0530 Subject: [PATCH 3/5] nodename and date subseconds removed --- src/vorta/views/exception_dialog.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/vorta/views/exception_dialog.py b/src/vorta/views/exception_dialog.py index 716fe9c62..6faa1cb1b 100644 --- a/src/vorta/views/exception_dialog.py +++ b/src/vorta/views/exception_dialog.py @@ -20,19 +20,17 @@ class ExceptionDetails: def get_os_details(): uname_result = platform.uname() os_details = f"OS: {uname_result.system}\n" - os_details += f"Node Name: {uname_result.node}\n" os_details += f"Release: {uname_result.release}\n" os_details += f"Version: {uname_result.version}" return os_details @staticmethod def get_exception_details(exception): - os_details = ExceptionDetails.get_os_details() - details = os_details - details += "\nDate and Time: " + str(datetime.datetime.now()) + details = ExceptionDetails.get_os_details() + details += "\nDate and Time: " + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") details += "\nBorg Version: " + borg_compat.version details += "\nVorta Version: " + __version__ - details += exception + details += "\n" + exception return details From 2c511f45c5d67b93c306c7917fdc04114b67c6dc Mon Sep 17 00:00:00 2001 From: shivansh02 Date: Tue, 2 Apr 2024 11:49:11 +0530 Subject: [PATCH 4/5] clipboard clear removed --- src/vorta/views/exception_dialog.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vorta/views/exception_dialog.py b/src/vorta/views/exception_dialog.py index 6faa1cb1b..0908580b1 100644 --- a/src/vorta/views/exception_dialog.py +++ b/src/vorta/views/exception_dialog.py @@ -54,5 +54,4 @@ def __init__(self, exception: str): def copy_report_to_clipboard(self): cb = QApplication.clipboard() - cb.clear(mode=cb.Mode.Clipboard) cb.setText(self.crashDetails.toPlainText(), mode=cb.Mode.Clipboard) From df196d83b24adc2b91da7296e49ad93ab19b2ba8 Mon Sep 17 00:00:00 2001 From: shivansh02 Date: Fri, 10 May 2024 18:36:56 +0530 Subject: [PATCH 5/5] exclamation svg replaced --- src/vorta/assets/icons/alert.svg | 129 ------------------ .../assets/icons/exclamation-triangle.svg | 4 + src/vorta/views/exception_dialog.py | 2 +- 3 files changed, 5 insertions(+), 130 deletions(-) delete mode 100644 src/vorta/assets/icons/alert.svg create mode 100644 src/vorta/assets/icons/exclamation-triangle.svg diff --git a/src/vorta/assets/icons/alert.svg b/src/vorta/assets/icons/alert.svg deleted file mode 100644 index 557cbcac0..000000000 --- a/src/vorta/assets/icons/alert.svg +++ /dev/null @@ -1,129 +0,0 @@ - - - Warning sign - - - - Warning sign - - - - - caution - security - warning - signs_and_symbols - sign - - - - - Thomas Weller - - - - - Thomas Weller - - - - - Thomas Weller - - - - image/svg+xml - - - en - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/vorta/assets/icons/exclamation-triangle.svg b/src/vorta/assets/icons/exclamation-triangle.svg new file mode 100644 index 000000000..05a0af08e --- /dev/null +++ b/src/vorta/assets/icons/exclamation-triangle.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/vorta/views/exception_dialog.py b/src/vorta/views/exception_dialog.py index 0908580b1..91f2da40d 100644 --- a/src/vorta/views/exception_dialog.py +++ b/src/vorta/views/exception_dialog.py @@ -50,7 +50,7 @@ def __init__(self, exception: str): self.crashDetails.setPlainText(details) # Set alert image - self.alertImage.setPixmap(get_colored_icon('alert', scaled_height=70, return_qpixmap=True)) + self.alertImage.setPixmap(get_colored_icon('exclamation-triangle', scaled_height=75, return_qpixmap=True)) def copy_report_to_clipboard(self): cb = QApplication.clipboard()