summaryrefslogtreecommitdiff
path: root/src/citron/applets/qt_error.cpp
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.org>2024-12-31 16:19:25 +1000
committerZephyron <zephyron@citron-emu.org>2024-12-31 16:19:25 +1000
commit9427e27e24a7135880ee2881c3c44988e174b41a (patch)
tree83f0062a35be144f6b162eaa823c5b3c7620146e /src/citron/applets/qt_error.cpp
parentb35ae725d20960411e8588b11c12a2d55f86c9d0 (diff)
chore: update project branding to citron
Diffstat (limited to 'src/citron/applets/qt_error.cpp')
-rw-r--r--src/citron/applets/qt_error.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/citron/applets/qt_error.cpp b/src/citron/applets/qt_error.cpp
new file mode 100644
index 000000000..ad35f4126
--- /dev/null
+++ b/src/citron/applets/qt_error.cpp
@@ -0,0 +1,68 @@
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <QDateTime>
+#include "yuzu/applets/qt_error.h"
+#include "yuzu/main.h"
+
+QtErrorDisplay::QtErrorDisplay(GMainWindow& parent) {
+ connect(this, &QtErrorDisplay::MainWindowDisplayError, &parent,
+ &GMainWindow::ErrorDisplayDisplayError, Qt::QueuedConnection);
+ connect(this, &QtErrorDisplay::MainWindowRequestExit, &parent,
+ &GMainWindow::ErrorDisplayRequestExit, Qt::QueuedConnection);
+ connect(&parent, &GMainWindow::ErrorDisplayFinished, this,
+ &QtErrorDisplay::MainWindowFinishedError, Qt::DirectConnection);
+}
+
+QtErrorDisplay::~QtErrorDisplay() = default;
+
+void QtErrorDisplay::Close() const {
+ callback = {};
+ emit MainWindowRequestExit();
+}
+
+void QtErrorDisplay::ShowError(Result error, FinishedCallback finished) const {
+ callback = std::move(finished);
+ emit MainWindowDisplayError(
+ tr("Error Code: %1-%2 (0x%3)")
+ .arg(static_cast<u32>(error.GetModule()) + 2000, 4, 10, QChar::fromLatin1('0'))
+ .arg(error.GetDescription(), 4, 10, QChar::fromLatin1('0'))
+ .arg(error.raw, 8, 16, QChar::fromLatin1('0')),
+ tr("An error has occurred.\nPlease try again or contact the developer of the software."));
+}
+
+void QtErrorDisplay::ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
+ FinishedCallback finished) const {
+ callback = std::move(finished);
+
+ const QDateTime date_time = QDateTime::fromSecsSinceEpoch(time.count());
+ emit MainWindowDisplayError(
+ tr("Error Code: %1-%2 (0x%3)")
+ .arg(static_cast<u32>(error.GetModule()) + 2000, 4, 10, QChar::fromLatin1('0'))
+ .arg(error.GetDescription(), 4, 10, QChar::fromLatin1('0'))
+ .arg(error.raw, 8, 16, QChar::fromLatin1('0')),
+ tr("An error occurred on %1 at %2.\nPlease try again or contact the developer of the "
+ "software.")
+ .arg(date_time.toString(QStringLiteral("dddd, MMMM d, yyyy")))
+ .arg(date_time.toString(QStringLiteral("h:mm:ss A"))));
+}
+
+void QtErrorDisplay::ShowCustomErrorText(Result error, std::string dialog_text,
+ std::string fullscreen_text,
+ FinishedCallback finished) const {
+ callback = std::move(finished);
+ emit MainWindowDisplayError(
+ tr("Error Code: %1-%2 (0x%3)")
+ .arg(static_cast<u32>(error.GetModule()) + 2000, 4, 10, QChar::fromLatin1('0'))
+ .arg(error.GetDescription(), 4, 10, QChar::fromLatin1('0'))
+ .arg(error.raw, 8, 16, QChar::fromLatin1('0')),
+ tr("An error has occurred.\n\n%1\n\n%2")
+ .arg(QString::fromStdString(dialog_text))
+ .arg(QString::fromStdString(fullscreen_text)));
+}
+
+void QtErrorDisplay::MainWindowFinishedError() {
+ if (callback) {
+ callback();
+ }
+}