X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/73ff57bef44984643bf1ffdb9a478095cfb78dfb..40cc5f665d:/src/dolphintabwidget.cpp diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp index de7a18db3..6caaf174f 100644 --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -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 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); }