mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 22:57:22 +00:00
web_browser: Make OpenPage non-const
This commit is contained in:
parent
8f8049e846
commit
2adb226b26
13 changed files with 30 additions and 25 deletions
|
@ -13,7 +13,7 @@ DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default;
|
||||||
|
|
||||||
void DefaultWebBrowserApplet::OpenPage(std::string_view filename,
|
void DefaultWebBrowserApplet::OpenPage(std::string_view filename,
|
||||||
std::function<void()> unpack_romfs_callback,
|
std::function<void()> unpack_romfs_callback,
|
||||||
std::function<void()> finished_callback) const {
|
std::function<void()> finished_callback) {
|
||||||
LOG_INFO(Service_AM,
|
LOG_INFO(Service_AM,
|
||||||
"(STUBBED) called - No suitable web browser implementation found to open website page "
|
"(STUBBED) called - No suitable web browser implementation found to open website page "
|
||||||
"at '{}'!",
|
"at '{}'!",
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
virtual ~WebBrowserApplet();
|
virtual ~WebBrowserApplet();
|
||||||
|
|
||||||
virtual void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
|
virtual void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
|
||||||
std::function<void()> finished_callback) const = 0;
|
std::function<void()> finished_callback) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultWebBrowserApplet final : public WebBrowserApplet {
|
class DefaultWebBrowserApplet final : public WebBrowserApplet {
|
||||||
|
@ -22,7 +22,7 @@ public:
|
||||||
~DefaultWebBrowserApplet() override;
|
~DefaultWebBrowserApplet() override;
|
||||||
|
|
||||||
void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
|
void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
|
||||||
std::function<void()> finished_callback) const override;
|
std::function<void()> finished_callback) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core::Frontend
|
} // namespace Core::Frontend
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <cstring>
|
||||||
|
#include "common/assert.h"
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/frontend/applets/error.h"
|
#include "core/frontend/applets/error.h"
|
||||||
|
@ -54,7 +58,7 @@ struct ApplicationErrorArg {
|
||||||
};
|
};
|
||||||
static_assert(sizeof(ApplicationErrorArg) == 0x1014, "ApplicationErrorArg has incorrect size.");
|
static_assert(sizeof(ApplicationErrorArg) == 0x1014, "ApplicationErrorArg has incorrect size.");
|
||||||
|
|
||||||
union ErrorArguments {
|
union Error::ErrorArguments {
|
||||||
ShowError error;
|
ShowError error;
|
||||||
ShowErrorRecord error_record;
|
ShowErrorRecord error_record;
|
||||||
SystemErrorArg system_error;
|
SystemErrorArg system_error;
|
||||||
|
@ -107,6 +111,7 @@ void Error::Initialize() {
|
||||||
case ErrorAppletMode::ShowSystemError:
|
case ErrorAppletMode::ShowSystemError:
|
||||||
CopyArgumentData(data, args->system_error);
|
CopyArgumentData(data, args->system_error);
|
||||||
error_code = ResultCode(Decode64BitError(args->system_error.error_code_64));
|
error_code = ResultCode(Decode64BitError(args->system_error.error_code_64));
|
||||||
|
break;
|
||||||
case ErrorAppletMode::ShowApplicationError:
|
case ErrorAppletMode::ShowApplicationError:
|
||||||
CopyArgumentData(data, args->application_error);
|
CopyArgumentData(data, args->application_error);
|
||||||
error_code = ResultCode(args->application_error.error_code);
|
error_code = ResultCode(args->application_error.error_code);
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
namespace Service::AM::Applets {
|
namespace Service::AM::Applets {
|
||||||
|
|
||||||
union ErrorArguments;
|
|
||||||
|
|
||||||
enum class ErrorAppletMode : u8 {
|
enum class ErrorAppletMode : u8 {
|
||||||
ShowError = 0,
|
ShowError = 0,
|
||||||
ShowSystemError = 1,
|
ShowSystemError = 1,
|
||||||
|
@ -23,7 +21,7 @@ enum class ErrorAppletMode : u8 {
|
||||||
|
|
||||||
class Error final : public Applet {
|
class Error final : public Applet {
|
||||||
public:
|
public:
|
||||||
Error(const Core::Frontend::ErrorApplet& frontend);
|
explicit Error(const Core::Frontend::ErrorApplet& frontend);
|
||||||
~Error() override;
|
~Error() override;
|
||||||
|
|
||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
|
@ -36,12 +34,14 @@ public:
|
||||||
void DisplayCompleted();
|
void DisplayCompleted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
union ErrorArguments;
|
||||||
|
|
||||||
const Core::Frontend::ErrorApplet& frontend;
|
const Core::Frontend::ErrorApplet& frontend;
|
||||||
ResultCode error_code = RESULT_SUCCESS;
|
ResultCode error_code = RESULT_SUCCESS;
|
||||||
ErrorAppletMode mode;
|
ErrorAppletMode mode = ErrorAppletMode::ShowError;
|
||||||
std::unique_ptr<ErrorArguments> args;
|
std::unique_ptr<ErrorArguments> args;
|
||||||
|
|
||||||
bool complete;
|
bool complete = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::AM::Applets
|
} // namespace Service::AM::Applets
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "common/assert.h"
|
||||||
#include "common/hex_util.h"
|
#include "common/hex_util.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
|
|
@ -15,7 +15,7 @@ enum class PhotoViewerAppletMode : u8 {
|
||||||
|
|
||||||
class PhotoViewer final : public Applet {
|
class PhotoViewer final : public Applet {
|
||||||
public:
|
public:
|
||||||
PhotoViewer(const Core::Frontend::PhotoViewerApplet& frontend);
|
explicit PhotoViewer(const Core::Frontend::PhotoViewerApplet& frontend);
|
||||||
~PhotoViewer() override;
|
~PhotoViewer() override;
|
||||||
|
|
||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
|
@ -28,8 +28,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Core::Frontend::PhotoViewerApplet& frontend;
|
const Core::Frontend::PhotoViewerApplet& frontend;
|
||||||
bool complete;
|
bool complete = false;
|
||||||
PhotoViewerAppletMode mode;
|
PhotoViewerAppletMode mode = PhotoViewerAppletMode::CurrentApp;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StubApplet final : public Applet {
|
class StubApplet final : public Applet {
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "core/frontend/applets/software_keyboard.h"
|
|
||||||
#include "core/hle/service/acc/profile_manager.h"
|
#include "core/hle/service/acc/profile_manager.h"
|
||||||
#include "core/hle/service/am/applets/applets.h"
|
#include "core/hle/service/am/applets/applets.h"
|
||||||
|
|
||||||
|
@ -29,7 +28,7 @@ static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has inco
|
||||||
|
|
||||||
class ProfileSelect final : public Applet {
|
class ProfileSelect final : public Applet {
|
||||||
public:
|
public:
|
||||||
ProfileSelect(const Core::Frontend::ProfileSelectApplet& frontend);
|
explicit ProfileSelect(const Core::Frontend::ProfileSelectApplet& frontend);
|
||||||
~ProfileSelect() override;
|
~ProfileSelect() override;
|
||||||
|
|
||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
|
|
|
@ -55,7 +55,7 @@ static_assert(sizeof(KeyboardConfig) == 0x3E0, "KeyboardConfig has incorrect siz
|
||||||
|
|
||||||
class SoftwareKeyboard final : public Applet {
|
class SoftwareKeyboard final : public Applet {
|
||||||
public:
|
public:
|
||||||
SoftwareKeyboard(const Core::Frontend::SoftwareKeyboardApplet& frontend);
|
explicit SoftwareKeyboard(const Core::Frontend::SoftwareKeyboardApplet& frontend);
|
||||||
~SoftwareKeyboard() override;
|
~SoftwareKeyboard() override;
|
||||||
|
|
||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
|
|
|
@ -95,7 +95,7 @@ static FileSys::VirtualFile GetManualRomFS() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebBrowser::WebBrowser(const Core::Frontend::WebBrowserApplet& frontend) : frontend(frontend) {}
|
WebBrowser::WebBrowser(Core::Frontend::WebBrowserApplet& frontend) : frontend(frontend) {}
|
||||||
|
|
||||||
WebBrowser::~WebBrowser() = default;
|
WebBrowser::~WebBrowser() = default;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Service::AM::Applets {
|
||||||
|
|
||||||
class WebBrowser final : public Applet {
|
class WebBrowser final : public Applet {
|
||||||
public:
|
public:
|
||||||
WebBrowser(const Core::Frontend::WebBrowserApplet& frontend);
|
WebBrowser(Core::Frontend::WebBrowserApplet& frontend);
|
||||||
~WebBrowser() override;
|
~WebBrowser() override;
|
||||||
|
|
||||||
void Initialize() override;
|
void Initialize() override;
|
||||||
|
@ -32,7 +32,7 @@ public:
|
||||||
void Finalize();
|
void Finalize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Core::Frontend::WebBrowserApplet& frontend;
|
Core::Frontend::WebBrowserApplet& frontend;
|
||||||
|
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
bool unpacked = false;
|
bool unpacked = false;
|
||||||
|
|
|
@ -17,7 +17,7 @@ QtErrorDisplay::QtErrorDisplay(GMainWindow& parent) {
|
||||||
QtErrorDisplay::~QtErrorDisplay() = default;
|
QtErrorDisplay::~QtErrorDisplay() = default;
|
||||||
|
|
||||||
void QtErrorDisplay::ShowError(ResultCode error, std::function<void()> finished) const {
|
void QtErrorDisplay::ShowError(ResultCode error, std::function<void()> finished) const {
|
||||||
this->callback = finished;
|
this->callback = std::move(finished);
|
||||||
emit MainWindowDisplayError(
|
emit MainWindowDisplayError(
|
||||||
tr("An error has occured.\nPlease try again or contact the developer of the "
|
tr("An error has occured.\nPlease try again or contact the developer of the "
|
||||||
"software.\n\nError Code: %1-%2 (0x%3)")
|
"software.\n\nError Code: %1-%2 (0x%3)")
|
||||||
|
@ -28,7 +28,7 @@ void QtErrorDisplay::ShowError(ResultCode error, std::function<void()> finished)
|
||||||
|
|
||||||
void QtErrorDisplay::ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time,
|
void QtErrorDisplay::ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time,
|
||||||
std::function<void()> finished) const {
|
std::function<void()> finished) const {
|
||||||
this->callback = finished;
|
this->callback = std::move(finished);
|
||||||
emit MainWindowDisplayError(
|
emit MainWindowDisplayError(
|
||||||
tr("An error occured on %1 at %2.\nPlease try again or contact the "
|
tr("An error occured on %1 at %2.\nPlease try again or contact the "
|
||||||
"developer of the software.\n\nError Code: %3-%4 (0x%5)")
|
"developer of the software.\n\nError Code: %3-%4 (0x%5)")
|
||||||
|
@ -42,7 +42,7 @@ void QtErrorDisplay::ShowErrorWithTimestamp(ResultCode error, std::chrono::secon
|
||||||
void QtErrorDisplay::ShowCustomErrorText(ResultCode error, std::string dialog_text,
|
void QtErrorDisplay::ShowCustomErrorText(ResultCode error, std::string dialog_text,
|
||||||
std::string fullscreen_text,
|
std::string fullscreen_text,
|
||||||
std::function<void()> finished) const {
|
std::function<void()> finished) const {
|
||||||
this->callback = finished;
|
this->callback = std::move(finished);
|
||||||
emit MainWindowDisplayError(
|
emit MainWindowDisplayError(
|
||||||
tr("An error has occured.\nError Code: %1-%2 (0x%3)\n\n%4\n\n%5")
|
tr("An error has occured.\nError Code: %1-%2 (0x%3)\n\n%4\n\n%5")
|
||||||
.arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0'))
|
.arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0'))
|
||||||
|
|
|
@ -88,7 +88,7 @@ QtWebBrowser::QtWebBrowser(GMainWindow& main_window) {
|
||||||
QtWebBrowser::~QtWebBrowser() = default;
|
QtWebBrowser::~QtWebBrowser() = default;
|
||||||
|
|
||||||
void QtWebBrowser::OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
|
void QtWebBrowser::OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
|
||||||
std::function<void()> finished_callback) const {
|
std::function<void()> finished_callback) {
|
||||||
this->unpack_romfs_callback = std::move(unpack_romfs_callback);
|
this->unpack_romfs_callback = std::move(unpack_romfs_callback);
|
||||||
this->finished_callback = std::move(finished_callback);
|
this->finished_callback = std::move(finished_callback);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
~QtWebBrowser() override;
|
~QtWebBrowser() override;
|
||||||
|
|
||||||
void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
|
void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
|
||||||
std::function<void()> finished_callback) const override;
|
std::function<void()> finished_callback) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MainWindowOpenPage(std::string_view filename, std::string_view additional_args) const;
|
void MainWindowOpenPage(std::string_view filename, std::string_view additional_args) const;
|
||||||
|
@ -47,6 +47,6 @@ private:
|
||||||
void MainWindowUnpackRomFS();
|
void MainWindowUnpackRomFS();
|
||||||
void MainWindowFinishedBrowsing();
|
void MainWindowFinishedBrowsing();
|
||||||
|
|
||||||
mutable std::function<void()> unpack_romfs_callback;
|
std::function<void()> unpack_romfs_callback;
|
||||||
mutable std::function<void()> finished_callback;
|
std::function<void()> finished_callback;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue