mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
DolphinTabBar: Open folder in new tab when dropped onto tab bar
This commit is contained in:
parent
8402b98995
commit
380543334c
|
@ -36,13 +36,7 @@ void DolphinTabBar::dragEnterEvent(QDragEnterEvent* event)
|
||||||
const int index = tabAt(event->pos());
|
const int index = tabAt(event->pos());
|
||||||
|
|
||||||
if (mimeData->hasUrls()) {
|
if (mimeData->hasUrls()) {
|
||||||
if (index >= 0) {
|
event->acceptProposedAction();
|
||||||
event->acceptProposedAction();
|
|
||||||
} else {
|
|
||||||
event->setDropAction(Qt::IgnoreAction);
|
|
||||||
// Still need to accept it to receive dragMoveEvent
|
|
||||||
event->accept();
|
|
||||||
}
|
|
||||||
updateAutoActivationTimer(index);
|
updateAutoActivationTimer(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,11 +56,6 @@ void DolphinTabBar::dragMoveEvent(QDragMoveEvent* event)
|
||||||
const int index = tabAt(event->pos());
|
const int index = tabAt(event->pos());
|
||||||
|
|
||||||
if (mimeData->hasUrls()) {
|
if (mimeData->hasUrls()) {
|
||||||
if (index >= 0) {
|
|
||||||
event->acceptProposedAction();
|
|
||||||
} else {
|
|
||||||
event->setDropAction(Qt::IgnoreAction);
|
|
||||||
}
|
|
||||||
updateAutoActivationTimer(index);
|
updateAutoActivationTimer(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +70,7 @@ void DolphinTabBar::dropEvent(QDropEvent* event)
|
||||||
const QMimeData* mimeData = event->mimeData();
|
const QMimeData* mimeData = event->mimeData();
|
||||||
const int index = tabAt(event->pos());
|
const int index = tabAt(event->pos());
|
||||||
|
|
||||||
if (index >= 0 && mimeData->hasUrls()) {
|
if (mimeData->hasUrls()) {
|
||||||
Q_EMIT tabDropEvent(index, event);
|
Q_EMIT tabDropEvent(index, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -393,6 +393,17 @@ void DolphinTabWidget::tabDropEvent(int index, QDropEvent* event)
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
|
DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
|
||||||
view->dropUrls(view->url(), event, 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue