summaryrefslogtreecommitdiff
path: root/src/yuzu/applets/qt_error.cpp
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2021-07-14 00:29:12 -0400
committerMorph <39850852+Morph1984@users.noreply.github.com>2021-07-14 01:07:09 -0400
commit9a48f252ae7b4471286a7d8899a0c70dff354b1a (patch)
treedfa4adf6aaaf460f7822188b5fc96dbe89f91e09 /src/yuzu/applets/qt_error.cpp
parentf2599534f8e096053bf7e8887ce729400a346e92 (diff)
applets: Append qt_ prefix to Qt frontend applets
Diffstat (limited to 'src/yuzu/applets/qt_error.cpp')
-rw-r--r--src/yuzu/applets/qt_error.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/yuzu/applets/qt_error.cpp b/src/yuzu/applets/qt_error.cpp
new file mode 100644
index 000000000..45cf64603
--- /dev/null
+++ b/src/yuzu/applets/qt_error.cpp
@@ -0,0 +1,63 @@
+// Copyright 2019 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <QDateTime>
+#include "core/hle/lock.h"
+#include "yuzu/applets/qt_error.h"
+#include "yuzu/main.h"
+
+QtErrorDisplay::QtErrorDisplay(GMainWindow& parent) {
+ connect(this, &QtErrorDisplay::MainWindowDisplayError, &parent,
+ &GMainWindow::ErrorDisplayDisplayError, Qt::QueuedConnection);
+ connect(&parent, &GMainWindow::ErrorDisplayFinished, this,
+ &QtErrorDisplay::MainWindowFinishedError, Qt::DirectConnection);
+}
+
+QtErrorDisplay::~QtErrorDisplay() = default;
+
+void QtErrorDisplay::ShowError(ResultCode error, std::function<void()> finished) const {
+ callback = std::move(finished);
+ emit MainWindowDisplayError(
+ tr("Error Code: %1-%2 (0x%3)")
+ .arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0'))
+ .arg(error.description, 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(ResultCode error, std::chrono::seconds time,
+ std::function<void()> 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.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0'))
+ .arg(error.description, 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(ResultCode error, std::string dialog_text,
+ std::string fullscreen_text,
+ std::function<void()> finished) const {
+ callback = std::move(finished);
+ emit MainWindowDisplayError(
+ tr("Error Code: %1-%2 (0x%3)")
+ .arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0'))
+ .arg(error.description, 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() {
+ // Acquire the HLE mutex
+ std::lock_guard lock{HLE::g_hle_lock};
+ callback();
+}