diff options
author | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-03-09 14:04:52 +0100 |
---|---|---|
committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-03-09 14:04:52 +0100 |
commit | 8b345977a0ca8e784470d312e117a19e991b13d3 (patch) | |
tree | 58c65729513c64654a3e941f33974b74d4382012 | |
parent | 5fc905f98dec5ef8ef9c5a4eb97cbc0b5c0543a2 (diff) |
webview: add fullscreen functionality
-rw-r--r-- | src/webwindow.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/webwindow.cpp b/src/webwindow.cpp index 5f69b09..0449bc9 100644 --- a/src/webwindow.cpp +++ b/src/webwindow.cpp @@ -1,5 +1,6 @@ #include <QtGui/QCloseEvent> #include <QtGui/QDesktopServices> +#include <QtWebEngineCore/QWebEngineFullScreenRequest> #include <QtWebEngineCore/QWebEngineCookieStore> #include <QtWebEngineCore/QWebEngineNewWindowRequest> #include <QtWidgets/QApplication> @@ -38,6 +39,7 @@ WebWindow::web_configure() this->page.settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, false); + this->page.settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); this->profile.setPushServiceEnabled(true); @@ -52,6 +54,15 @@ WebWindow::web_configure() [=](QWebEngineNewWindowRequest &request) { QDesktopServices::openUrl(request.requestedUrl()); }); + + this->page.connect(&this->page, &QWebEnginePage::fullScreenRequested, [=](QWebEngineFullScreenRequest request) { + request.accept(); + if (request.toggleOn()) { + this->showFullScreen(); + } else { + this->showNormal(); + } + }); } void |