forked from quickshell/quickshell
crash: add crash reporter
This commit is contained in:
parent
5040f3796c
commit
fe1d15e8f6
23 changed files with 1118 additions and 315 deletions
97
src/crash/interface.cpp
Normal file
97
src/crash/interface.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
#include "interface.hpp"
|
||||
#include <utility>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qboxlayout.h>
|
||||
#include <qdesktopservices.h>
|
||||
#include <qfont.h>
|
||||
#include <qfontinfo.h>
|
||||
#include <qlabel.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobject.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qwidget.h>
|
||||
|
||||
#include "build.hpp"
|
||||
|
||||
class ReportLabel: public QWidget {
|
||||
public:
|
||||
ReportLabel(const QString& label, const QString& content, QWidget* parent): QWidget(parent) {
|
||||
auto* layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(new QLabel(label, this));
|
||||
|
||||
auto* cl = new QLabel(content, this);
|
||||
cl->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
layout->addWidget(cl);
|
||||
|
||||
layout->addStretch();
|
||||
}
|
||||
};
|
||||
|
||||
CrashReporterGui::CrashReporterGui(QString reportFolder, int pid)
|
||||
: reportFolder(std::move(reportFolder)) {
|
||||
this->setWindowFlags(Qt::Window);
|
||||
|
||||
auto textHeight = QFontInfo(QFont()).pixelSize();
|
||||
|
||||
auto* mainLayout = new QVBoxLayout(this);
|
||||
|
||||
mainLayout->addWidget(new QLabel(
|
||||
"<u>Quickshell has crashed. Please submit a bug report to help us fix it.</u>",
|
||||
this
|
||||
));
|
||||
|
||||
mainLayout->addSpacing(textHeight);
|
||||
|
||||
mainLayout->addWidget(new QLabel("General information", this));
|
||||
mainLayout->addWidget(new ReportLabel("Git Revision:", GIT_REVISION, this));
|
||||
mainLayout->addWidget(new ReportLabel("Crashed process ID:", QString::number(pid), this));
|
||||
mainLayout->addWidget(new ReportLabel("Crash report folder:", this->reportFolder, this));
|
||||
mainLayout->addSpacing(textHeight);
|
||||
|
||||
mainLayout->addWidget(new QLabel("Please open a bug report for this issue via github or email."));
|
||||
|
||||
mainLayout->addWidget(new ReportLabel(
|
||||
"Github:",
|
||||
"https://github.com/outfoxxed/quickshell/issues/new?template=crash.yml",
|
||||
this
|
||||
));
|
||||
|
||||
mainLayout->addWidget(new ReportLabel("Email:", "quickshell-bugs@outfoxxed.me", this));
|
||||
|
||||
auto* buttons = new QWidget(this);
|
||||
buttons->setMinimumWidth(900);
|
||||
auto* buttonLayout = new QHBoxLayout(buttons);
|
||||
buttonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
auto* reportButton = new QPushButton("Open report page", buttons);
|
||||
reportButton->setDefault(true);
|
||||
QObject::connect(reportButton, &QPushButton::clicked, this, &CrashReporterGui::openReportUrl);
|
||||
buttonLayout->addWidget(reportButton);
|
||||
|
||||
auto* openFolderButton = new QPushButton("Open crash folder", buttons);
|
||||
QObject::connect(openFolderButton, &QPushButton::clicked, this, &CrashReporterGui::openFolder);
|
||||
buttonLayout->addWidget(openFolderButton);
|
||||
|
||||
auto* cancelButton = new QPushButton("Exit", buttons);
|
||||
QObject::connect(cancelButton, &QPushButton::clicked, this, &CrashReporterGui::cancel);
|
||||
buttonLayout->addWidget(cancelButton);
|
||||
|
||||
mainLayout->addWidget(buttons);
|
||||
|
||||
mainLayout->addStretch();
|
||||
this->setFixedSize(this->sizeHint());
|
||||
}
|
||||
|
||||
void CrashReporterGui::openFolder() {
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(this->reportFolder));
|
||||
}
|
||||
|
||||
void CrashReporterGui::openReportUrl() {
|
||||
QDesktopServices::openUrl(
|
||||
QUrl("https://github.com/outfoxxed/quickshell/issues/new?template=crash.yml")
|
||||
);
|
||||
}
|
||||
|
||||
void CrashReporterGui::cancel() { QApplication::quit(); }
|
Loading…
Add table
Add a link
Reference in a new issue