2011-09-23 22:06:21 +02:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2012-01-01 15:29:55 +01:00
|
|
|
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
2011-09-23 22:06:21 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-09-11 19:15:06 +02:00
|
|
|
#include "navigationbar.h"
|
|
|
|
#include "toolbutton.h"
|
|
|
|
#include "qupzilla.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "mainapplication.h"
|
2011-09-11 19:15:06 +02:00
|
|
|
#include "iconprovider.h"
|
|
|
|
#include "websearchbar.h"
|
|
|
|
#include "reloadstopbutton.h"
|
2011-10-29 23:01:17 +02:00
|
|
|
#include "webhistorywrapper.h"
|
2011-12-14 22:30:05 +01:00
|
|
|
#include "enhancedmenu.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "tabwidget.h"
|
|
|
|
#include "tabbedwebview.h"
|
2012-04-03 19:28:12 +02:00
|
|
|
#include "webpage.h"
|
2012-08-10 21:16:43 +02:00
|
|
|
#include "qzsettings.h"
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QSplitter>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QStackedWidget>
|
|
|
|
#include <QWebHistory>
|
|
|
|
|
2012-10-01 11:26:07 +02:00
|
|
|
QString NavigationBar::titleForUrl(QString title, const QUrl &url)
|
2011-12-16 19:07:36 +01:00
|
|
|
{
|
|
|
|
if (title.isEmpty()) {
|
2011-12-16 20:17:17 +01:00
|
|
|
title = url.toString(QUrl::RemoveFragment);
|
2011-12-16 19:07:36 +01:00
|
|
|
}
|
|
|
|
if (title.isEmpty()) {
|
|
|
|
return NavigationBar::tr("No Named Page");
|
|
|
|
}
|
|
|
|
if (title.length() > 40) {
|
|
|
|
title.truncate(40);
|
|
|
|
title += "..";
|
|
|
|
}
|
|
|
|
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
2012-10-01 11:26:07 +02:00
|
|
|
QIcon NavigationBar::iconForPage(const QUrl &url, const QIcon &sIcon)
|
2012-04-01 10:48:50 +02:00
|
|
|
{
|
|
|
|
QIcon icon;
|
2012-09-04 12:42:45 +02:00
|
|
|
icon.addPixmap(url.scheme() == QLatin1String("qupzilla") ? QIcon(":icons/qupzilla.png").pixmap(16, 16) : _iconForUrl(url).pixmap(16, 16));
|
2012-04-01 10:48:50 +02:00
|
|
|
icon.addPixmap(sIcon.pixmap(16, 16), QIcon::Active);
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
2012-10-01 11:26:07 +02:00
|
|
|
NavigationBar::NavigationBar(QupZilla* mainClass)
|
|
|
|
: QWidget(mainClass)
|
2011-09-11 19:15:06 +02:00
|
|
|
, p_QupZilla(mainClass)
|
|
|
|
{
|
|
|
|
setObjectName("navigationbar");
|
|
|
|
m_layout = new QHBoxLayout(this);
|
2012-03-04 22:30:45 +01:00
|
|
|
m_layout->setMargin(3);
|
|
|
|
m_layout->setSpacing(3);
|
2011-09-11 19:15:06 +02:00
|
|
|
setLayout(m_layout);
|
|
|
|
|
2011-12-04 20:09:44 +01:00
|
|
|
m_buttonBack = new ToolButton(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_buttonBack->setObjectName("navigation-button-back");
|
|
|
|
m_buttonBack->setToolTip(tr("Back"));
|
|
|
|
m_buttonBack->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
|
|
m_buttonBack->setAutoRaise(true);
|
|
|
|
m_buttonBack->setEnabled(false);
|
2012-01-08 12:38:02 +01:00
|
|
|
m_buttonBack->setFocusPolicy(Qt::NoFocus);
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2011-12-04 20:09:44 +01:00
|
|
|
m_buttonNext = new ToolButton(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_buttonNext->setObjectName("navigation-button-next");
|
|
|
|
m_buttonNext->setToolTip(tr("Forward"));
|
|
|
|
m_buttonNext->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
|
|
m_buttonNext->setAutoRaise(true);
|
|
|
|
m_buttonNext->setEnabled(false);
|
2012-01-08 12:38:02 +01:00
|
|
|
m_buttonNext->setFocusPolicy(Qt::NoFocus);
|
2011-09-11 19:15:06 +02:00
|
|
|
|
|
|
|
QHBoxLayout* backNextLayout = new QHBoxLayout();
|
2011-12-18 13:15:56 +01:00
|
|
|
backNextLayout->setContentsMargins(0, 0, 0, 0);
|
2011-09-11 19:15:06 +02:00
|
|
|
backNextLayout->setSpacing(0);
|
|
|
|
backNextLayout->addWidget(m_buttonBack);
|
|
|
|
backNextLayout->addWidget(m_buttonNext);
|
|
|
|
|
2011-12-04 20:09:44 +01:00
|
|
|
m_reloadStop = new ReloadStopButton(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2011-12-04 20:09:44 +01:00
|
|
|
m_buttonHome = new ToolButton(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_buttonHome->setObjectName("navigation-button-home");
|
|
|
|
m_buttonHome->setToolTip(tr("Home"));
|
|
|
|
m_buttonHome->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
|
|
m_buttonHome->setAutoRaise(true);
|
2012-01-08 12:38:02 +01:00
|
|
|
m_buttonHome->setFocusPolicy(Qt::NoFocus);
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2011-12-04 20:09:44 +01:00
|
|
|
m_buttonAddTab = new ToolButton(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_buttonAddTab->setObjectName("navigation-button-addtab");
|
|
|
|
m_buttonAddTab->setToolTip(tr("New Tab"));
|
|
|
|
m_buttonAddTab->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
|
|
m_buttonAddTab->setAutoRaise(true);
|
2012-01-08 12:38:02 +01:00
|
|
|
m_buttonAddTab->setFocusPolicy(Qt::NoFocus);
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2011-12-12 18:07:07 +01:00
|
|
|
m_menuBack = new Menu(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_buttonBack->setMenu(m_menuBack);
|
2011-12-12 18:07:07 +01:00
|
|
|
m_menuForward = new Menu(this);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_buttonNext->setMenu(m_menuForward);
|
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2011-09-11 19:15:06 +02:00
|
|
|
m_supMenu = new ToolButton(this);
|
|
|
|
m_supMenu->setObjectName("navigation-button-supermenu");
|
|
|
|
m_supMenu->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
m_supMenu->setToolTip(tr("Main Menu"));
|
|
|
|
m_supMenu->setAutoRaise(true);
|
2012-03-04 14:25:52 +01:00
|
|
|
m_supMenu->setFocusPolicy(Qt::NoFocus);
|
2011-09-11 19:15:06 +02:00
|
|
|
m_supMenu->setMenu(p_QupZilla->superMenu());
|
2012-01-27 17:25:51 +01:00
|
|
|
#endif
|
2011-09-11 19:15:06 +02:00
|
|
|
|
|
|
|
m_searchLine = new WebSearchBar(p_QupZilla);
|
|
|
|
|
|
|
|
m_navigationSplitter = new QSplitter(this);
|
|
|
|
m_navigationSplitter->addWidget(p_QupZilla->tabWidget()->locationBars());
|
|
|
|
m_navigationSplitter->addWidget(m_searchLine);
|
|
|
|
|
|
|
|
m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
|
|
|
m_navigationSplitter->setCollapsible(0, false);
|
|
|
|
|
|
|
|
m_exitFullscreen = new ToolButton();
|
|
|
|
m_exitFullscreen->setText(tr("Exit Fullscreen"));
|
|
|
|
m_exitFullscreen->setToolTip(tr("Exit Fullscreen"));
|
|
|
|
m_exitFullscreen->setAutoRaise(true);
|
|
|
|
m_exitFullscreen->setVisible(false);
|
|
|
|
|
|
|
|
m_layout->addLayout(backNextLayout);
|
|
|
|
m_layout->addWidget(m_reloadStop);
|
|
|
|
m_layout->addWidget(m_buttonHome);
|
|
|
|
m_layout->addWidget(m_buttonAddTab);
|
|
|
|
m_layout->addWidget(m_navigationSplitter);
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2011-09-11 19:15:06 +02:00
|
|
|
m_layout->addWidget(m_supMenu);
|
2012-01-28 16:20:03 +01:00
|
|
|
#endif
|
2011-09-11 19:15:06 +02:00
|
|
|
m_layout->addWidget(m_exitFullscreen);
|
|
|
|
|
|
|
|
connect(m_menuBack, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryBackMenu()));
|
|
|
|
connect(m_menuForward, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryNextMenu()));
|
2011-10-29 23:01:17 +02:00
|
|
|
connect(m_buttonBack, SIGNAL(clicked()), this, SLOT(goBack()));
|
2011-12-12 18:30:08 +01:00
|
|
|
connect(m_buttonBack, SIGNAL(middleMouseClicked()), this, SLOT(goBackInNewTab()));
|
2012-02-08 14:40:21 +01:00
|
|
|
connect(m_buttonBack, SIGNAL(controlClicked()), this, SLOT(goBackInNewTab()));
|
2011-10-29 23:01:17 +02:00
|
|
|
connect(m_buttonNext, SIGNAL(clicked()), this, SLOT(goForward()));
|
2011-12-12 18:30:08 +01:00
|
|
|
connect(m_buttonNext, SIGNAL(middleMouseClicked()), this, SLOT(goForwardInNewTab()));
|
2012-02-08 14:40:21 +01:00
|
|
|
connect(m_buttonNext, SIGNAL(controlClicked()), this, SLOT(goForwardInNewTab()));
|
2011-12-12 18:30:08 +01:00
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
connect(m_reloadStop->buttonStop(), SIGNAL(clicked()), p_QupZilla, SLOT(stop()));
|
|
|
|
connect(m_reloadStop->buttonReload(), SIGNAL(clicked()), p_QupZilla, SLOT(reload()));
|
|
|
|
connect(m_buttonHome, SIGNAL(clicked()), p_QupZilla, SLOT(goHome()));
|
2011-10-26 19:23:50 +02:00
|
|
|
connect(m_buttonHome, SIGNAL(middleMouseClicked()), p_QupZilla, SLOT(goHomeInNewTab()));
|
2011-12-07 15:17:21 +01:00
|
|
|
connect(m_buttonHome, SIGNAL(controlClicked()), p_QupZilla, SLOT(goHomeInNewTab()));
|
2011-09-11 19:15:06 +02:00
|
|
|
connect(m_buttonAddTab, SIGNAL(clicked()), p_QupZilla, SLOT(addTab()));
|
|
|
|
connect(m_exitFullscreen, SIGNAL(clicked(bool)), p_QupZilla, SLOT(fullScreen(bool)));
|
|
|
|
}
|
|
|
|
|
2011-10-17 09:57:07 +02:00
|
|
|
void NavigationBar::setSplitterSizes(int locationBar, int websearchBar)
|
|
|
|
{
|
|
|
|
QList<int> sizes;
|
|
|
|
|
|
|
|
if (locationBar == 0) {
|
|
|
|
int splitterWidth = m_navigationSplitter->width();
|
|
|
|
sizes << (int)((double)splitterWidth * .80) << (int)((double)splitterWidth * .20);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-10-17 09:57:07 +02:00
|
|
|
sizes << locationBar << websearchBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_navigationSplitter->setSizes(sizes);
|
|
|
|
}
|
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
void NavigationBar::showReloadButton()
|
|
|
|
{
|
|
|
|
m_reloadStop->showReloadButton();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationBar::showStopButton()
|
|
|
|
{
|
|
|
|
m_reloadStop->showStopButton();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationBar::aboutToShowHistoryBackMenu()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!m_menuBack || !p_QupZilla->weView()) {
|
2011-09-11 19:15:06 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-11 19:15:06 +02:00
|
|
|
m_menuBack->clear();
|
|
|
|
QWebHistory* history = p_QupZilla->weView()->history();
|
2011-10-29 23:01:17 +02:00
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
int curindex = history->currentItemIndex();
|
|
|
|
int count = 0;
|
2011-10-29 23:01:17 +02:00
|
|
|
QUrl lastUrl = history->currentItem().url();
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
for (int i = curindex - 1; i >= 0; i--) {
|
2011-09-11 19:15:06 +02:00
|
|
|
QWebHistoryItem item = history->itemAt(i);
|
2011-10-29 23:01:17 +02:00
|
|
|
if (item.isValid() && lastUrl != item.url()) {
|
2011-12-16 19:07:36 +01:00
|
|
|
QString title = titleForUrl(item.title(), item.url());
|
2011-12-12 18:07:07 +01:00
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
const QIcon &icon = iconForPage(item.url(), qIconProvider->standardIcon(QStyle::SP_ArrowBack));
|
2012-04-01 10:48:50 +02:00
|
|
|
Action* act = new Action(icon, title);
|
2011-12-12 18:07:07 +01:00
|
|
|
act->setData(i);
|
2011-12-12 21:14:43 +01:00
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex()));
|
|
|
|
connect(act, SIGNAL(middleClicked()), this, SLOT(goAtHistoryIndexInNewTab()));
|
2011-12-12 18:07:07 +01:00
|
|
|
m_menuBack->addAction(act);
|
|
|
|
|
2011-10-29 23:01:17 +02:00
|
|
|
lastUrl = item.url();
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|
2011-10-29 23:01:17 +02:00
|
|
|
|
|
|
|
count++;
|
2011-11-06 17:01:23 +01:00
|
|
|
if (count == 20) {
|
2011-09-11 19:15:06 +02:00
|
|
|
break;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|
2011-10-29 23:01:17 +02:00
|
|
|
|
|
|
|
m_menuBack->addSeparator();
|
|
|
|
m_menuBack->addAction(tr("Clear history"), this, SLOT(clearHistory()));
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationBar::aboutToShowHistoryNextMenu()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!m_menuForward || !p_QupZilla->weView()) {
|
2011-09-11 19:15:06 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-11 19:15:06 +02:00
|
|
|
m_menuForward->clear();
|
2011-10-29 23:01:17 +02:00
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
QWebHistory* history = p_QupZilla->weView()->history();
|
|
|
|
int curindex = history->currentItemIndex();
|
|
|
|
int count = 0;
|
2011-10-29 23:01:17 +02:00
|
|
|
QUrl lastUrl = history->currentItem().url();
|
2011-09-11 19:15:06 +02:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
for (int i = curindex + 1; i < history->count(); i++) {
|
2011-09-11 19:15:06 +02:00
|
|
|
QWebHistoryItem item = history->itemAt(i);
|
2011-10-29 23:01:17 +02:00
|
|
|
if (item.isValid() && lastUrl != item.url()) {
|
2011-12-16 19:07:36 +01:00
|
|
|
QString title = titleForUrl(item.title(), item.url());
|
2011-12-12 18:07:07 +01:00
|
|
|
|
2012-04-22 20:51:28 +02:00
|
|
|
const QIcon &icon = iconForPage(item.url(), qIconProvider->standardIcon(QStyle::SP_ArrowForward));
|
2012-04-01 10:48:50 +02:00
|
|
|
Action* act = new Action(icon, title);
|
2011-12-12 18:07:07 +01:00
|
|
|
act->setData(i);
|
2011-12-12 21:14:43 +01:00
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex()));
|
|
|
|
connect(act, SIGNAL(middleClicked()), this, SLOT(goAtHistoryIndexInNewTab()));
|
2011-12-12 18:07:07 +01:00
|
|
|
m_menuForward->addAction(act);
|
|
|
|
|
2011-10-29 23:01:17 +02:00
|
|
|
lastUrl = item.url();
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|
2011-10-29 23:01:17 +02:00
|
|
|
|
|
|
|
count++;
|
2011-11-06 17:01:23 +01:00
|
|
|
if (count == 20) {
|
2011-09-11 19:15:06 +02:00
|
|
|
break;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|
2011-10-29 23:01:17 +02:00
|
|
|
|
|
|
|
m_menuForward->addSeparator();
|
|
|
|
m_menuForward->addAction(tr("Clear history"), this, SLOT(clearHistory()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationBar::clearHistory()
|
|
|
|
{
|
|
|
|
QWebHistory* history = p_QupZilla->weView()->page()->history();
|
|
|
|
history->clear();
|
|
|
|
refreshHistory();
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationBar::goAtHistoryIndex()
|
|
|
|
{
|
2011-12-12 18:07:07 +01:00
|
|
|
QWebHistory* history = p_QupZilla->weView()->page()->history();
|
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
2011-12-12 18:07:07 +01:00
|
|
|
history->goToItem(history->itemAt(action->data().toInt()));
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|
2011-10-29 23:01:17 +02:00
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
refreshHistory();
|
|
|
|
}
|
|
|
|
|
2011-12-12 18:30:08 +01:00
|
|
|
void NavigationBar::goAtHistoryIndexInNewTab(int index)
|
2011-12-12 18:07:07 +01:00
|
|
|
{
|
|
|
|
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
2011-12-12 18:30:08 +01:00
|
|
|
index = action->data().toInt();
|
|
|
|
}
|
2011-12-12 18:07:07 +01:00
|
|
|
|
2011-12-12 18:30:08 +01:00
|
|
|
if (index == -1) {
|
|
|
|
return;
|
2011-12-12 18:07:07 +01:00
|
|
|
}
|
2011-12-12 18:30:08 +01:00
|
|
|
|
|
|
|
TabWidget* tabWidget = p_QupZilla->tabWidget();
|
2011-12-29 15:45:29 +01:00
|
|
|
int tabIndex = tabWidget->duplicateTab(tabWidget->currentIndex());
|
2011-12-12 18:30:08 +01:00
|
|
|
|
|
|
|
QWebHistory* history = p_QupZilla->weView(tabIndex)->page()->history();
|
|
|
|
history->goToItem(history->itemAt(index));
|
2012-06-27 18:05:09 +02:00
|
|
|
|
2012-08-10 21:16:43 +02:00
|
|
|
if (qzSettings->newTabPosition == Qz::NT_SelectedTab) {
|
2012-06-27 18:05:09 +02:00
|
|
|
tabWidget->setCurrentIndex(tabIndex);
|
|
|
|
}
|
2011-12-12 18:07:07 +01:00
|
|
|
}
|
|
|
|
|
2011-09-11 19:15:06 +02:00
|
|
|
void NavigationBar::refreshHistory()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (mApp->isClosing() || p_QupZilla->isClosing()) {
|
2011-09-11 19:15:06 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-09-11 19:15:06 +02:00
|
|
|
|
|
|
|
QWebHistory* history = p_QupZilla->weView()->page()->history();
|
2012-04-04 13:21:53 +02:00
|
|
|
m_buttonBack->setEnabled(history->canGoBack());
|
|
|
|
m_buttonNext->setEnabled(history->canGoForward());
|
2011-10-29 23:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationBar::goBack()
|
|
|
|
{
|
2011-12-12 18:30:08 +01:00
|
|
|
QWebHistory* history = p_QupZilla->weView()->page()->history();
|
2012-04-04 13:21:53 +02:00
|
|
|
history->back();
|
2011-12-12 18:30:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationBar::goBackInNewTab()
|
|
|
|
{
|
|
|
|
QWebHistory* history = p_QupZilla->weView()->page()->history();
|
|
|
|
|
2012-04-04 13:21:53 +02:00
|
|
|
if (!history->canGoBack()) {
|
2011-12-12 18:30:08 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-04 13:21:53 +02:00
|
|
|
int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), history->backItem());
|
2011-12-12 18:30:08 +01:00
|
|
|
if (itemIndex == -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
goAtHistoryIndexInNewTab(itemIndex);
|
2011-10-29 23:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationBar::goForward()
|
|
|
|
{
|
2011-12-12 18:30:08 +01:00
|
|
|
QWebHistory* history = p_QupZilla->weView()->page()->history();
|
2012-04-04 13:21:53 +02:00
|
|
|
history->forward();
|
2011-12-12 18:30:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NavigationBar::goForwardInNewTab()
|
|
|
|
{
|
|
|
|
QWebHistory* history = p_QupZilla->weView()->page()->history();
|
|
|
|
|
2012-04-04 13:21:53 +02:00
|
|
|
if (!history->canGoForward()) {
|
2011-12-12 18:30:08 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-04 13:21:53 +02:00
|
|
|
int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), history->forwardItem());
|
2011-12-12 18:30:08 +01:00
|
|
|
if (itemIndex == -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
goAtHistoryIndexInNewTab(itemIndex);
|
2011-09-11 19:15:06 +02:00
|
|
|
}
|