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

Improved showing navigation in fullscreen.

It will now hide navigation toolbar after 1 second instead
of hiding it instantly when on mouse leave.
This commit is contained in:
nowrep 2013-02-09 15:44:17 +01:00
parent 8a6beac501
commit 945b40f2a5
8 changed files with 62 additions and 39 deletions

View File

@ -752,6 +752,7 @@ void MainApplication::saveSettings()
qIconProvider->saveIconsToDatabase(); qIconProvider->saveIconsToDatabase();
clearTempPath(); clearTempPath();
qzSettings->saveSettings();
AdBlockManager::instance()->save(); AdBlockManager::instance()->save();
QFile::remove(currentProfilePath() + "WebpageIcons.db"); QFile::remove(currentProfilePath() + "WebpageIcons.db");
Settings::syncSettings(); Settings::syncSettings();

View File

@ -138,8 +138,14 @@ QupZilla::QupZilla(Qz::BrowserWindow type, QUrl startUrl)
setupUi(); setupUi();
setupMenu(); setupMenu();
QTimer::singleShot(0, this, SLOT(postLaunch())); m_hideNavigationTimer = new QTimer(this);
m_hideNavigationTimer->setInterval(1000);
m_hideNavigationTimer->setSingleShot(true);
connect(m_hideNavigationTimer, SIGNAL(timeout()), this, SLOT(hideNavigationSlot()));
connect(mApp, SIGNAL(message(Qz::AppMessageType, bool)), this, SLOT(receiveMessage(Qz::AppMessageType, bool))); connect(mApp, SIGNAL(message(Qz::AppMessageType, bool)), this, SLOT(receiveMessage(Qz::AppMessageType, bool)));
QTimer::singleShot(0, this, SLOT(postLaunch()));
} }
void QupZilla::postLaunch() void QupZilla::postLaunch()
@ -1689,24 +1695,36 @@ void QupZilla::openLocation()
locationBar()->selectAll(); locationBar()->selectAll();
} }
void QupZilla::showNavigationWithFullscreen() bool QupZilla::fullScreenNavigationVisible() const
{ {
bool state; return m_navigationContainer->isVisible();
if (m_navigationVisible) { }
state = !m_navigationBar->isVisible();
} void QupZilla::showNavigationWithFullScreen()
else { {
state = !m_tabWidget->getTabBar()->isVisible(); if (m_hideNavigationTimer->isActive()) {
m_hideNavigationTimer->stop();
} }
if (m_navigationVisible) { m_navigationContainer->show();
m_navigationBar->setVisible(state); m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(true);
}
void QupZilla::hideNavigationWithFullScreen()
{
if (!m_hideNavigationTimer->isActive()) {
m_hideNavigationTimer->start();
} }
}
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(state); void QupZilla::hideNavigationSlot()
{
TabbedWebView* view = weView();
bool mouseInView = view && view->geometry().contains(view->mapFromGlobal(QCursor::pos()));
if (m_bookmarksToolBarVisible) { if (isFullScreen() && mouseInView) {
m_bookmarksToolbar->setVisible(state); m_navigationContainer->hide();
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(false);
} }
} }
@ -1715,15 +1733,13 @@ void QupZilla::fullScreen(bool make)
if (make) { if (make) {
m_menuBarVisible = menuBar()->isVisible(); m_menuBarVisible = menuBar()->isVisible();
m_statusBarVisible = statusBar()->isVisible(); m_statusBarVisible = statusBar()->isVisible();
m_navigationVisible = m_navigationBar->isVisible();
m_bookmarksToolBarVisible = m_bookmarksToolbar->isVisible();
setWindowState(windowState() | Qt::WindowFullScreen); setWindowState(windowState() | Qt::WindowFullScreen);
menuBar()->hide(); menuBar()->hide();
statusBar()->hide(); statusBar()->hide();
bookmarksToolbar()->hide(); bookmarksToolbar()->hide();
m_navigationBar->hide(); m_navigationContainer->hide();
m_tabWidget->getTabBar()->hide(); m_tabWidget->getTabBar()->hide();
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
m_navigationBar->buttonSuperMenu()->hide(); m_navigationBar->buttonSuperMenu()->hide();
@ -1741,8 +1757,7 @@ void QupZilla::fullScreen(bool make)
menuBar()->setVisible(m_menuBarVisible); menuBar()->setVisible(m_menuBarVisible);
statusBar()->setVisible(m_statusBarVisible); statusBar()->setVisible(m_statusBarVisible);
m_bookmarksToolbar->setVisible(m_bookmarksToolBarVisible); m_navigationContainer->show();
m_navigationBar->setVisible(m_navigationVisible);
m_tabWidget->showTabBar(); m_tabWidget->showTabBar();
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
m_navigationBar->buttonSuperMenu()->setVisible(!m_menuBarVisible); m_navigationBar->buttonSuperMenu()->setVisible(!m_menuBarVisible);
@ -1755,6 +1770,7 @@ void QupZilla::fullScreen(bool make)
#endif #endif
} }
m_hideNavigationTimer->stop();
m_actionShowFullScreen->setChecked(make); m_actionShowFullScreen->setChecked(make);
m_navigationBar->buttonExitFullscreen()->setVisible(make); m_navigationBar->buttonExitFullscreen()->setVisible(make);

View File

@ -29,6 +29,7 @@ class QLabel;
class QVBoxLayout; class QVBoxLayout;
class QSplitter; class QSplitter;
class QWebFrame; class QWebFrame;
class QTimer;
class Menu; class Menu;
class TabWidget; class TabWidget;
@ -66,9 +67,12 @@ public:
~QupZilla(); ~QupZilla();
void loadSettings(); void loadSettings();
void showNavigationWithFullscreen();
void saveSideBarWidth(); void saveSideBarWidth();
bool fullScreenNavigationVisible() const;
void showNavigationWithFullScreen();
void hideNavigationWithFullScreen();
void currentTabChanged(); void currentTabChanged();
void updateLoadingActions(); void updateLoadingActions();
@ -203,6 +207,8 @@ private slots:
void restoreClosedTab(QObject* obj = 0); void restoreClosedTab(QObject* obj = 0);
void restoreAllClosedTabs(); void restoreAllClosedTabs();
void clearClosedTabsList(); void clearClosedTabsList();
void hideNavigationSlot();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
void applyBlurToMainWindow(bool force = false); void applyBlurToMainWindow(bool force = false);
#endif #endif
@ -318,12 +324,10 @@ private:
bool m_useTabNumberShortcuts; bool m_useTabNumberShortcuts;
bool m_useSpeedDialNumberShortcuts; bool m_useSpeedDialNumberShortcuts;
// Used for F11 FullScreen remember visibility // Used for F11 FullScreen remember visibility of menubar and statusbar
// of menubar and statusbar
bool m_menuBarVisible; bool m_menuBarVisible;
bool m_statusBarVisible; bool m_statusBarVisible;
bool m_navigationVisible; QTimer* m_hideNavigationTimer;
bool m_bookmarksToolBarVisible;
QList<QPointer<QWidget> > m_deleteOnCloseWidgets; QList<QPointer<QWidget> > m_deleteOnCloseWidgets;
}; };

View File

@ -55,7 +55,7 @@ void QzSettings::loadSettings()
settings.beginGroup("Browser-Tabs-Settings"); settings.beginGroup("Browser-Tabs-Settings");
newTabPosition = settings.value("OpenNewTabsSelected", false).toBool() ? Qz::NT_SelectedTab : Qz::NT_NotSelectedTab; newTabPosition = settings.value("OpenNewTabsSelected", false).toBool() ? Qz::NT_SelectedTab : Qz::NT_NotSelectedTab;
tabsOnTop = settings.value("TabsOnTop", true).toBool(); tabsOnTop = settings.value("TabsOnTop", false).toBool();
settings.endGroup(); settings.endGroup();
} }

View File

@ -87,14 +87,18 @@ void TabBar::loadSettings()
void TabBar::updateVisibilityWithFullscreen(bool visible) void TabBar::updateVisibilityWithFullscreen(bool visible)
{ {
// It is needed to save original geometry, otherwise
// tabbar will get 3px height in fullscreen once it was hidden
QTabBar::setVisible(visible);
if (visible) { if (visible) {
setGeometry(m_originalGeometry);
emit showButtons(); emit showButtons();
} }
else { else {
m_originalGeometry = geometry();
emit hideButtons(); emit hideButtons();
} }
QTabBar::setVisible(visible);
} }
void TabBar::setVisible(bool visible) void TabBar::setVisible(bool visible)
@ -107,6 +111,7 @@ void TabBar::setVisible(bool visible)
emit showButtons(); emit showButtons();
} }
else { else {
m_originalGeometry = geometry();
emit hideButtons(); emit hideButtons();
} }
@ -534,7 +539,7 @@ void TabBar::mouseMoveEvent(QMouseEvent* event)
} }
} }
//Tab Preview // Tab Preview
const int tab = tabAt(event->pos()); const int tab = tabAt(event->pos());
@ -587,7 +592,8 @@ bool TabBar::event(QEvent* event)
case QEvent::ToolTip: case QEvent::ToolTip:
if (m_showTabPreviews) { if (m_showTabPreviews) {
if (!m_tabPreview->isVisible()) { QHelpEvent* ev = static_cast<QHelpEvent*>(event);
if (tabAt(ev->pos()) != -1 && !m_tabPreview->isVisible()) {
showTabPreview(); showTabPreview();
} }
return true; return true;

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* QupZilla - WebKit based browser * QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,6 +19,7 @@
#define TABBAR_H #define TABBAR_H
#include <QTabBar> #include <QTabBar>
#include <QRect>
#include <QAbstractButton> #include <QAbstractButton>
#include "qz_namespace.h" #include "qz_namespace.h"
@ -111,6 +112,7 @@ private:
mutable int m_normalTabWidth; mutable int m_normalTabWidth;
mutable int m_activeTabWidth; mutable int m_activeTabWidth;
QRect m_originalGeometry;
QPoint m_dragStartPosition; QPoint m_dragStartPosition;
}; };

View File

@ -37,8 +37,6 @@
#include <QWebFrame> #include <QWebFrame>
#include <QContextMenuEvent> #include <QContextMenuEvent>
bool TabbedWebView::m_navigationVisible = false;
TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab) TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab)
: WebView(webTab) : WebView(webTab)
, p_QupZilla(mainClass) , p_QupZilla(mainClass)
@ -314,13 +312,11 @@ void TabbedWebView::getFocus(const QUrl &urla)
void TabbedWebView::mouseMoveEvent(QMouseEvent* event) void TabbedWebView::mouseMoveEvent(QMouseEvent* event)
{ {
if (m_mouseTrack) { if (m_mouseTrack) {
if (m_navigationVisible) { if (p_QupZilla->fullScreenNavigationVisible()) {
m_navigationVisible = false; p_QupZilla->hideNavigationWithFullScreen();
p_QupZilla->showNavigationWithFullscreen();
} }
else if (event->y() < 5) { else if (event->y() < 5) {
m_navigationVisible = true; p_QupZilla->showNavigationWithFullScreen();
p_QupZilla->showNavigationWithFullscreen();
} }
} }

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* QupZilla - WebKit based browser * QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -98,8 +98,6 @@ private:
Menu* m_menu; Menu* m_menu;
bool m_mouseTrack; bool m_mouseTrack;
static bool m_navigationVisible;
bool m_hasRss; bool m_hasRss;
bool m_rssChecked; bool m_rssChecked;