]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Use the actions "new_tab" and "new_window" for the viewport-contextmenu instead of...
[dolphin.git] / src / dolphinmainwindow.cpp
index 9a5e5e3a8610c9b16688757880febfb8ba38547a..21b1817468c3251edb08b52ade656ae0f2f580cf 100644 (file)
@@ -462,17 +462,27 @@ void DolphinMainWindow::activatePrevTab()
 void DolphinMainWindow::openInNewTab()
 {
     const KFileItemList list = m_activeViewContainer->view()->selectedItems();
-    if ((list.count() == 1) && list[0].isDir()) {
+    if (list.isEmpty()) {
+        openNewTab(m_activeViewContainer->url());
+    } else if ((list.count() == 1) && list[0].isDir()) {
         openNewTab(m_activeViewContainer->view()->selectedUrls()[0]);
     }
 }
 
 void DolphinMainWindow::openInNewWindow()
 {
+    KUrl newWindowUrl;
+
     const KFileItemList list = m_activeViewContainer->view()->selectedItems();
-    if ((list.count() == 1) && list[0].isDir()) {
+    if (list.isEmpty()) {
+        newWindowUrl = m_activeViewContainer->url();
+    } else if ((list.count() == 1) && list[0].isDir()) {
+        newWindowUrl = m_activeViewContainer->view()->selectedUrls()[0];
+    }
+
+    if (!newWindowUrl.isEmpty()) {
         DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
-        window->changeUrl(m_activeViewContainer->view()->selectedUrls()[0]);
+        window->changeUrl(newWindowUrl);
         window->show();
     }
 }
@@ -1184,7 +1194,24 @@ void DolphinMainWindow::openContextMenu(const KFileItem& item,
 {
     DolphinContextMenu contextMenu(this, item, url);
     contextMenu.setCustomActions(customActions);
-    contextMenu.open();
+    const DolphinContextMenu::Command command = contextMenu.open();
+
+    switch (command) {
+    case DolphinContextMenu::OpenParentFolderInNewWindow: {
+        DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
+        window->changeUrl(item.url().upUrl());
+        window->show();
+        break;
+    }
+
+    case DolphinContextMenu::OpenParentFolderInNewTab:
+        openNewTab(item.url().upUrl());
+        break;
+
+    case DolphinContextMenu::None:
+    default:
+        break;
+    }
 }
 
 void DolphinMainWindow::init()