-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Exception Dialog. By @shivansh02 (#1977)
- Loading branch information
1 parent
6b440ba
commit 513e8e2
Showing
4 changed files
with
240 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Dialog</class> | ||
<widget class="QDialog" name="Dialog"> | ||
<property name="windowModality"> | ||
<enum>Qt::NonModal</enum> | ||
</property> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>674</width> | ||
<height>296</height> | ||
</rect> | ||
</property> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>0</width> | ||
<height>0</height> | ||
</size> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Fatal Error</string> | ||
</property> | ||
<property name="modal"> | ||
<bool>true</bool> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<property name="leftMargin"> | ||
<number>10</number> | ||
</property> | ||
<property name="topMargin"> | ||
<number>10</number> | ||
</property> | ||
<property name="rightMargin"> | ||
<number>10</number> | ||
</property> | ||
<property name="bottomMargin"> | ||
<number>10</number> | ||
</property> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,7"> | ||
<property name="spacing"> | ||
<number>0</number> | ||
</property> | ||
<item> | ||
<widget class="QLabel" name="alertImage"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer name="horizontalSpacer_2"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeType"> | ||
<enum>QSizePolicy::Fixed</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>10</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<layout class="QVBoxLayout" name="verticalLayout_3"> | ||
<property name="spacing"> | ||
<number>0</number> | ||
</property> | ||
<property name="topMargin"> | ||
<number>0</number> | ||
</property> | ||
<item> | ||
<widget class="QLabel" name="title_label"> | ||
<property name="font"> | ||
<font> | ||
<bold>true</bold> | ||
</font> | ||
</property> | ||
<property name="text"> | ||
<string>Vorta quit unexpectedly. </string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="report_to_github_label"> | ||
<property name="text"> | ||
<string><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></string> | ||
</property> | ||
<property name="wordWrap"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<spacer name="verticalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeType"> | ||
<enum>QSizePolicy::Fixed</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>5</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="report_label"> | ||
<property name="text"> | ||
<string>Crash Report:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPlainTextEdit" name="crashDetails"> | ||
<property name="readOnly"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
<item> | ||
<spacer name="horizontalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>40</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<widget class="QDialogButtonBox" name="ignoreButton"> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Close</set> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="copyButton"> | ||
<property name="text"> | ||
<string>Copy to Clipboard</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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"Release: {uname_result.release}\n" | ||
os_details += f"Version: {uname_result.version}" | ||
return os_details | ||
|
||
@staticmethod | ||
def get_exception_details(exception): | ||
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 += "\n" + exception | ||
return details | ||
|
||
|
||
class ExceptionDialog(ExceptionDialogBase, ExceptionDialogUI): | ||
def __init__(self, exception: str): | ||
super().__init__() | ||
self.setupUi(self) | ||
|
||
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) | ||
|
||
# Set alert image | ||
self.alertImage.setPixmap(get_colored_icon('exclamation-triangle', scaled_height=75, return_qpixmap=True)) | ||
|
||
def copy_report_to_clipboard(self): | ||
cb = QApplication.clipboard() | ||
cb.setText(self.crashDetails.toPlainText(), mode=cb.Mode.Clipboard) |