summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorFurkan Uzumcu <furkanuzumcu@gmail.com>2011-02-01 17:56:35 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-02-01 17:56:35 +0100
commit64e6342abf2f0a2c306d207b44715297eeabba7c (patch)
tree79060711ff4856947d4265dfa5d253f89b550f8c /src/mainwindow.cpp
parentMerge branch 'master' of git.kde.org:rekonq (diff)
downloadrekonq-64e6342abf2f0a2c306d207b44715297eeabba7c.tar.xz
Added pulldown menu for multiple steps to the "Forward History" button
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp63
1 files changed, 54 insertions, 9 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a93157a6..943f877d 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -104,6 +104,7 @@ MainWindow::MainWindow()
, m_webInspectorPanel(0)
, m_analyzerPanel(0)
, m_historyBackMenu(0)
+ , m_historyForwardMenu(0)
, m_encodingMenu(new KMenu(this))
, m_userAgentMenu(new KMenu(this))
, m_bookmarksBar(0)
@@ -178,6 +179,7 @@ MainWindow::~MainWindow()
delete m_stopReloadAction;
delete m_historyBackMenu;
+ delete m_historyForwardMenu;
delete m_encodingMenu;
delete m_bookmarksBar;
@@ -454,6 +456,11 @@ void MainWindow::setupActions()
a = actionCollection()->addAction(KStandardAction::Forward);
connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openNext(Qt::MouseButtons, Qt::KeyboardModifiers)));
+ m_historyForwardMenu = new KMenu(this);
+ a->setMenu(m_historyForwardMenu);
+ connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowForwardMenu()));
+ connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction*)));
+
// ============================== General Tab Actions ====================================
a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this);
a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_T));
@@ -1263,16 +1270,12 @@ void MainWindow::aboutToShowBackMenu()
QWebHistory *history = currentTab()->view()->history();
int pivot = history->currentItemIndex();
int offset = 0;
- QList<QWebHistoryItem> historyList = history->backItems(8); //no more than 8 elements!
+ const int maxItemNumber = 8; // no more than 8 elements in the Back History Menu!
+ QList<QWebHistoryItem> historyList = history->backItems(maxItemNumber);
int listCount = historyList.count();
- if (pivot >= 8)
- offset = pivot - 8;
-
- /*
- * Need a bug report upstream.
- * Seems setHtml() do some garbage in history
- * Here history->currentItem() have backItem url and currentItem (error page) title
- */
+ if (pivot >= maxItemNumber)
+ offset = pivot - maxItemNumber;
+
if (currentTab()->view()->page()->isOnRekonqPage())
{
QWebHistoryItem item = history->currentItem();
@@ -1296,6 +1299,48 @@ void MainWindow::aboutToShowBackMenu()
}
}
+
+void MainWindow::aboutToShowForwardMenu()
+{
+ m_historyForwardMenu->clear();
+
+ if (!currentTab())
+ return;
+
+ QWebHistory *history = currentTab()->view()->history();
+ const int pivot = history->currentItemIndex();
+ int offset = 0;
+ const int maxItemNumber = 8; // no more than 8 elements in the Forward History Menu!
+ QList<QWebHistoryItem> historyList = history->forwardItems(maxItemNumber);
+ int listCount = historyList.count();
+
+ if (pivot >= maxItemNumber)
+ offset = pivot - maxItemNumber;
+
+ if (currentTab()->view()->page()->isOnRekonqPage())
+ {
+ QWebHistoryItem item = history->currentItem();
+ KAction *action = new KAction(this);
+ action->setData(listCount + offset++);
+ KIcon icon = Application::iconManager()->iconForUrl(item.url());
+ action->setIcon(icon);
+ action->setText(item.title());
+ m_historyForwardMenu->addAction(action);
+ }
+
+ for (int i = 1; i <= listCount; i++)
+ {
+ QWebHistoryItem item = historyList.at(i - 1);
+ KAction *action = new KAction(this);
+ action->setData(pivot +i + offset);
+ KIcon icon = Application::iconManager()->iconForUrl(item.url());
+ action->setIcon(icon);
+ action->setText(item.title());
+ m_historyForwardMenu->addAction(action);
+ }
+}
+
+
void MainWindow::aboutToShowTabListMenu()
{
m_tabListMenu->clear();