summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-12-21 21:25:46 +0100
committerAndrea Diamantini <adjam7@gmail.com>2010-12-21 21:25:46 +0100
commit0b6a409095880fad4a8f7ae59019c56e5093808e (patch)
tree1965f5832f0b6c0c445ef957eed65fa08629d012 /src/mainwindow.cpp
parentSVN_SILENT made messages (.desktop file) (diff)
downloadrekonq-0b6a409095880fad4a8f7ae59019c56e5093808e.tar.xz
Adding a tab list menu entry showing all open tabs.
Courtesy patch by Felix Rohrbach. Thanks :)
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index be534432..4159d451 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -404,6 +404,17 @@ void MainWindow::setupActions()
// set zoom bar actions
m_zoomBar->setupActions(this);
+
+ // tab list
+ m_tabListMenu = new KMenu();
+ m_tabListMenu->addAction("hack"); // necessary to show the menu on the right side the first time
+ connect(m_tabListMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowTabListMenu()));
+ connect(m_tabListMenu, SIGNAL(triggered(QAction*)), this, SLOT(openActionTab(QAction*)));
+ KActionMenu *tabAction = new KActionMenu(i18n("Tab List"), this);
+ tabAction->setMenu(m_tabListMenu);
+ tabAction->setIcon(KIcon("document-multiple"));
+ tabAction->setDelayed(false);
+ actionCollection()->addAction(QL1S("tab_list"), tabAction);
// =============================== Tools Actions =================================
a = new KAction(i18n("View Page S&ource"), this);
@@ -1243,6 +1254,18 @@ void MainWindow::aboutToShowBackMenu()
}
}
+void MainWindow::aboutToShowTabListMenu()
+{
+ m_tabListMenu->clear();
+ for( int i = 0; i < m_view->count(); ++i ){
+ KAction *action = new KAction(m_view->tabText(i), this);
+ action->setIcon(Application::iconManager()->iconForUrl(m_view->webTab(i)->url()).pixmap(16, 16));
+ action->setData(i);
+ m_tabListMenu->addAction(action);
+ }
+ m_tabListMenu->adjustSize();
+}
+
void MainWindow::openActionUrl(QAction *action)
{
@@ -1258,6 +1281,17 @@ void MainWindow::openActionUrl(QAction *action)
history->goToItem(history->itemAt(index));
}
+void MainWindow::openActionTab(QAction* action)
+{
+ int index = action->data().toInt();
+ if(index < 0 || index >= m_view->count())
+ {
+ kDebug() << "Invalid Index!: " << index;
+ return;
+ }
+ m_view->setCurrentIndex(index);
+}
+
void MainWindow::setEncoding(QAction *qa)
{