#include "widgets/dialogs/LastRunCrashDialog.hpp" #include "common/Args.hpp" #include "common/Literals.hpp" #include "common/Modes.hpp" #include "singletons/Paths.hpp" #include "util/LayoutCreator.hpp" #include #include #include #include #include #include #include #include #include #include namespace { using namespace chatterino::literals; const std::initializer_list MESSAGES = { u"Oops..."_s, u"NotLikeThis"_s, u"NOOOOOO"_s, u"I'm sorry"_s, u"We're sorry"_s, u"My bad"_s, u"FailFish"_s, u"O_o"_s, u"Sorry :("_s, u"I blame cosmic rays"_s, u"I blame TMI"_s, u"I blame Helix"_s, u"Oopsie woopsie"_s, }; QString randomMessage() { return *(MESSAGES.begin() + (QRandomGenerator::global()->generate64() % MESSAGES.size())); } } // namespace namespace chatterino { using namespace literals; LastRunCrashDialog::LastRunCrashDialog(const Args &args) { this->setWindowFlag(Qt::WindowContextHelpButtonHint, false); this->setWindowTitle(u"Chatterino - " % randomMessage()); auto layout = LayoutCreator(this).setLayoutType(); QString text = u"Chatterino unexpectedly crashed and restarted. "_s "You can disable automatic restarts in the settings.

"; #ifdef CHATTERINO_WITH_CRASHPAD auto reportsDir = QDir(getPaths()->crashdumpDirectory).filePath(u"reports"_s); text += u"A crash report has been saved to " "" % reportsDir % u".
"; if (args.exceptionCode) { text += u"The last run crashed with code 0x" % QString::number(*args.exceptionCode, 16) % u""; if (args.exceptionMessage) { text += u" (" % *args.exceptionMessage % u")"; } text += u".
"_s; } text += "Crash reports are only stored locally and never uploaded.
" "
Please report " "the crash " u"so it can be prevented in the future."_s; if (Modes::instance().isNightly) { text += u" Make sure you're using the latest nightly version!"_s; } text += u"
For more information, consult the wiki."_s; #endif auto label = layout.emplace(text); label->setTextInteractionFlags(Qt::TextBrowserInteraction); label->setOpenExternalLinks(true); label->setWordWrap(true); layout->addSpacing(16); auto buttons = layout.emplace(); auto *okButton = buttons->addButton(u"Ok"_s, QDialogButtonBox::AcceptRole); QObject::connect(okButton, &QPushButton::clicked, [this] { this->accept(); }); } } // namespace chatterino