1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Showing/hiding navigation toolbars while fullscreen is active

This commit is contained in:
nowrep 2011-04-22 07:45:15 +02:00
parent db5791c3d2
commit ee47f976eb
5 changed files with 58 additions and 9 deletions

View File

@ -451,6 +451,9 @@ bool MainApplication::saveStateSlot()
stream << m_mainWindows.count();
for (int i = 0; i < m_mainWindows.count(); i++) {
stream << m_mainWindows.at(i)->tabWidget()->saveState();
if (m_mainWindows.at(i)->isFullScreen())
stream << QByteArray();
else
stream << m_mainWindows.at(i)->saveState();
}
file.close();
@ -517,8 +520,6 @@ bool MainApplication::restoreStateSlot(QupZilla* window)
stream >> tabState;
stream >> qMainWindowState;
qDebug() << "restoring another window" << tabState.size();
QupZilla* window = new QupZilla(false);
m_mainWindows.append(window);
connect(window, SIGNAL(message(MainApplication::MessageType,bool)), this, SLOT(sendMessages(MainApplication::MessageType,bool)));

View File

@ -688,23 +688,43 @@ void QupZilla::openFile()
loadAddress(QUrl(filePath));
}
void QupZilla::showNavigationWithFullscreen()
{
bool state;
if (m_navigationVisible)
state = !m_navigation->isVisible();
else
state = !m_tabWidget->getTabBar()->isVisible();
if (m_navigationVisible)
m_navigation->setVisible(state);
m_tabWidget->getTabBar()->setVisible(state);
if (m_bookmarksToolBarVisible)
m_bookmarksToolbar->setVisible(state);
}
void QupZilla::fullScreen(bool make)
{
if (make) {
m_menuBarVisible = menuBar()->isVisible();
m_statusBarVisible = statusBar()->isVisible();
m_navigationVisible = m_navigation->isVisible();
m_bookmarksToolBarVisible = m_bookmarksToolbar->isVisible();
setWindowState(windowState() | Qt::WindowFullScreen);
menuBar()->hide();
statusBar()->hide();
}else{
bookmarksToolbar()->hide();
m_navigation->hide();
} else {
setWindowState(windowState() & ~Qt::WindowFullScreen);
if (m_menuBarVisible)
showMenubar();
if (m_statusBarVisible)
showStatusbar();
menuBar()->setVisible(m_menuBarVisible);
statusBar()->setVisible(m_statusBarVisible);
m_bookmarksToolbar->setVisible(m_bookmarksToolBarVisible);
m_navigation->setVisible(m_navigationVisible);
}
m_actionShowFullScreen->setChecked(make);
m_actionExitFullscreen->setVisible(make);
m_tabWidget->getTabBar()->setVisible(!make);
emit setWebViewMouseTracking(make);
}
void QupZilla::savePage()

View File

@ -93,6 +93,7 @@ public:
void loadSettings();
void showInspector();
void setBackground(QColor textColor);
void showNavigationWithFullscreen();
inline WebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); }
inline WebView* weView(int index) const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); if (!webTab) return 0; return webTab->view(); }
@ -115,6 +116,7 @@ signals:
void loadHistory();
void startingCompleted();
void message(MainApplication::MessageType mes, bool state);
void setWebViewMouseTracking(bool state);
public slots:
void showBookmarksToolbar();
@ -127,7 +129,6 @@ public slots:
void receiveMessage(MainApplication::MessageType mes, bool state);
private slots:
void closeEvent(QCloseEvent* event);
void postLaunch();
void goAtHistoryIndex();
void goNext() { weView()->forward(); }
@ -187,6 +188,8 @@ private slots:
bool quitApp();
private:
void closeEvent(QCloseEvent* event);
void setupUi();
void setupMenu();
@ -250,6 +253,8 @@ private:
//of menubar and statusbar
bool m_menuBarVisible;
bool m_statusBarVisible;
bool m_navigationVisible;
bool m_bookmarksToolBarVisible;
};
#endif // QUPZILLA_H

View File

@ -41,6 +41,8 @@ WebView::WebView(QupZilla* mainClass, QWidget* parent)
,m_lastUrl(QUrl())
,m_wantsClose(false)
,m_page(new WebPage(this, p_QupZilla))
,m_mouseTrack(false)
,m_navigationVisible(false)
//,m_loadingTimer(0)
{
m_networkProxy = new NetworkManagerProxy(p_QupZilla);
@ -70,6 +72,8 @@ WebView::WebView(QupZilla* mainClass, QWidget* parent)
connect(mApp->networkManager(), SIGNAL(finishLoading(bool)), this, SLOT(loadFinished(bool)));
connect(mApp->networkManager(), SIGNAL(wantsFocus(QUrl)), this, SLOT(getFocus(QUrl)));
connect(p_QupZilla, SIGNAL(setWebViewMouseTracking(bool)), this, SLOT(trackMouse(bool)));
//Zoom levels same as in firefox
m_zoomLevels << 30 << 50 << 67 << 80 << 90 << 100 << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300;
}
@ -398,6 +402,20 @@ void WebView::keyPressEvent(QKeyEvent* event)
}
}
void WebView::mouseMoveEvent(QMouseEvent *event)
{
if (m_mouseTrack) {
if (m_navigationVisible) {
m_navigationVisible = false;
p_QupZilla->showNavigationWithFullscreen();
} else if (event->y() < 5) {
m_navigationVisible = true;
p_QupZilla->showNavigationWithFullscreen();
}
}
QWebView::mouseMoveEvent(event);
}
void WebView::contextMenuEvent(QContextMenuEvent* event)
{
QMenu* menu = new QMenu(this);

View File

@ -74,6 +74,7 @@ public slots:
void zoomOut();
private slots:
void trackMouse(bool state) { m_mouseTrack = state; }
void showImage();
void copyImageToClipboard();
void downloadImageToDisk();
@ -108,6 +109,7 @@ private:
void mouseReleaseEvent(QMouseEvent* event);
void contextMenuEvent(QContextMenuEvent* event);
void wheelEvent(QWheelEvent* event);
void mouseMoveEvent(QMouseEvent* event);
TabWidget* tabWidget() const;
bool isCurrent();
void applyZoom();
@ -127,6 +129,9 @@ private:
WebPage* m_page;
NetworkManagerProxy* m_networkProxy;
bool m_mouseTrack;
bool m_navigationVisible;
//QTimer* m_loadingTimer; //Too confusing
signals: