diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 73ed049a1..d80252fef 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1136,14 +1136,15 @@ void MainWindow::onClipboardCommandActionTriggered(CommandAction *commandAction, action( actionData, command, QModelIndex() ); } -void MainWindow::onTabWidgetDropItems(const QString &tabName, const QMimeData *data) +void MainWindow::onTabWidgetDropItems(const QString &tabName, const QMimeData *data, bool *accepted) { auto browser = tab(tabName); if (browser) { const QVariantMap dataMap = data->hasFormat(mimeItems) ? cloneData(data, QStringList() << mimeItems) : cloneData(data); - browser->addAndSelect(dataMap, 0); + if ( browser->addAndSelect(dataMap, 0) ) + *accepted = true; } } diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 742bc70a6..45c76d61a 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -486,7 +486,7 @@ class MainWindow final : public QMainWindow void onItemCommandActionTriggered(CommandAction *commandAction, const QString &triggeredShortcut); void onClipboardCommandActionTriggered(CommandAction *commandAction, const QString &triggeredShortcut); - void onTabWidgetDropItems(const QString &tabName, const QMimeData *data); + void onTabWidgetDropItems(const QString &tabName, const QMimeData *data, bool *accepted); void showContextMenuAt(QPoint position); diff --git a/src/gui/tabbar.cpp b/src/gui/tabbar.cpp index 31aaa3b28..ac98a5ebe 100644 --- a/src/gui/tabbar.cpp +++ b/src/gui/tabbar.cpp @@ -184,8 +184,10 @@ void TabBar::dropEvent(QDropEvent *event) int tabIndex = dropItemsTabIndex(*event, *this); if ( tabIndex != -1 ) { - acceptDrag(event); - emit dropItems( tabName(tabIndex), event->mimeData() ); + bool accepted = false; + emit dropItems( tabName(tabIndex), event->mimeData(), &accepted ); + if (accepted) + acceptDrag(event); } else { QTabBar::dropEvent(event); } diff --git a/src/gui/tabbar.h b/src/gui/tabbar.h index 5ecfdd588..e0f08fa8f 100644 --- a/src/gui/tabbar.h +++ b/src/gui/tabbar.h @@ -49,7 +49,7 @@ class TabBar final : public QTabBar, public TabsWidgetInterface signals: void tabBarMenuRequested(const QPoint &pos, int tab); void tabRenamed(const QString &newName, int index); - void dropItems(const QString &tabName, const QMimeData *data); + void dropItems(const QString &tabName, const QMimeData *data, bool *accepted); protected: void contextMenuEvent(QContextMenuEvent *event) override; diff --git a/src/gui/tabtree.cpp b/src/gui/tabtree.cpp index 17b309eef..0d98b0d7b 100644 --- a/src/gui/tabtree.cpp +++ b/src/gui/tabtree.cpp @@ -559,8 +559,10 @@ void TabTree::dropEvent(QDropEvent *event) const auto targetItem = dropItemsTarget(*event, *this); if (targetItem) { - acceptDrag(event); - emit dropItems( getTabPath(targetItem), event->mimeData() ); + bool accepted = false; + emit dropItems( getTabPath(targetItem), event->mimeData(), &accepted ); + if (accepted) + acceptDrag(event); } else if ( itemAt(event->pos()) ) { const QString oldPrefix = getTabPath(current); diff --git a/src/gui/tabtree.h b/src/gui/tabtree.h index 7b5387cc3..33f7b642f 100644 --- a/src/gui/tabtree.h +++ b/src/gui/tabtree.h @@ -70,7 +70,7 @@ class TabTree final : public QTreeWidget, public TabsWidgetInterface void currentTabChanged(int index); void tabTreeMenuRequested(const QPoint &pos, const QString &groupPath); void tabsMoved(const QString &oldPrefix, const QString &newPrefix, const QList &indexes); - void dropItems(const QString &tabName, const QMimeData *data); + void dropItems(const QString &tabName, const QMimeData *data, bool *accepted); protected: void contextMenuEvent(QContextMenuEvent *event) override; diff --git a/src/gui/tabwidget.h b/src/gui/tabwidget.h index 6406d1224..3c23ef884 100644 --- a/src/gui/tabwidget.h +++ b/src/gui/tabwidget.h @@ -90,7 +90,7 @@ class TabWidget final : public QWidget void tabRenamed(const QString &newName, int index); void currentChanged(int tabIndex, int oldTabIndex); void tabCloseRequested(int); - void dropItems(const QString &tabName, const QMimeData *data); + void dropItems(const QString &tabName, const QMimeData *data, bool *accepted); protected: bool eventFilter(QObject *object, QEvent *event) override;