diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/applets/qt_web_browser.cpp | 13 | ||||
| -rw-r--r-- | src/yuzu/applets/qt_web_browser.h | 3 | ||||
| -rw-r--r-- | src/yuzu/applets/qt_web_browser_scripts.h | 6 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp index b112dd7b0..cc1a42f74 100644 --- a/src/yuzu/applets/qt_web_browser.cpp +++ b/src/yuzu/applets/qt_web_browser.cpp | |||
| @@ -107,6 +107,7 @@ void QtNXWebEngineView::LoadLocalWebPage(const std::string& main_url, | |||
| 107 | is_local = true; | 107 | is_local = true; |
| 108 | 108 | ||
| 109 | LoadExtractedFonts(); | 109 | LoadExtractedFonts(); |
| 110 | FocusFirstLinkElement(); | ||
| 110 | SetUserAgent(UserAgent::WebApplet); | 111 | SetUserAgent(UserAgent::WebApplet); |
| 111 | SetFinished(false); | 112 | SetFinished(false); |
| 112 | SetExitReason(Service::AM::Applets::WebExitReason::EndButtonPressed); | 113 | SetExitReason(Service::AM::Applets::WebExitReason::EndButtonPressed); |
| @@ -121,6 +122,7 @@ void QtNXWebEngineView::LoadExternalWebPage(const std::string& main_url, | |||
| 121 | const std::string& additional_args) { | 122 | const std::string& additional_args) { |
| 122 | is_local = false; | 123 | is_local = false; |
| 123 | 124 | ||
| 125 | FocusFirstLinkElement(); | ||
| 124 | SetUserAgent(UserAgent::WebApplet); | 126 | SetUserAgent(UserAgent::WebApplet); |
| 125 | SetFinished(false); | 127 | SetFinished(false); |
| 126 | SetExitReason(Service::AM::Applets::WebExitReason::EndButtonPressed); | 128 | SetExitReason(Service::AM::Applets::WebExitReason::EndButtonPressed); |
| @@ -364,6 +366,17 @@ void QtNXWebEngineView::LoadExtractedFonts() { | |||
| 364 | Qt::QueuedConnection); | 366 | Qt::QueuedConnection); |
| 365 | } | 367 | } |
| 366 | 368 | ||
| 369 | void QtNXWebEngineView::FocusFirstLinkElement() { | ||
| 370 | QWebEngineScript focus_link_element; | ||
| 371 | |||
| 372 | focus_link_element.setName(QStringLiteral("focus_link_element.js")); | ||
| 373 | focus_link_element.setSourceCode(QString::fromStdString(FOCUS_LINK_ELEMENT_SCRIPT)); | ||
| 374 | focus_link_element.setWorldId(QWebEngineScript::MainWorld); | ||
| 375 | focus_link_element.setInjectionPoint(QWebEngineScript::Deferred); | ||
| 376 | focus_link_element.setRunsOnSubFrames(true); | ||
| 377 | default_profile->scripts()->insert(focus_link_element); | ||
| 378 | } | ||
| 379 | |||
| 367 | #endif | 380 | #endif |
| 368 | 381 | ||
| 369 | QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { | 382 | QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { |
diff --git a/src/yuzu/applets/qt_web_browser.h b/src/yuzu/applets/qt_web_browser.h index 7ad07409f..7e9f703fc 100644 --- a/src/yuzu/applets/qt_web_browser.h +++ b/src/yuzu/applets/qt_web_browser.h | |||
| @@ -161,6 +161,9 @@ private: | |||
| 161 | /// Loads the extracted fonts using JavaScript. | 161 | /// Loads the extracted fonts using JavaScript. |
| 162 | void LoadExtractedFonts(); | 162 | void LoadExtractedFonts(); |
| 163 | 163 | ||
| 164 | /// Brings focus to the first available link element. | ||
| 165 | void FocusFirstLinkElement(); | ||
| 166 | |||
| 164 | InputCommon::InputSubsystem* input_subsystem; | 167 | InputCommon::InputSubsystem* input_subsystem; |
| 165 | 168 | ||
| 166 | std::unique_ptr<UrlRequestInterceptor> url_interceptor; | 169 | std::unique_ptr<UrlRequestInterceptor> url_interceptor; |
diff --git a/src/yuzu/applets/qt_web_browser_scripts.h b/src/yuzu/applets/qt_web_browser_scripts.h index 992837a85..c4ba8d40f 100644 --- a/src/yuzu/applets/qt_web_browser_scripts.h +++ b/src/yuzu/applets/qt_web_browser_scripts.h | |||
| @@ -73,6 +73,12 @@ constexpr char LOAD_NX_FONT[] = R"( | |||
| 73 | })(); | 73 | })(); |
| 74 | )"; | 74 | )"; |
| 75 | 75 | ||
| 76 | constexpr char FOCUS_LINK_ELEMENT_SCRIPT[] = R"( | ||
| 77 | if (document.getElementsByTagName("a").length > 0) { | ||
| 78 | document.getElementsByTagName("a")[0].focus(); | ||
| 79 | } | ||
| 80 | )"; | ||
| 81 | |||
| 76 | constexpr char GAMEPAD_SCRIPT[] = R"( | 82 | constexpr char GAMEPAD_SCRIPT[] = R"( |
| 77 | window.addEventListener("gamepadconnected", function(e) { | 83 | window.addEventListener("gamepadconnected", function(e) { |
| 78 | console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.", | 84 | console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.", |