dcs_liberation/qt_ui/windows/BugReportDialog.py
Dan Albert 306971230b Update to PySide6.
It sounds like PySide2 will not be moving to Python 3.11, so we're stuck
on 3.10 without this. Upgrading to a newer Qt also fixes some high DPI
bugs (the file browser dialog for save/load is no longer tiny on 4k).

https://github.com/pyinstaller/pyinstaller/issues/5414 previously
blocked this, but the bug appears to be fixed now.
2022-12-29 16:26:50 -08:00

59 lines
2.1 KiB
Python

import webbrowser
from PySide6.QtCore import Qt
from PySide6.QtGui import QGuiApplication
from PySide6.QtWidgets import QDialog, QLabel, QPushButton, QVBoxLayout, QWidget
from game.version import BUILD_NUMBER, GIT_SHA, VERSION_NUMBER
class BugReportDialog(QDialog):
def __init__(self, parent: QWidget) -> None:
super().__init__(parent)
self.setWindowTitle("Report an issue")
self.setModal(True)
self.setMaximumWidth(600)
layout = QVBoxLayout()
self.setLayout(layout)
components = [f"DCS Liberation {VERSION_NUMBER}"]
if BUILD_NUMBER is not None:
components.append(f"Build {BUILD_NUMBER}")
if GIT_SHA is not None:
components.append(f"Git revision {GIT_SHA}")
self.report_data = "\n".join(components)
label = QLabel(
"Use the button below to file a bug. The version information will be "
"automatically copied to your clipboard. Paste that information into the "
"box in the bug template that asks for the version.<br />"
"<br />"
"<strong>Look for duplicate bugs before filing.</strong><br />"
"<br />"
"<strong>If the template asks for a save game, it is required. No matter "
"how easily reproducible the bug may appear, it rarely is. If it were "
"obvious you wouldn't be the first to find it.</strong><br />"
"<br />"
f"{'<br />'.join(components)}<br />"
)
label.setTextInteractionFlags(
Qt.TextSelectableByMouse
| Qt.LinksAccessibleByMouse
| Qt.LinksAccessibleByKeyboard
)
label.setWordWrap(True)
label.setOpenExternalLinks(True)
layout.addWidget(label)
copy_button = QPushButton("Copy details to clipboard and go to bug page")
copy_button.clicked.connect(self.on_file_bug)
layout.addWidget(copy_button)
def on_file_bug(self) -> None:
QGuiApplication.clipboard().setText(self.report_data)
webbrowser.open_new_tab(
"https://github.com/dcs-liberation/dcs_liberation/issues/new/choose"
)