From b1aadb8cce40ac4bc2f33729cd80ef270de72163 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 25 Oct 2008 10:32:55 +0000 Subject: If the context menu is opened above a directory, add the actions "Open in New Window" and "Open in New Tab" to the context menu. Thanks to Mathias Soeken for the patch! CCMAIL: msoeken@tzi.de svn path=/trunk/KDE/kdebase/apps/; revision=875711 --- src/dolphinmainwindow.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 3a46cd6df..0dc2ecb57 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -341,6 +341,25 @@ void DolphinMainWindow::activatePrevTab() m_tabBar->setCurrentIndex(tabIndex); } +void DolphinMainWindow::openInNewTab() +{ + const KFileItemList list = m_activeViewContainer->view()->selectedItems(); + if ((list.count() == 1) && list[0].isDir()) { + openNewTab(m_activeViewContainer->view()->selectedUrls()[0]); + m_tabBar->setCurrentIndex(m_viewTab.count() - 1); + } +} + +void DolphinMainWindow::openInNewWindow() +{ + const KFileItemList list = m_activeViewContainer->view()->selectedItems(); + if ((list.count() == 1) && list[0].isDir()) { + DolphinMainWindow* window = DolphinApplication::app()->createMainWindow(); + window->changeUrl(m_activeViewContainer->view()->selectedUrls()[0]); + window->show(); + } +} + void DolphinMainWindow::toggleActiveView() { if (m_viewTab[m_tabIndex].secondaryView == 0) { @@ -1050,6 +1069,17 @@ void DolphinMainWindow::setupActions() connect(activatePrevTab, SIGNAL(triggered()), SLOT(activatePrevTab())); activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev()); + + // for context menu + KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab"); + openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab")); + openInNewTab->setIcon(KIcon("tab-new")); + connect(openInNewTab, 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")); + connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow())); } void DolphinMainWindow::setupDockWidgets() -- cgit v1.3