diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-05-24 16:55:38 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-05-24 16:55:38 +0200 |
commit | 25cc96d4f7c38181f8b1c6739fb90eaa403191c5 (patch) | |
tree | d39d7d9c1b10808400f7b22901e1b2b50ffaac1a | |
parent | Merge commit 'refs/merge-requests/2273' of git://gitorious.org/rekonq/mainlin... (diff) | |
parent | Added actions to switch to Tab #n (diff) | |
download | rekonq-25cc96d4f7c38181f8b1c6739fb90eaa403191c5.tar.xz |
Merge commit 'refs/merge-requests/2274' of git://gitorious.org/rekonq/mainline into m2274
-rw-r--r-- | src/mainview.cpp | 11 | ||||
-rw-r--r-- | src/mainview.h | 1 | ||||
-rw-r--r-- | src/mainwindow.cpp | 10 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp index 1c36adcf..01f0e1a4 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -657,6 +657,17 @@ void MainView::openClosedTab() } } +void MainView::switchToTab() +{ + // uses the sender to determine the tab index + QAction *sender = static_cast<QAction*>(QObject::sender()); + int index = sender->data().toInt(); + index -= 1; // to compensate for off by 1 presented to the user + if( index < 0 || index >= count() ) + return; + setCurrentIndex( index ); +} + QLabel *MainView::animatedLoading(int index, bool addMovie) { if (index == -1) diff --git a/src/mainview.h b/src/mainview.h index 0cff4c81..636d37ac 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -135,6 +135,7 @@ public slots: void detachTab(int index = -1); void openClosedTabs(); void openClosedTab(); + void switchToTab(); // WEB slot actions void webReload(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f5be73ee..d14f2254 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -398,6 +398,16 @@ void MainWindow::setupActions() closedTabsMenu->setDelayed(false); actionCollection()->addAction(QL1S("closed_tab_menu"), closedTabsMenu); + // shortcuts for quickly switching to a tab + for( int i = 1; i <= 9; i++ ) { + a = new KAction(i18n("Switch to Tab %1", i), this); + a->setShortcut(KShortcut( QString("Alt+%1").arg(i) )); + a->setData( QVariant(i) ); + actionCollection()->addAction(QL1S(("switch_tab_" + QString::number(i)).toAscii()), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(switchToTab())); + } + + // ============================== Indexed Tab Actions ==================================== a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); actionCollection()->addAction(QL1S("close_tab"), a); |