enable kind-of-fullscreen when media HTML5 element requests it

This commit is contained in:
Martin Rotter 2025-02-07 08:10:15 +01:00
parent 2e0288d3d4
commit 79a4e7c73e
3 changed files with 13 additions and 4 deletions

View file

@ -84,6 +84,7 @@ class RSSGUARD_DLLSPEC WebBrowser : public TabContent {
signals:
void windowCloseRequested();
void iconChanged(int index, const QIcon& icon);
void titleChanged(int index, const QString& title);

View file

@ -33,6 +33,8 @@ WebEngineViewer::WebEngineViewer(QWidget* parent) : QWebEngineView(parent), m_br
WebEnginePage* page = new WebEnginePage(this);
setPage(page);
connect(page, &WebEnginePage::fullScreenRequested, this, &WebEngineViewer::onFullScreenRequested);
}
bool WebEngineViewer::event(QEvent* event) {
@ -48,6 +50,10 @@ bool WebEngineViewer::event(QEvent* event) {
return QWebEngineView::event(event);
}
void WebEngineViewer::onFullScreenRequested(QWebEngineFullScreenRequest request) {
request.accept();
}
WebEnginePage* WebEngineViewer::page() const {
return qobject_cast<WebEnginePage*>(QWebEngineView::page());
}
@ -178,10 +184,10 @@ void WebEngineViewer::setVerticalScrollBarPosition(double pos) {
void WebEngineViewer::applyFont(const QFont& fon) {
auto pixel_size = QFontMetrics(fon).ascent();
qApp->web()->engineProfile()->settings()->setFontFamily(QWebEngineSettings::FontFamily::StandardFont, fon.family());
qApp->web()->engineProfile()->settings()->setFontFamily(QWebEngineSettings::FontFamily::SerifFont, fon.family());
qApp->web()->engineProfile()->settings()->setFontFamily(QWebEngineSettings::FontFamily::SansSerifFont, fon.family());
qApp->web()->engineProfile()->settings()->setFontSize(QWebEngineSettings::DefaultFontSize, pixel_size);
page()->profile()->settings()->setFontFamily(QWebEngineSettings::FontFamily::StandardFont, fon.family());
page()->profile()->settings()->setFontFamily(QWebEngineSettings::FontFamily::SerifFont, fon.family());
page()->profile()->settings()->setFontFamily(QWebEngineSettings::FontFamily::SansSerifFont, fon.family());
page()->profile()->settings()->setFontSize(QWebEngineSettings::DefaultFontSize, pixel_size);
}
qreal WebEngineViewer::zoomFactor() const {

View file

@ -8,6 +8,7 @@
#include "miscellaneous/externaltool.h"
#include "network-web/webengine/webenginepage.h"
#include <QWebEngineFullScreenRequest>
#include <QWebEngineView>
class RootItem;
@ -57,6 +58,7 @@ class RSSGUARD_DLLSPEC WebEngineViewer : public QWebEngineView, public WebViewer
virtual bool event(QEvent* event);
private slots:
void onFullScreenRequested(QWebEngineFullScreenRequest request);
void openUrlWithExternalTool(ExternalTool tool, const QString& target_url);
private: