1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Go to fullscreen in QWindoStateChangeEvent.

It is now possible to go properly to fullscreen also from Window
Manager's actions/shortcuts.
This commit is contained in:
nowrep 2013-02-17 11:05:35 +01:00
parent e718e00e5c
commit 91c88872f8
4 changed files with 85 additions and 55 deletions

View File

@ -439,7 +439,7 @@ void QupZilla::setupMenu()
#else #else
m_actionShowFullScreen->setShortcut(QKeySequence("Ctrl+F11")); m_actionShowFullScreen->setShortcut(QKeySequence("Ctrl+F11"));
#endif #endif
connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(fullScreen(bool))); connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(toggleFullScreen(bool)));
m_actionStop = new QAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), MENU_RECEIVER); m_actionStop = new QAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), MENU_RECEIVER);
connect(m_actionStop, SIGNAL(triggered()), MENU_RECEIVER, SLOT(stop())); connect(m_actionStop, SIGNAL(triggered()), MENU_RECEIVER, SLOT(stop()));
m_actionStop->setShortcut(QKeySequence("Esc")); m_actionStop->setShortcut(QKeySequence("Esc"));
@ -1743,55 +1743,75 @@ void QupZilla::hideNavigationSlot()
} }
} }
void QupZilla::fullScreen(bool make) bool QupZilla::event(QEvent* event)
{
switch (event->type()) {
case QEvent::WindowStateChange: {
QWindowStateChangeEvent* ev = static_cast<QWindowStateChangeEvent*>(event);
if (!(ev->oldState() & Qt::WindowFullScreen) && windowState() & Qt::WindowFullScreen) {
// Enter fullscreen
m_windowStates = ev->oldState();
m_menuBarVisible = menuBar()->isVisible();
m_statusBarVisible = statusBar()->isVisible();
menuBar()->hide();
statusBar()->hide();
bookmarksToolbar()->hide();
m_navigationContainer->hide();
m_tabWidget->getTabBar()->hide();
#ifndef Q_OS_MAC
m_navigationBar->buttonSuperMenu()->hide();
#endif
m_hideNavigationTimer->stop();
m_actionShowFullScreen->setChecked(true);
m_navigationBar->buttonExitFullscreen()->setVisible(true);
emit setWebViewMouseTracking(true);
#ifdef Q_OS_WIN
if (m_usingTransparentBackground) {
QtWin::extendFrameIntoClientArea(this, 0, 0, 0 , 0);
QtWin::enableBlurBehindWindow(this, false);
}
#endif
}
else if (ev->oldState() & Qt::WindowFullScreen && !(windowState() & Qt::WindowFullScreen)) {
// Leave fullscreen
setWindowState(m_windowStates);
menuBar()->setVisible(m_menuBarVisible);
statusBar()->setVisible(m_statusBarVisible);
m_navigationContainer->show();
m_tabWidget->showTabBar();
#ifndef Q_OS_MAC
m_navigationBar->buttonSuperMenu()->setVisible(!m_menuBarVisible);
#endif
m_hideNavigationTimer->stop();
m_actionShowFullScreen->setChecked(false);
m_navigationBar->buttonExitFullscreen()->setVisible(false);
emit setWebViewMouseTracking(false);
#ifdef Q_OS_WIN
if (m_usingTransparentBackground) {
applyBlurToMainWindow(true);
}
#endif
}
}
default:
break;
}
return QMainWindow::event(event);
}
void QupZilla::toggleFullScreen(bool make)
{ {
if (make) { if (make) {
m_menuBarVisible = menuBar()->isVisible();
m_statusBarVisible = statusBar()->isVisible();
m_windowStates = windowState();
showFullScreen(); showFullScreen();
menuBar()->hide();
statusBar()->hide();
bookmarksToolbar()->hide();
m_navigationContainer->hide();
m_tabWidget->getTabBar()->hide();
#ifndef Q_OS_MAC
m_navigationBar->buttonSuperMenu()->hide();
#endif
#ifdef Q_OS_WIN
if (m_usingTransparentBackground) {
QtWin::extendFrameIntoClientArea(this, 0, 0, 0 , 0);
QtWin::enableBlurBehindWindow(this, false);
}
#endif
} }
else { else {
showNormal(); showNormal();
setWindowState(m_windowStates);
menuBar()->setVisible(m_menuBarVisible);
statusBar()->setVisible(m_statusBarVisible);
m_navigationContainer->show();
m_tabWidget->showTabBar();
#ifndef Q_OS_MAC
m_navigationBar->buttonSuperMenu()->setVisible(!m_menuBarVisible);
#endif
#ifdef Q_OS_WIN
if (m_usingTransparentBackground) {
applyBlurToMainWindow(true);
}
#endif
} }
m_hideNavigationTimer->stop();
m_actionShowFullScreen->setChecked(make);
m_navigationBar->buttonExitFullscreen()->setVisible(make);
emit setWebViewMouseTracking(make);
} }
void QupZilla::savePage() void QupZilla::savePage()
@ -1841,26 +1861,35 @@ void QupZilla::keyPressEvent(QKeyEvent* event)
} }
int number = -1; int number = -1;
TabbedWebView* view = weView();
switch (event->key()) { switch (event->key()) {
case Qt::Key_Back: case Qt::Key_Back:
weView()->back(); if (view) {
event->accept(); weView()->back();
event->accept();
}
break; break;
case Qt::Key_Forward: case Qt::Key_Forward:
weView()->forward(); if (view) {
event->accept(); weView()->forward();
event->accept();
}
break; break;
case Qt::Key_Stop: case Qt::Key_Stop:
weView()->stop(); if (view) {
event->accept(); weView()->stop();
event->accept();
}
break; break;
case Qt::Key_Refresh: case Qt::Key_Refresh:
weView()->reload(); if (view) {
event->accept(); weView()->reload();
event->accept();
}
break; break;
case Qt::Key_HomePage: case Qt::Key_HomePage:
@ -1933,7 +1962,7 @@ void QupZilla::keyPressEvent(QKeyEvent* event)
break; break;
case Qt::Key_Equal: case Qt::Key_Equal:
if (event->modifiers() == Qt::ControlModifier) { if (view && event->modifiers() == Qt::ControlModifier) {
weView()->zoomIn(); weView()->zoomIn();
event->accept(); event->accept();
} }

View File

@ -196,7 +196,7 @@ private slots:
void zoomIn(); void zoomIn();
void zoomOut(); void zoomOut();
void zoomReset(); void zoomReset();
void fullScreen(bool make); void toggleFullScreen(bool make);
void changeEncoding(QObject* obj = 0); void changeEncoding(QObject* obj = 0);
void triggerCaretBrowsing(); void triggerCaretBrowsing();
@ -215,6 +215,7 @@ private slots:
#endif #endif
private: private:
bool event(QEvent* event);
void resizeEvent(QResizeEvent* event); void resizeEvent(QResizeEvent* event);
void keyPressEvent(QKeyEvent* event); void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event); void keyReleaseEvent(QKeyEvent* event);

View File

@ -165,7 +165,7 @@ NavigationBar::NavigationBar(QupZilla* mainClass)
connect(m_buttonHome, SIGNAL(middleMouseClicked()), p_QupZilla, SLOT(goHomeInNewTab())); connect(m_buttonHome, SIGNAL(middleMouseClicked()), p_QupZilla, SLOT(goHomeInNewTab()));
connect(m_buttonHome, SIGNAL(controlClicked()), p_QupZilla, SLOT(goHomeInNewTab())); connect(m_buttonHome, SIGNAL(controlClicked()), p_QupZilla, SLOT(goHomeInNewTab()));
connect(m_buttonAddTab, SIGNAL(clicked()), p_QupZilla, SLOT(addTab())); connect(m_buttonAddTab, SIGNAL(clicked()), p_QupZilla, SLOT(addTab()));
connect(m_exitFullscreen, SIGNAL(clicked(bool)), p_QupZilla, SLOT(fullScreen(bool))); connect(m_exitFullscreen, SIGNAL(clicked(bool)), p_QupZilla, SLOT(toggleFullScreen(bool)));
} }
void NavigationBar::setSplitterSizes(int locationBar, int websearchBar) void NavigationBar::setSplitterSizes(int locationBar, int websearchBar)

View File

@ -101,7 +101,7 @@ void AddTabButton::dropEvent(QDropEvent* event)
TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent)
: QTabWidget(parent) : QTabWidget(parent)
, p_QupZilla(mainClass) , p_QupZilla(mainClass)
, m_lastTabIndex(0) , m_lastTabIndex(-1)
, m_lastBackgroundTabIndex(-1) , m_lastBackgroundTabIndex(-1)
, m_isClosingToLastTabIndex(false) , m_isClosingToLastTabIndex(false)
, m_isRestoringState(false) , m_isRestoringState(false)