diff options
| -rw-r--r-- | src/yuzu/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/yuzu/applets/error.cpp | 59 | ||||
| -rw-r--r-- | src/yuzu/applets/error.h | 33 |
3 files changed, 94 insertions, 0 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 31b65c04c..5138bd9a3 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt | |||
| @@ -7,6 +7,8 @@ add_executable(yuzu | |||
| 7 | Info.plist | 7 | Info.plist |
| 8 | about_dialog.cpp | 8 | about_dialog.cpp |
| 9 | about_dialog.h | 9 | about_dialog.h |
| 10 | applets/error.cpp | ||
| 11 | applets/error.h | ||
| 10 | applets/profile_select.cpp | 12 | applets/profile_select.cpp |
| 11 | applets/profile_select.h | 13 | applets/profile_select.h |
| 12 | applets/software_keyboard.cpp | 14 | applets/software_keyboard.cpp |
diff --git a/src/yuzu/applets/error.cpp b/src/yuzu/applets/error.cpp new file mode 100644 index 000000000..f7535e768 --- /dev/null +++ b/src/yuzu/applets/error.cpp | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <QDateTime> | ||
| 6 | #include "core/hle/lock.h" | ||
| 7 | #include "yuzu/applets/error.h" | ||
| 8 | #include "yuzu/main.h" | ||
| 9 | |||
| 10 | QtErrorDisplay::QtErrorDisplay(GMainWindow& parent) { | ||
| 11 | connect(this, &QtErrorDisplay::MainWindowDisplayError, &parent, | ||
| 12 | &GMainWindow::ErrorDisplayDisplayError, Qt::QueuedConnection); | ||
| 13 | connect(&parent, &GMainWindow::ErrorDisplayFinished, this, | ||
| 14 | &QtErrorDisplay::MainWindowFinishedError, Qt::DirectConnection); | ||
| 15 | } | ||
| 16 | |||
| 17 | QtErrorDisplay::~QtErrorDisplay() = default; | ||
| 18 | |||
| 19 | void QtErrorDisplay::ShowError(ResultCode error, std::function<void()> finished) const { | ||
| 20 | this->callback = finished; | ||
| 21 | emit MainWindowDisplayError( | ||
| 22 | tr("An error has occured.\nPlease try again or contact the developer of the " | ||
| 23 | "software.\n\nError Code: %1-%2 (0x%3)") | ||
| 24 | .arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0')) | ||
| 25 | .arg(error.description, 4, 10, QChar::fromLatin1('0')) | ||
| 26 | .arg(error.raw, 8, 16, QChar::fromLatin1('0'))); | ||
| 27 | } | ||
| 28 | |||
| 29 | void QtErrorDisplay::ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time, | ||
| 30 | std::function<void()> finished) const { | ||
| 31 | this->callback = finished; | ||
| 32 | emit MainWindowDisplayError( | ||
| 33 | tr("An error occured on %1 at %2.\nPlease try again or contact the " | ||
| 34 | "developer of the software.\n\nError Code: %3-%4 (0x%5)") | ||
| 35 | .arg(QDateTime::fromSecsSinceEpoch(time.count()).toString("dddd, MMMM d, yyyy")) | ||
| 36 | .arg(QDateTime::fromSecsSinceEpoch(time.count()).toString("h:mm:ss A")) | ||
| 37 | .arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0')) | ||
| 38 | .arg(error.description, 4, 10, QChar::fromLatin1('0')) | ||
| 39 | .arg(error.raw, 8, 16, QChar::fromLatin1('0'))); | ||
| 40 | } | ||
| 41 | |||
| 42 | void QtErrorDisplay::ShowCustomErrorText(ResultCode error, std::string dialog_text, | ||
| 43 | std::string fullscreen_text, | ||
| 44 | std::function<void()> finished) const { | ||
| 45 | this->callback = finished; | ||
| 46 | emit MainWindowDisplayError( | ||
| 47 | tr("An error has occured.\nError Code: %1-%2 (0x%3)\n\n%4\n\n%5") | ||
| 48 | .arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0')) | ||
| 49 | .arg(error.description, 4, 10, QChar::fromLatin1('0')) | ||
| 50 | .arg(error.raw, 8, 16, QChar::fromLatin1('0')) | ||
| 51 | .arg(QString::fromStdString(dialog_text)) | ||
| 52 | .arg(QString::fromStdString(fullscreen_text))); | ||
| 53 | } | ||
| 54 | |||
| 55 | void QtErrorDisplay::MainWindowFinishedError() { | ||
| 56 | // Acquire the HLE mutex | ||
| 57 | std::lock_guard<std::recursive_mutex> lock(HLE::g_hle_lock); | ||
| 58 | callback(); | ||
| 59 | } | ||
diff --git a/src/yuzu/applets/error.h b/src/yuzu/applets/error.h new file mode 100644 index 000000000..b0932d895 --- /dev/null +++ b/src/yuzu/applets/error.h | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <QObject> | ||
| 8 | |||
| 9 | #include "core/frontend/applets/error.h" | ||
| 10 | |||
| 11 | class GMainWindow; | ||
| 12 | |||
| 13 | class QtErrorDisplay final : public QObject, public Core::Frontend::ErrorApplet { | ||
| 14 | Q_OBJECT | ||
| 15 | |||
| 16 | public: | ||
| 17 | explicit QtErrorDisplay(GMainWindow& parent); | ||
| 18 | ~QtErrorDisplay() override; | ||
| 19 | |||
| 20 | void ShowError(ResultCode error, std::function<void()> finished) const override; | ||
| 21 | void ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time, | ||
| 22 | std::function<void()> finished) const override; | ||
| 23 | void ShowCustomErrorText(ResultCode error, std::string dialog_text, std::string fullscreen_text, | ||
| 24 | std::function<void()> finished) const override; | ||
| 25 | |||
| 26 | signals: | ||
| 27 | void MainWindowDisplayError(QString error) const; | ||
| 28 | |||
| 29 | private: | ||
| 30 | void MainWindowFinishedError(); | ||
| 31 | |||
| 32 | mutable std::function<void()> callback; | ||
| 33 | }; | ||