]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphintabwidget.cpp
GIT_SILENT Update Appstream for new release
[dolphin.git] / src / dolphintabwidget.cpp
index de7a18db3622636385910225d8af5b51ae090b6c..6caaf174f899e2e476a6c0ac43d3d40ae291237e 100644 (file)
@@ -157,7 +157,7 @@ void DolphinTabWidget::openNewActivatedTab(const QUrl& primaryUrl, const QUrl& s
     }
 }
 
-void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
+void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryUrl, DolphinTabWidget::NewTabPosition position)
 {
     QWidget* focusWidget = QApplication::focusWidget();
 
@@ -173,8 +173,16 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
         tabBar()->setTabText(tabIndex, tabName(tabPage));
     });
 
+    if (position == NewTabPosition::FollowSetting) {
+        if (GeneralSettings::openNewTabAfterLastTab()) {
+            position = NewTabPosition::AtEnd;
+        } else {
+            position = NewTabPosition::AfterCurrent;
+        }
+    }
+
     int newTabIndex = -1;
-    if (!GeneralSettings::openNewTabAfterLastTab()) {
+    if (position == NewTabPosition::AfterCurrent || (position == NewTabPosition::FollowSetting && !GeneralSettings::openNewTabAfterLastTab())) {
         newTabIndex = currentIndex() + 1;
     }
 
@@ -385,6 +393,17 @@ void DolphinTabWidget::tabDropEvent(int index, QDropEvent* event)
     if (index >= 0) {
         DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
         view->dropUrls(view->url(), event, view);
+    } else {
+        const auto urls = event->mimeData()->urls();
+
+        for (const QUrl &url : urls) {
+            auto *job = KIO::statDetails(url, KIO::StatJob::SourceSide, KIO::StatDetail::StatBasic, KIO::JobFlag::HideProgressInfo);
+            connect(job, &KJob::result, this, [this, job]() {
+                if (!job->error() && job->statResult().isDir()) {
+                    openNewTab(job->url(), QUrl(), NewTabPosition::AtEnd);
+                }
+            });
+        }
     }
 }
 
@@ -490,13 +509,13 @@ QPair<int, bool> DolphinTabWidget::indexByUrl(const QUrl& url, ChildUrlBehavior
     do {
         const auto tabPage = tabPageAt(i);
         if (tabPage->primaryViewContainer()->url() == url ||
-                childUrlBehavior == ReturnIndexForOpenedParentAlso && tabPage->primaryViewContainer()->url().isParentOf(url)) {
+                (childUrlBehavior == ReturnIndexForOpenedParentAlso && tabPage->primaryViewContainer()->url().isParentOf(url))) {
             return qMakePair(i, true);
         }
 
         if (tabPage->splitViewEnabled() &&
                 (url == tabPage->secondaryViewContainer()->url() ||
-                 childUrlBehavior == ReturnIndexForOpenedParentAlso && tabPage->secondaryViewContainer()->url().isParentOf(url))) {
+                 (childUrlBehavior == ReturnIndexForOpenedParentAlso && tabPage->secondaryViewContainer()->url().isParentOf(url)))) {
             return qMakePair(i, false);
         }