]> cloud.milkyroute.net Git - dolphin.git/commitdiff
You can now switch the tabs in dolphin via keyboard shortcuts like in konqueror
authorMathias Soeken <soeken@pprojekt.de>
Sat, 25 Oct 2008 09:00:28 +0000 (09:00 +0000)
committerMathias Soeken <soeken@pprojekt.de>
Sat, 25 Oct 2008 09:00:28 +0000 (09:00 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=875689

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h

index edff432a4f65a72886d5e99f3779c9f63923385d..04ce2b74111a1ec2337f4894977636c851b2407d 100644 (file)
@@ -318,6 +318,29 @@ void DolphinMainWindow::openNewTab(const KUrl& url)
     actionCollection()->action("close_tab")->setEnabled(true);
 }
 
+void DolphinMainWindow::activateNextTab()
+{
+    if (m_viewTab.count() == 1 || m_tabBar->count() < 2) {
+        return;
+    }
+
+    int tabIndex = (m_tabBar->currentIndex() + 1) % m_tabBar->count();
+    m_tabBar->setCurrentIndex(tabIndex);
+}
+
+void DolphinMainWindow::activatePrevTab()
+{
+    if (m_viewTab.count() == 1 || m_tabBar->count() < 2) {
+        return;
+    }
+
+    int tabIndex = (m_tabBar->currentIndex() - 1);
+    if (tabIndex == -1) {
+        tabIndex = m_tabBar->count() - 1;
+    }
+    m_tabBar->setCurrentIndex(tabIndex);
+}
+
 void DolphinMainWindow::toggleActiveView()
 {
     if (m_viewTab[m_tabIndex].secondaryView == 0) {
@@ -1015,6 +1038,17 @@ void DolphinMainWindow::setupActions()
     // setup 'Settings' menu
     m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
     KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
+
+    // not in menu actions
+    KAction* activateNextTab = actionCollection()->addAction("activatenexttab");
+    activateNextTab->setText( i18n( "Activate Next Tab" ) );
+    connect(activateNextTab, SIGNAL(triggered()), SLOT( activateNextTab() ));
+    activateNextTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext());
+
+    KAction* activatePrevTab = actionCollection()->addAction("activateprevtab");
+    activatePrevTab->setText( i18n( "Activate Previous Tab" ) );
+    connect(activatePrevTab, SIGNAL(triggered()), SLOT( activatePrevTab() ));
+    activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev());
 }
 
 void DolphinMainWindow::setupDockWidgets()
index a9db9a3e2c5aa40900916a98dd5cae4149d36781..eb609938f525697271b094406fff580be3756800 100644 (file)
@@ -305,6 +305,10 @@ private slots:
      */
     void openNewTab(const KUrl& url);
 
+    void activateNextTab();
+
+    void activatePrevTab();
+
     /** Toggles the active view if two views are shown within the main window. */
     void toggleActiveView();