mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Add support for HTML FullScreen
Esc is used to leave fullscreen
This commit is contained in:
parent
637f38684d
commit
949faa5856
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -1077,6 +1077,13 @@ void WebView::_keyPressEvent(QKeyEvent *event)
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_Escape:
|
||||
if (isFullScreen()) {
|
||||
triggerPageAction(QWebEnginePage::ExitFullScreen);
|
||||
event->accept();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user