]> cloud.milkyroute.net Git - dolphin.git/commitdiff
If the context menu is opened above a directory, add the actions "Open in New Window...
authorPeter Penz <peter.penz19@gmail.com>
Sat, 25 Oct 2008 10:32:55 +0000 (10:32 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 25 Oct 2008 10:32:55 +0000 (10:32 +0000)
Thanks to Mathias Soeken for the patch!

CCMAIL: msoeken@tzi.de

svn path=/trunk/KDE/kdebase/apps/; revision=875711

src/dolphincontextmenu.cpp
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h

index 7edfdb2852f4c38b86dd954d5ceb2f6f66f04457..6409ba0fa4146914af583b1cd59f4f9ce1ef2852 100644 (file)
@@ -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);
 
index 3a46cd6df09a0a916dd06523037cb33d2561c86e..0dc2ecb57bb898f2a6554e548e43580d48b939c4 100644 (file)
@@ -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()
index 4b223626798dd892a59e8425304de2074b22a255..c98d2386a3adc7cbd8e52c947698472ac86efbde 100644 (file)
@@ -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();