diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index 087a8b8f5..b04aa29b0 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -114,6 +114,7 @@ BrowserWindow::BrowserWindow(Qz::BrowserWindowType type, const QUrl &startUrl) , m_startTab(0) , m_sideBarManager(new SideBarManager(this)) , m_statusBarMessage(new StatusBarMessage(this)) + , m_isHtmlFullScreen(false) , m_hideNavigationTimer(0) { setObjectName("mainwindow"); @@ -799,6 +800,12 @@ void BrowserWindow::toggleOfflineMode() qzSettings->workOffline = enable; } +void BrowserWindow::enterHtmlFullScreen() +{ + showFullScreen(); + m_isHtmlFullScreen = true; +} + void BrowserWindow::showWebInspector() { if (weView() && weView()->webTab()) { @@ -1023,6 +1030,9 @@ bool BrowserWindow::fullScreenNavigationVisible() const void BrowserWindow::showNavigationWithFullScreen() { + if (m_isHtmlFullScreen) + return; + if (m_hideNavigationTimer->isActive()) { m_hideNavigationTimer->stop(); } @@ -1080,6 +1090,7 @@ bool BrowserWindow::event(QEvent* event) m_navigationContainer->show(); m_navigationToolbar->setSuperMenuVisible(!m_menuBarVisible); m_navigationToolbar->buttonExitFullscreen()->setVisible(false); + m_isHtmlFullScreen = false; } if (m_hideNavigationTimer) { diff --git a/src/lib/app/browserwindow.h b/src/lib/app/browserwindow.h index 3c0b67bd6..764c21ec8 100644 --- a/src/lib/app/browserwindow.h +++ b/src/lib/app/browserwindow.h @@ -132,6 +132,7 @@ public slots: void toggleFullScreen(); void toggleOfflineMode(); + void enterHtmlFullScreen(); void loadActionUrl(QObject* obj = 0); void loadActionUrlInNewTab(QObject* obj = 0); @@ -210,6 +211,7 @@ private: // Remember visibility of menubar and statusbar after entering Fullscreen bool m_menuBarVisible; bool m_statusBarVisible; + bool m_isHtmlFullScreen; Qt::WindowStates m_windowStates; QTimer* m_hideNavigationTimer; diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 301c0906e..cf5059d12 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -877,6 +877,7 @@ void MainApplication::loadSettings() webSettings->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, settings.value("SpatialNavigation", false).toBool()); webSettings->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, settings.value("AnimateScrolling", true).toBool()); webSettings->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, false); + webSettings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); webSettings->setDefaultTextEncoding(settings.value("DefaultEncoding", webSettings->defaultTextEncoding()).toString()); diff --git a/src/lib/popupwindow/popupwebview.cpp b/src/lib/popupwindow/popupwebview.cpp index f84a6bfa8..733739f85 100644 --- a/src/lib/popupwindow/popupwebview.cpp +++ b/src/lib/popupwindow/popupwebview.cpp @@ -59,6 +59,19 @@ void PopupWebView::closeView() parentWidget()->close(); } +bool PopupWebView::isFullScreen() +{ + return parentWidget()->isFullScreen(); +} + +void PopupWebView::requestFullScreen(bool enable) +{ + if (enable) + parentWidget()->showFullScreen(); + else + parentWidget()->showNormal(); +} + void PopupWebView::inspectElement() { WebInspector *inspector = new WebInspector; diff --git a/src/lib/popupwindow/popupwebview.h b/src/lib/popupwindow/popupwebview.h index 43e614438..a298de49d 100644 --- a/src/lib/popupwindow/popupwebview.h +++ b/src/lib/popupwindow/popupwebview.h @@ -33,10 +33,11 @@ public: QWidget* overlayWidget() Q_DECL_OVERRIDE; void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) Q_DECL_OVERRIDE; -signals: + void closeView() Q_DECL_OVERRIDE; + bool isFullScreen() Q_DECL_OVERRIDE; + void requestFullScreen(bool enable) Q_DECL_OVERRIDE; public slots: - void closeView(); void inspectElement(); private: diff --git a/src/lib/webengine/webpage.cpp b/src/lib/webengine/webpage.cpp index 0a435239e..8d847f111 100644 --- a/src/lib/webengine/webpage.cpp +++ b/src/lib/webengine/webpage.cpp @@ -81,6 +81,7 @@ WebPage::WebPage(QObject* parent) connect(this, &QWebEnginePage::urlChanged, this, &WebPage::urlChanged); connect(this, &QWebEnginePage::featurePermissionRequested, this, &WebPage::featurePermissionRequested); connect(this, &QWebEnginePage::windowCloseRequested, this, &WebPage::windowCloseRequested); + connect(this, &QWebEnginePage::fullScreenRequested, this, &WebPage::fullScreenRequested); connect(this, &QWebEnginePage::authenticationRequired, this, [this](const QUrl &url, QAuthenticator *auth) { mApp->networkManager()->authentication(url, auth, view()); @@ -316,11 +317,21 @@ void WebPage::windowCloseRequested() view()->closeView(); } +void WebPage::fullScreenRequested(bool fullScreen) +{ + view()->requestFullScreen(fullScreen); +} + void WebPage::featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature) { mApp->html5PermissionsManager()->requestPermissions(this, origin, feature); } +bool WebPage::isFullScreen() +{ + return view()->isFullScreen(); +} + bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) { m_lastRequestUrl = url; diff --git a/src/lib/webengine/webpage.h b/src/lib/webengine/webpage.h index a855cfde4..c15d8709a 100644 --- a/src/lib/webengine/webpage.h +++ b/src/lib/webengine/webpage.h @@ -87,9 +87,11 @@ private slots: void urlChanged(const QUrl &url); void watchedFileChanged(const QString &file); void windowCloseRequested(); + void fullScreenRequested(bool fullScreen); void featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature); private: + bool isFullScreen() Q_DECL_OVERRIDE; bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) Q_DECL_OVERRIDE; bool certificateError(const QWebEngineCertificateError &error) Q_DECL_OVERRIDE; QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) Q_DECL_OVERRIDE; diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index 0871f38aa..44a729a6c 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -1077,6 +1077,13 @@ void WebView::_keyPressEvent(QKeyEvent *event) } break; + case Qt::Key_Escape: + if (isFullScreen()) { + triggerPageAction(QWebEnginePage::ExitFullScreen); + event->accept(); + } + break; + default: break; } diff --git a/src/lib/webengine/webview.h b/src/lib/webengine/webview.h index 11ab01e35..5a86f82d3 100644 --- a/src/lib/webengine/webview.h +++ b/src/lib/webengine/webview.h @@ -107,6 +107,9 @@ public slots: virtual void closeView() = 0; virtual void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) = 0; + virtual bool isFullScreen() = 0; + virtual void requestFullScreen(bool enable) = 0; + protected slots: void slotLoadStarted(); void slotLoadProgress(int progress); diff --git a/src/lib/webtab/tabbedwebview.cpp b/src/lib/webtab/tabbedwebview.cpp index 9b73f5800..a9a81eeae 100644 --- a/src/lib/webtab/tabbedwebview.cpp +++ b/src/lib/webtab/tabbedwebview.cpp @@ -174,6 +174,22 @@ void TabbedWebView::loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags } } +bool TabbedWebView::isFullScreen() +{ + return m_window && m_window->isFullScreen(); +} + +void TabbedWebView::requestFullScreen(bool enable) +{ + if (!m_window) + return; + + if (enable) + m_window->enterHtmlFullScreen(); + else + m_window->showNormal(); +} + void TabbedWebView::setAsCurrentTab() { if (m_window) { diff --git a/src/lib/webtab/tabbedwebview.h b/src/lib/webtab/tabbedwebview.h index 85d25b506..0e5c2c6b6 100644 --- a/src/lib/webtab/tabbedwebview.h +++ b/src/lib/webtab/tabbedwebview.h @@ -51,6 +51,9 @@ public: void closeView() Q_DECL_OVERRIDE; void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) Q_DECL_OVERRIDE; + bool isFullScreen() Q_DECL_OVERRIDE; + void requestFullScreen(bool enable) Q_DECL_OVERRIDE; + signals: void wantsCloseTab(int); void ipChanged(QString);