]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Merge branch 'Applications/17.04'
[dolphin.git] / src / dolphinmainwindow.cpp
index 8d580432f76f6a631fcf29b6e6c94bfd0ec2376c..3d6f8489defecc2976509393a54e85c51b23f29d 100644 (file)
@@ -307,16 +307,21 @@ void DolphinMainWindow::openNewTab(const QUrl& url)
 void DolphinMainWindow::openInNewTab()
 {
     const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
-    if (list.isEmpty()) {
-        openNewTab(m_activeViewContainer->url());
-    } else {
-        foreach (const KFileItem& item, list) {
-            const QUrl& url = DolphinView::openItemAsFolderUrl(item);
-            if (!url.isEmpty()) {
-                openNewTab(url);
-            }
+    bool tabCreated = false;
+
+    foreach (const KFileItem& item, list) {
+        const QUrl& url = DolphinView::openItemAsFolderUrl(item);
+        if (!url.isEmpty()) {
+            openNewTab(url);
+            tabCreated = true;
         }
     }
+
+    // if no new tab has been created from the selection
+    // open the current directory in a new tab
+    if (!tabCreated) {
+        openNewTab(m_activeViewContainer->url());
+    }
 }
 
 void DolphinMainWindow::openInNewWindow()