| | |
| | |
| |
|
| | #pragma once |
| |
|
| | #include <atomic> |
| | #include <thread> |
| |
|
| | #include <QObject> |
| |
|
| | #ifdef YUZU_USE_QT_WEB_ENGINE |
| | #include <QWebEngineView> |
| | #endif |
| |
|
| | #include "core/frontend/applets/web_browser.h" |
| |
|
| | class GMainWindow; |
| | class InputInterpreter; |
| | class UrlRequestInterceptor; |
| |
|
| | namespace Core { |
| | class System; |
| | } |
| |
|
| | namespace Core::HID { |
| | enum class NpadButton : u64; |
| | } |
| |
|
| | namespace InputCommon { |
| | class InputSubsystem; |
| | } |
| |
|
| | #ifdef YUZU_USE_QT_WEB_ENGINE |
| |
|
| | enum class UserAgent { |
| | WebApplet, |
| | ShopN, |
| | LoginApplet, |
| | ShareApplet, |
| | LobbyApplet, |
| | WifiWebAuthApplet, |
| | }; |
| |
|
| | class QWebEngineProfile; |
| | class QWebEngineSettings; |
| |
|
| | class QtNXWebEngineView : public QWebEngineView { |
| | Q_OBJECT |
| |
|
| | public: |
| | explicit QtNXWebEngineView(QWidget* parent, Core::System& system, |
| | InputCommon::InputSubsystem* input_subsystem_); |
| | ~QtNXWebEngineView() override; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | void LoadLocalWebPage(const std::string& main_url, const std::string& additional_args); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | void LoadExternalWebPage(const std::string& main_url, const std::string& additional_args); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | void SetBackgroundColor(QColor color); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | void SetUserAgent(UserAgent user_agent); |
| |
|
| | [[nodiscard]] bool IsFinished() const; |
| | void SetFinished(bool finished_); |
| |
|
| | [[nodiscard]] Service::AM::Frontend::WebExitReason GetExitReason() const; |
| | void SetExitReason(Service::AM::Frontend::WebExitReason exit_reason_); |
| |
|
| | [[nodiscard]] const std::string& GetLastURL() const; |
| | void SetLastURL(std::string last_url_); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | [[nodiscard]] QString GetCurrentURL() const; |
| |
|
| | public slots: |
| | void hide(); |
| |
|
| | protected: |
| | void keyPressEvent(QKeyEvent* event) override; |
| | void keyReleaseEvent(QKeyEvent* event) override; |
| |
|
| | private: |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | template <Core::HID::NpadButton... T> |
| | void HandleWindowFooterButtonPressedOnce(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | template <Core::HID::NpadButton... T> |
| | void HandleWindowKeyButtonPressedOnce(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | template <Core::HID::NpadButton... T> |
| | void HandleWindowKeyButtonHold(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | void SendKeyPressEvent(int key); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | template <int... T> |
| | void SendMultipleKeyPressEvents() { |
| | (SendKeyPressEvent(T), ...); |
| | } |
| |
|
| | void StartInputThread(); |
| | void StopInputThread(); |
| |
|
| | |
| | void InputThread(); |
| |
|
| | |
| | void LoadExtractedFonts(); |
| |
|
| | |
| | void FocusFirstLinkElement(); |
| |
|
| | InputCommon::InputSubsystem* input_subsystem; |
| |
|
| | std::unique_ptr<UrlRequestInterceptor> url_interceptor; |
| |
|
| | std::unique_ptr<InputInterpreter> input_interpreter; |
| |
|
| | std::thread input_thread; |
| |
|
| | std::atomic<bool> input_thread_running{}; |
| |
|
| | std::atomic<bool> finished{}; |
| |
|
| | Service::AM::Frontend::WebExitReason exit_reason{ |
| | Service::AM::Frontend::WebExitReason::EndButtonPressed}; |
| |
|
| | std::string last_url{"http://localhost/"}; |
| |
|
| | bool is_local{}; |
| |
|
| | QWebEngineProfile* default_profile; |
| | QWebEngineSettings* global_settings; |
| | }; |
| |
|
| | #endif |
| |
|
| | class QtWebBrowser final : public QObject, public Core::Frontend::WebBrowserApplet { |
| | Q_OBJECT |
| |
|
| | public: |
| | explicit QtWebBrowser(GMainWindow& parent); |
| | ~QtWebBrowser() override; |
| |
|
| | void Close() const override; |
| | void OpenLocalWebPage(const std::string& local_url, |
| | ExtractROMFSCallback extract_romfs_callback_, |
| | OpenWebPageCallback callback_) const override; |
| |
|
| | void OpenExternalWebPage(const std::string& external_url, |
| | OpenWebPageCallback callback_) const override; |
| |
|
| | signals: |
| | void MainWindowOpenWebPage(const std::string& main_url, const std::string& additional_args, |
| | bool is_local) const; |
| | void MainWindowRequestExit() const; |
| |
|
| | private: |
| | void MainWindowExtractOfflineRomFS(); |
| |
|
| | void MainWindowWebBrowserClosed(Service::AM::Frontend::WebExitReason exit_reason, |
| | std::string last_url); |
| |
|
| | mutable ExtractROMFSCallback extract_romfs_callback; |
| | mutable OpenWebPageCallback callback; |
| | }; |
| |
|