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

Added option to show tabs on top.

You can change it in Menu View -> Toolbars

Closes #640
This commit is contained in:
nowrep 2013-02-09 13:00:45 +01:00
parent 732c1b533f
commit 83f3c90752
14 changed files with 171 additions and 49 deletions

View File

@ -5,6 +5,7 @@ Version 1.4.0
* QtWebKit 2.3 new features - caret browsing, animated scrolling
* added support for FTP listing files and downloading
* added support for saving passwords of multiple users per site
* added support for showing tabs on top
* asking user whether to allow site to use notifications/geolocation
* option to set JavaScript privacy permissions
* option to specify default search engine used in locationbar
@ -28,6 +29,7 @@ Version 1.4.0
* X11: fixed Ctrl+Q shortcut for DEs other than KDE and Gnome
* windows: improved installer allows registering as default web browser
* windows: check and set as default browser from preferences
* mac: fixed not working global menu after closing browser window
Version 1.3.5
* released 16 September 2012

View File

@ -60,6 +60,7 @@
#include "reloadstopbutton.h"
#include "enhancedmenu.h"
#include "settings.h"
#include "qzsettings.h"
#include "webtab.h"
#include "speeddial.h"
#include "qtwin.h"
@ -289,9 +290,16 @@ void QupZilla::setupUi()
m_navigationBar->setSplitterSizes(locationBarWidth, websearchBarWidth);
m_bookmarksToolbar = new BookmarksToolbar(this);
m_navigationContainer = new QWidget(this);
QVBoxLayout* l = new QVBoxLayout(m_navigationContainer);
l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0);
l->addWidget(m_navigationBar);
l->addWidget(m_bookmarksToolbar);
m_navigationContainer->setLayout(l);
m_mainSplitter->addWidget(m_tabWidget);
m_mainLayout->addWidget(m_navigationBar);
m_mainLayout->addWidget(m_bookmarksToolbar);
m_mainLayout->addWidget(m_navigationContainer);
m_mainLayout->addWidget(m_mainSplitter);
m_mainSplitter->setCollapsible(0, false);
@ -415,6 +423,9 @@ void QupZilla::setupMenu()
#else
m_menuEncoding = new QMenu(0);
#endif
m_actionTabsOnTop = new QAction(tr("&Tabs on Top"), MENU_RECEIVER);
m_actionTabsOnTop->setCheckable(true);
connect(m_actionTabsOnTop, SIGNAL(triggered(bool)), this, SLOT(triggerTabsOnTop(bool)));
m_actionShowFullScreen = new QAction(tr("&Fullscreen"), MENU_RECEIVER);
m_actionShowFullScreen->setCheckable(true);
m_actionShowFullScreen->setShortcut(QKeySequence("F11"));
@ -444,6 +455,8 @@ void QupZilla::setupMenu()
#endif
toolbarsMenu->addAction(m_actionShowToolbar);
toolbarsMenu->addAction(m_actionShowBookmarksToolbar);
toolbarsMenu->addSeparator();
toolbarsMenu->addAction(m_actionTabsOnTop);
QMenu* sidebarsMenu = new QMenu(tr("Sidebars"));
m_sideBarManager->setSideBarMenu(sidebarsMenu);
@ -791,6 +804,15 @@ LocationBar* QupZilla::locationBar() const
return qobject_cast<LocationBar*>(m_tabWidget->locationBars()->currentWidget());
}
QWidget* QupZilla::navigationContainer()
{
if (!qzSettings->tabsOnTop) {
return 0;
}
return m_navigationContainer;
}
void QupZilla::setWindowTitle(const QString &t)
{
QString title = t;
@ -1066,6 +1088,7 @@ void QupZilla::aboutToShowViewMenu()
m_actionShowStatusbar->setChecked(statusBar()->isVisible());
m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible());
m_actionTabsOnTop->setChecked(qzSettings->tabsOnTop);
m_actionPageSource->setEnabled(true);
@ -1307,7 +1330,7 @@ void QupZilla::reloadByPassCache()
weView()->triggerPageAction(QWebPage::ReloadAndBypassCache);
}
void QupZilla::loadActionUrl(QObject *obj)
void QupZilla::loadActionUrl(QObject* obj)
{
if (!obj) {
obj = sender();
@ -1526,6 +1549,18 @@ void QupZilla::showBookmarkImport()
b->show();
}
void QupZilla::triggerTabsOnTop(bool enable)
{
if (enable) {
m_tabWidget->showNavigationBar(m_navigationContainer);
}
else {
m_mainLayout->insertWidget(0, m_navigationContainer);
}
qzSettings->tabsOnTop = enable;
}
void QupZilla::refreshHistory()
{
m_navigationBar->refreshHistory();
@ -1610,10 +1645,11 @@ void QupZilla::webSearch()
void QupZilla::searchOnPage()
{
SearchToolBar* toolBar = searchToolBar();
const int searchPos = qzSettings->tabsOnTop ? 1 : 2;
if (!toolBar) {
toolBar = new SearchToolBar(weView(), this);
m_mainLayout->insertWidget(3, toolBar);
m_mainLayout->insertWidget(searchPos, toolBar);
}
toolBar->focusSearchLine();
@ -1995,9 +2031,10 @@ void QupZilla::closeEvent(QCloseEvent* event)
SearchToolBar* QupZilla::searchToolBar()
{
SearchToolBar* toolBar = 0;
const int searchPos = qzSettings->tabsOnTop ? 1 : 2;
if (m_mainLayout->count() == 4) {
toolBar = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(3)->widget());
if (m_mainLayout->count() == searchPos + 1) {
toolBar = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(searchPos)->widget());
}
return toolBar;
@ -2242,11 +2279,9 @@ bool QupZilla::nativeEvent(const QByteArray &eventType, void* _message, long* re
m_sideBar.data()->installEventFilter(this);
}
if (m_mainLayout->count() == 4) {
SearchToolBar* search = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(3)->widget());
if (search) {
search->installEventFilter(this);
}
SearchToolBar* search = searchToolBar();
if (search) {
search->installEventFilter(this);
}
if (m_webInspectorDock) {
@ -2291,11 +2326,9 @@ void QupZilla::applyBlurToMainWindow(bool force)
topMargin += m_bookmarksToolbar->isVisible() ? m_bookmarksToolbar->height() : 0;
topMargin += m_tabWidget->getTabBar()->height();
if (m_mainLayout->count() == 4) {
SearchToolBar* search = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(3)->widget());
if (search) {
bottomMargin += search->height();
}
SearchToolBar* search = searchToolBar();
if (search) {
bottomMargin += search->height();
}
bottomMargin += statusBar()->isVisible() ? statusBar()->height() : 0;

View File

@ -87,21 +87,23 @@ public:
TabbedWebView* weView(int index) const;
LocationBar* locationBar() const;
inline TabWidget* tabWidget() { return m_tabWidget; }
inline BookmarksToolbar* bookmarksToolbar() { return m_bookmarksToolbar; }
inline StatusBarMessage* statusBarMessage() { return m_statusBarMessage; }
inline NavigationBar* navigationBar() { return m_navigationBar; }
inline SideBarManager* sideBarManager() { return m_sideBarManager; }
inline ProgressBar* progressBar() { return m_progressBar; }
inline QLabel* ipLabel() { return m_ipLabel; }
inline AdBlockIcon* adBlockIcon() { return m_adblockIcon; }
inline QMenu* menuHelp() { return m_menuHelp; }
inline QAction* actionRestoreTab() { return m_actionRestoreTab; }
inline QAction* actionReload() { return m_actionReload; }
inline QMenu* superMenu() { return m_superMenu; }
TabWidget* tabWidget() { return m_tabWidget; }
BookmarksToolbar* bookmarksToolbar() { return m_bookmarksToolbar; }
StatusBarMessage* statusBarMessage() { return m_statusBarMessage; }
NavigationBar* navigationBar() { return m_navigationBar; }
SideBarManager* sideBarManager() { return m_sideBarManager; }
ProgressBar* progressBar() { return m_progressBar; }
QLabel* ipLabel() { return m_ipLabel; }
AdBlockIcon* adBlockIcon() { return m_adblockIcon; }
QMenu* menuHelp() { return m_menuHelp; }
QAction* actionRestoreTab() { return m_actionRestoreTab; }
QAction* actionReload() { return m_actionReload; }
QMenu* superMenu() { return m_superMenu; }
inline bool isClosing() { return m_isClosing; }
inline QUrl homepageUrl() { return m_homepage; }
QWidget* navigationContainer();
bool isClosing() { return m_isClosing; }
QUrl homepageUrl() { return m_homepage; }
signals:
void startingCompleted();
@ -189,9 +191,10 @@ private slots:
void zoomOut();
void zoomReset();
void fullScreen(bool make);
void changeEncoding(QObject *obj = 0);
void changeEncoding(QObject* obj = 0);
void triggerCaretBrowsing();
void triggerTabsOnTop(bool enable);
void closeWindow();
bool quitApp();
@ -275,6 +278,7 @@ private:
#ifndef Q_OS_MAC
QAction* m_actionShowMenubar;
#endif
QAction* m_actionTabsOnTop;
QAction* m_actionShowFullScreen;
QAction* m_actionShowBookmarksSideBar;
QAction* m_actionShowHistorySideBar;
@ -291,6 +295,7 @@ private:
AdBlockIcon* m_adblockIcon;
QPointer<WebInspectorDockWidget> m_webInspectorDock;
QWidget* m_navigationContainer;
BookmarksToolbar* m_bookmarksToolbar;
TabWidget* m_tabWidget;
QPointer<SideBar> m_sideBar;

View File

@ -446,7 +446,7 @@ win32 {
SOURCES += other/registerqappassociation.cpp
}
macx {
mac {
HEADERS += other/macmenureceiver.h
SOURCES += other/macmenureceiver.cpp
}

View File

@ -313,12 +313,15 @@ void MacMenuReceiver::changeEncoding(QObject* obj)
callSlot("changeEncoding", false, Q_ARG(QObject*, obj));
}
void MacMenuReceiver::triggerCaretBrowsing()
{
callSlot("triggerCaretBrowsing");
}
void MacMenuReceiver::triggerTabsOnTop(bool enable)
{
callSlot("triggerTabsOnTop", false, Q_ARG(bool, enable));
}
void MacMenuReceiver::closeWindow()
{
@ -330,7 +333,6 @@ void MacMenuReceiver::quitApp()
if (!callSlot("quitApp")) {
mApp->quitApplication();
}
}
void MacMenuReceiver::printPage(QWebFrame* frame)

View File

@ -120,6 +120,7 @@ private slots:
void changeEncoding(QObject* obj = 0);
void triggerCaretBrowsing();
void triggerTabsOnTop(bool enable);
void closeWindow();
void quitApp();

View File

@ -55,6 +55,7 @@ void QzSettings::loadSettings()
settings.beginGroup("Browser-Tabs-Settings");
newTabPosition = settings.value("OpenNewTabsSelected", false).toBool() ? Qz::NT_SelectedTab : Qz::NT_NotSelectedTab;
tabsOnTop = settings.value("TabsOnTop", true).toBool();
settings.endGroup();
}
@ -62,10 +63,12 @@ void QzSettings::saveSettings()
{
Settings settings;
settings.beginGroup("Web-Browser-Settings");
settings.setValue("AutomaticallyOpenProtocols", autoOpenProtocols);
settings.setValue("BlockOpeningProtocols", blockedProtocols);
settings.endGroup();
settings.beginGroup("Browser-Tabs-Settings");
settings.setValue("TabsOnTop", tabsOnTop);
settings.endGroup();
}

View File

@ -58,6 +58,7 @@ public:
// Browser-Tabs-Settings
Qz::NewTabPositionFlag newTabPosition;
bool tabsOnTop;
};
#define qzSettings Settings::staticSettings()

View File

@ -1,6 +1,6 @@
/* ============================================================
* 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
* it under the terms of the GNU General Public License as published by
@ -399,6 +399,8 @@ void TabBar::currentTabChanged(int index)
showCloseButton(index);
hideCloseButton(m_tabWidget->lastTabIndex());
m_tabWidget->currentTabChanged(index);
}
void TabBar::bookmarkTab()
@ -482,6 +484,7 @@ void TabBar::tabRemoved(int index)
{
Q_UNUSED(index)
m_tabWidget->showNavigationBar(p_QupZilla->navigationContainer());
showCloseButton(currentIndex());
}

View File

@ -30,6 +30,7 @@
#include "locationbar.h"
#include "websearchbar.h"
#include "settings.h"
#include "qzsettings.h"
#include <QMovie>
#include <QMenu>
@ -111,7 +112,6 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent)
m_tabBar = new TabBar(p_QupZilla, this);
setTabBar(m_tabBar);
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
connect(this, SIGNAL(currentChanged(int)), p_QupZilla, SLOT(refreshHistory()));
connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
@ -429,12 +429,13 @@ void TabWidget::currentTabChanged(int index)
WebTab* webTab = weTab(index);
LocationBar* locBar = webTab->locationBar();
if (m_locationBars->indexOf(locBar) != -1) {
if (locBar && m_locationBars->indexOf(locBar) != -1) {
m_locationBars->setCurrentWidget(locBar);
}
webTab->setCurrentTab();
p_QupZilla->currentTabChanged();
showNavigationBar(p_QupZilla->navigationContainer());
}
void TabWidget::tabMoved(int before, int after)
@ -586,6 +587,25 @@ int TabWidget::lastTabIndex() const
return m_lastTabIndex;
}
void TabWidget::showNavigationBar(QWidget* bar)
{
WebTab* tab = weTab();
if (tab) {
tab->showNavigationBar(bar);
}
}
TabBar* TabWidget::getTabBar() const
{
return m_tabBar;
}
ClosedTabsManager* TabWidget::closedTabsManager() const
{
return m_closedTabsManager;
}
void TabWidget::reloadAllTabs()
{
for (int i = 0; i < count(); i++) {
@ -687,11 +707,26 @@ void TabWidget::clearClosedTabsList()
m_closedTabsManager->clearList();
}
bool TabWidget::canRestoreTab()
bool TabWidget::canRestoreTab() const
{
return m_closedTabsManager->isClosedTabAvailable();
}
QStackedWidget* TabWidget::locationBars() const
{
return m_locationBars;
}
ToolButton* TabWidget::buttonListTabs() const
{
return m_buttonListTabs;
}
AddTabButton* TabWidget::buttonAddTab() const
{
return m_buttonAddTab;
}
void TabWidget::aboutToShowClosedTabsMenu()
{
if (!m_closedInsteadOpened) {

View File

@ -75,6 +75,7 @@ public:
void nextTab();
void previousTab();
void currentTabChanged(int index);
int normalTabsCount() const;
int pinnedTabsCount() const;
@ -82,13 +83,16 @@ public:
void showTabBar();
int lastTabIndex() const;
TabBar* getTabBar() { return m_tabBar; }
ClosedTabsManager* closedTabsManager() { return m_closedTabsManager; }
bool canRestoreTab();
void showNavigationBar(QWidget* bar);
TabBar* getTabBar() const;
ClosedTabsManager* closedTabsManager() const;
QList<WebTab*> allTabs(bool withPinned = true);
QStackedWidget* locationBars() { return m_locationBars; }
ToolButton* buttonListTabs() { return m_buttonListTabs; }
AddTabButton* buttonAddTab() { return m_buttonAddTab; }
bool canRestoreTab() const;
QStackedWidget* locationBars() const;
ToolButton* buttonListTabs() const;
AddTabButton* buttonAddTab() const;
void disconnectObjects();
@ -122,7 +126,6 @@ public slots:
private slots:
void aboutToShowTabsMenu();
void actionChangeIndex();
void currentTabChanged(int index);
void tabMoved(int before, int after);
private:
@ -142,6 +145,7 @@ private:
bool m_newTabAfterActive;
bool m_newEmptyTabAfterActive;
QUrl m_urlOnNewTab;
QupZilla* p_QupZilla;
int m_lastTabIndex;

View File

@ -70,6 +70,7 @@ QDataStream &operator >>(QDataStream &stream, WebTab::SavedTab &tab)
WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar)
: QWidget()
, p_QupZilla(mainClass)
, m_navigationContainer(0)
, m_locationBar(locationBar)
, m_pinned(false)
, m_inspectorVisible(false)
@ -84,6 +85,7 @@ WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar)
m_layout->setSpacing(0);
m_view = new TabbedWebView(p_QupZilla, this);
m_view->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
WebPage* page = new WebPage(p_QupZilla);
m_view->setWebPage(page);
m_layout->addWidget(m_view);
@ -293,11 +295,13 @@ QPixmap WebTab::renderTabPreview()
void WebTab::showNotification(QWidget* notif)
{
if (m_layout->count() > 1) {
const int notifPos = m_navigationContainer ? 2 : 1;
if (m_layout->count() > notifPos) {
delete m_layout->itemAt(0)->widget();
}
m_layout->insertWidget(0, notif);
m_layout->insertWidget(notifPos - 1, notif);
notif->show();
}
@ -306,6 +310,18 @@ int WebTab::tabIndex() const
return m_view->tabIndex();
}
void WebTab::showNavigationBar(QWidget* bar)
{
if (bar) {
m_navigationContainer = bar;
m_layout->insertWidget(0, m_navigationContainer);
// Needed to prevent flickering when closing tabs
m_navigationContainer->setUpdatesEnabled(true);
m_navigationContainer->show();
}
}
void WebTab::pinTab(int index)
{
TabWidget* tabWidget = p_QupZilla->tabWidget();
@ -337,5 +353,16 @@ void WebTab::disconnectObjects()
WebTab::~WebTab()
{
if (m_navigationContainer) {
m_layout->removeWidget(m_navigationContainer);
// Needed to prevent flickering when closing tabs
m_navigationContainer->setUpdatesEnabled(false);
m_navigationContainer->hide();
// Needed to prevent deleting m_navigationContainer in ~QWidget
m_navigationContainer->setParent(p_QupZilla);
}
delete m_locationBar.data();
}

View File

@ -1,6 +1,6 @@
/* ============================================================
* 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
* it under the terms of the GNU General Public License as published by
@ -76,6 +76,7 @@ public:
void setPinned(bool state);
int tabIndex() const;
void showNavigationBar(QWidget* bar);
void setLocationBar(LocationBar* bar);
LocationBar* locationBar() const;
@ -102,6 +103,7 @@ private:
QupZilla* p_QupZilla;
TabbedWebView* m_view;
QVBoxLayout* m_layout;
QWidget* m_navigationContainer;
QPointer<LocationBar> m_locationBar;
SavedTab m_savedTab;

View File

@ -3229,6 +3229,10 @@ Are you sure to quit QupZilla?</source>
<source>Enable &amp;Caret Browsing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Tabs on Top</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QupZillaSchemeReply</name>