From 45c659b440a3c8058fff1d4d7f64a3cc4d45e237 Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Wed, 22 May 2013 21:47:14 +0200 Subject: [PATCH] Added the "Open in new Tabs" action to the Dolphin Context menu. BUG: 312296 REVIEW: 110371 FIXED-IN: 4.11.0 --- src/dolphincontextmenu.cpp | 14 ++++++++++++++ src/dolphinmainwindow.cpp | 15 ++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index af8b61384..cddcc8936 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -235,6 +235,20 @@ void DolphinContextMenu::openItemContextMenu() this); addAction(openParentInNewTabAction); + addSeparator(); + } + } else { + bool selectionHasOnlyDirs = true; + foreach (const KFileItem& item, m_selectedItems) { + if (!item.isDir()) { + selectionHasOnlyDirs = false; + break; + } + } + + if (selectionHasOnlyDirs) { + // insert 'Open in new tab' entry + addAction(m_mainWindow->actionCollection()->action("open_in_new_tabs")); addSeparator(); } } diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 347489d6b..3b169a57d 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -520,11 +520,15 @@ void DolphinMainWindow::activatePrevTab() void DolphinMainWindow::openInNewTab() { - const KFileItemList list = m_activeViewContainer->view()->selectedItems(); + const KFileItemList& list = m_activeViewContainer->view()->selectedItems(); if (list.isEmpty()) { openNewTab(m_activeViewContainer->url()); - } else if ((list.count() == 1) && list[0].isDir()) { - openNewTab(list[0].url()); + } else { + foreach (const KFileItem& item, list) { + if (item.isDir()) { + openNewTab(item.url()); + } + } } } @@ -1645,6 +1649,11 @@ void DolphinMainWindow::setupActions() openInNewTab->setIcon(KIcon("tab-new")); connect(openInNewTab, SIGNAL(triggered()), this, SLOT(openInNewTab())); + KAction* openInNewTabs = actionCollection()->addAction("open_in_new_tabs"); + openInNewTabs->setText(i18nc("@action:inmenu", "Open in New Tabs")); + openInNewTabs->setIcon(KIcon("tab-new")); + connect(openInNewTabs, SIGNAL(triggered()), this, SLOT(openInNewTab())); + KAction* openInNewWindow = actionCollection()->addAction("open_in_new_window"); openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window")); openInNewWindow->setIcon(KIcon("window-new")); -- 2.47.3