mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-11-28 06:52:47 +00:00
applets/web_browser: Use aliases for callbacks
Deduplicates a lot of long callback declarations
This commit is contained in:
parent
9bbb77637e
commit
e26c86a6e7
|
@ -10,18 +10,17 @@ WebBrowserApplet::~WebBrowserApplet() = default;
|
||||||
|
|
||||||
DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default;
|
DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default;
|
||||||
|
|
||||||
void DefaultWebBrowserApplet::OpenLocalWebPage(
|
void DefaultWebBrowserApplet::OpenLocalWebPage(const std::string& local_url,
|
||||||
const std::string& local_url, std::function<void()> extract_romfs_callback,
|
ExtractROMFSCallback extract_romfs_callback,
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const {
|
OpenWebPageCallback callback) const {
|
||||||
LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open local web page at {}",
|
LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open local web page at {}",
|
||||||
local_url);
|
local_url);
|
||||||
|
|
||||||
callback(Service::AM::Applets::WebExitReason::WindowClosed, "http://localhost/");
|
callback(Service::AM::Applets::WebExitReason::WindowClosed, "http://localhost/");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultWebBrowserApplet::OpenExternalWebPage(
|
void DefaultWebBrowserApplet::OpenExternalWebPage(const std::string& external_url,
|
||||||
const std::string& external_url,
|
OpenWebPageCallback callback) const {
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const {
|
|
||||||
LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open external web page at {}",
|
LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open external web page at {}",
|
||||||
external_url);
|
external_url);
|
||||||
|
|
||||||
|
|
|
@ -11,29 +11,29 @@ namespace Core::Frontend {
|
||||||
|
|
||||||
class WebBrowserApplet {
|
class WebBrowserApplet {
|
||||||
public:
|
public:
|
||||||
|
using ExtractROMFSCallback = std::function<void()>;
|
||||||
|
using OpenWebPageCallback =
|
||||||
|
std::function<void(Service::AM::Applets::WebExitReason, std::string)>;
|
||||||
|
|
||||||
virtual ~WebBrowserApplet();
|
virtual ~WebBrowserApplet();
|
||||||
|
|
||||||
virtual void OpenLocalWebPage(
|
virtual void OpenLocalWebPage(const std::string& local_url,
|
||||||
const std::string& local_url, std::function<void()> extract_romfs_callback,
|
ExtractROMFSCallback extract_romfs_callback,
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0;
|
OpenWebPageCallback callback) const = 0;
|
||||||
|
|
||||||
virtual void OpenExternalWebPage(
|
virtual void OpenExternalWebPage(const std::string& external_url,
|
||||||
const std::string& external_url,
|
OpenWebPageCallback callback) const = 0;
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultWebBrowserApplet final : public WebBrowserApplet {
|
class DefaultWebBrowserApplet final : public WebBrowserApplet {
|
||||||
public:
|
public:
|
||||||
~DefaultWebBrowserApplet() override;
|
~DefaultWebBrowserApplet() override;
|
||||||
|
|
||||||
void OpenLocalWebPage(const std::string& local_url,
|
void OpenLocalWebPage(const std::string& local_url, ExtractROMFSCallback extract_romfs_callback,
|
||||||
std::function<void()> extract_romfs_callback,
|
OpenWebPageCallback callback) const override;
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)>
|
|
||||||
callback) const override;
|
|
||||||
|
|
||||||
void OpenExternalWebPage(const std::string& external_url,
|
void OpenExternalWebPage(const std::string& external_url,
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)>
|
OpenWebPageCallback callback) const override;
|
||||||
callback) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core::Frontend
|
} // namespace Core::Frontend
|
||||||
|
|
|
@ -401,9 +401,9 @@ QtWebBrowser::QtWebBrowser(GMainWindow& main_window) {
|
||||||
|
|
||||||
QtWebBrowser::~QtWebBrowser() = default;
|
QtWebBrowser::~QtWebBrowser() = default;
|
||||||
|
|
||||||
void QtWebBrowser::OpenLocalWebPage(
|
void QtWebBrowser::OpenLocalWebPage(const std::string& local_url,
|
||||||
const std::string& local_url, std::function<void()> extract_romfs_callback_,
|
ExtractROMFSCallback extract_romfs_callback_,
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback_) const {
|
OpenWebPageCallback callback_) const {
|
||||||
extract_romfs_callback = std::move(extract_romfs_callback_);
|
extract_romfs_callback = std::move(extract_romfs_callback_);
|
||||||
callback = std::move(callback_);
|
callback = std::move(callback_);
|
||||||
|
|
||||||
|
@ -416,9 +416,8 @@ void QtWebBrowser::OpenLocalWebPage(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtWebBrowser::OpenExternalWebPage(
|
void QtWebBrowser::OpenExternalWebPage(const std::string& external_url,
|
||||||
const std::string& external_url,
|
OpenWebPageCallback callback_) const {
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback_) const {
|
|
||||||
callback = std::move(callback_);
|
callback = std::move(callback_);
|
||||||
|
|
||||||
const auto index = external_url.find('?');
|
const auto index = external_url.find('?');
|
||||||
|
|
|
@ -197,13 +197,11 @@ public:
|
||||||
~QtWebBrowser() override;
|
~QtWebBrowser() override;
|
||||||
|
|
||||||
void OpenLocalWebPage(const std::string& local_url,
|
void OpenLocalWebPage(const std::string& local_url,
|
||||||
std::function<void()> extract_romfs_callback_,
|
ExtractROMFSCallback extract_romfs_callback_,
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)>
|
OpenWebPageCallback callback_) const override;
|
||||||
callback_) const override;
|
|
||||||
|
|
||||||
void OpenExternalWebPage(const std::string& external_url,
|
void OpenExternalWebPage(const std::string& external_url,
|
||||||
std::function<void(Service::AM::Applets::WebExitReason, std::string)>
|
OpenWebPageCallback callback_) const override;
|
||||||
callback_) const override;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MainWindowOpenWebPage(const std::string& main_url, const std::string& additional_args,
|
void MainWindowOpenWebPage(const std::string& main_url, const std::string& additional_args,
|
||||||
|
@ -215,7 +213,6 @@ private:
|
||||||
void MainWindowWebBrowserClosed(Service::AM::Applets::WebExitReason exit_reason,
|
void MainWindowWebBrowserClosed(Service::AM::Applets::WebExitReason exit_reason,
|
||||||
std::string last_url);
|
std::string last_url);
|
||||||
|
|
||||||
mutable std::function<void()> extract_romfs_callback;
|
mutable ExtractROMFSCallback extract_romfs_callback;
|
||||||
|
mutable OpenWebPageCallback callback;
|
||||||
mutable std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback;
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue