summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/mainwindow.cpp63
-rw-r--r--src/mainwindow.h5
2 files changed, 59 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();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 3a918879..598d66e3 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -158,6 +158,8 @@ private Q_SLOTS:
void clearPrivateData();
void aboutToShowBackMenu();
+ void aboutToShowForwardMenu();
+
void aboutToShowTabListMenu();
void openActionUrl(QAction *action);
void openActionTab(QAction *action);
@@ -187,7 +189,10 @@ private:
NetworkAnalyzerPanel *m_analyzerPanel;
KAction *m_stopReloadAction;
+
KMenu *m_historyBackMenu;
+ KMenu *m_historyForwardMenu;
+
KMenu *m_encodingMenu;
KMenu *m_tabListMenu;