From: Peter Penz Date: Sat, 25 Oct 2008 10:32:55 +0000 (+0000) Subject: If the context menu is opened above a directory, add the actions "Open in New Window... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/b1aadb8cce40ac4bc2f33729cd80ef270de72163 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 --- diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 7edfdb285..6409ba0fa 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -172,6 +172,11 @@ void DolphinContextMenu::openItemContextMenu() Q_ASSERT(!m_fileInfo.isNull()); KMenu* popup = new KMenu(m_mainWindow); + if (m_fileInfo.isDir() && (m_selectedUrls.count() == 1)) { + popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_window")); + popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_tab")); + popup->addSeparator(); + } addShowMenubarAction(popup); insertDefaultItemActions(popup); 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() diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 4b2236267..c98d2386a 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -310,6 +310,16 @@ private slots: void activatePrevTab(); + /** + * Opens the selected folder in a new tab. + */ + void openInNewTab(); + + /** + * Opens the selected folder in a new window. + */ + void openInNewWindow(); + /** Toggles the active view if two views are shown within the main window. */ void toggleActiveView();