##// END OF EJS Templates
Fix for D&D bug on mac
Thibaud Rabillard -
r911:9102bdac4611
parent child
Show More
@@ -63,6 +63,10 public:
63 63 void setHightlightedDragWidget(VisualizationDragWidget *dragWidget);
64 64 VisualizationDragWidget *getHightlightedDragWidget() const;
65 65
66 /// Delays the closing of a widget during a drag&drop operation
67 void delayedCloseWidget(QWidget *widget);
68 void doCloseWidgets();
69
66 70 private:
67 71 class DragDropHelperPrivate;
68 72 spimpl::unique_impl_ptr<DragDropHelperPrivate> impl;
@@ -38,6 +38,8 struct DragDropHelper::DragDropHelperPrivate {
38 38 QMetaObject::Connection m_DragWidgetDestroyedConnection;
39 39 QMetaObject::Connection m_HighlightedWidgetDestroyedConnection;
40 40
41 QList<QWidget *> m_WidgetToClose;
42
41 43 explicit DragDropHelperPrivate()
42 44 : m_PlaceHolder{std::make_unique<QWidget>()},
43 45 m_DragDropScroller{std::make_unique<DragDropScroller>()},
@@ -209,6 +211,21 VisualizationDragWidget *DragDropHelper::getHightlightedDragWidget() const
209 211 return impl->m_HighlightedDragWidget;
210 212 }
211 213
214 void DragDropHelper::delayedCloseWidget(QWidget *widget)
215 {
216 widget->hide();
217 impl->m_WidgetToClose << widget;
218 }
219
220 void DragDropHelper::doCloseWidgets()
221 {
222 for (auto widget : impl->m_WidgetToClose) {
223 widget->close();
224 }
225
226 impl->m_WidgetToClose.clear();
227 }
228
212 229 bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData,
213 230 VisualizationDragDropContainer *dropContainer)
214 231 {
@@ -210,8 +210,9 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidg
210 210 // do not add the placeHolder
211 211 }
212 212
213 // Note: The exec() is blocking on windows but not on linux and macOS
214 drag->exec(Qt::MoveAction | Qt::CopyAction);
213 drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::MoveAction);
214
215 helper.doCloseWidgets();
215 216 }
216 217 else {
217 218 qCWarning(LOG_VisualizationDragDropContainer())
@@ -237,11 +237,11 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph(
237 237
238 238 if (nbGraph == 1) {
239 239 // This is the only graph in the previous zone, close the zone
240 graphWidget->parentZoneWidget()->close();
240 helper.delayedCloseWidget(graphWidget->parentZoneWidget());
241 241 }
242 242 else {
243 243 // Close the graph
244 graphWidget->close();
244 helper.delayedCloseWidget(graphWidget);
245 245 }
246 246
247 247 tabWidget->createZone(variables, index);
@@ -258,7 +258,7 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph(
258 258
259 259 // Close the old zone if it was the only graph inside
260 260 if (nbGraph == 1) {
261 parentZoneWidget->close();
261 helper.delayedCloseWidget(parentZoneWidget);
262 262 }
263 263 }
264 264 }
@@ -452,11 +452,11 void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph(
452 452 auto nbGraph = parentDragDropContainer->countDragWidget();
453 453 if (nbGraph == 1) {
454 454 // This is the only graph in the previous zone, close the zone
455 previousParentZoneWidget->close();
455 helper.delayedCloseWidget(previousParentZoneWidget);
456 456 }
457 457 else {
458 458 // Close the graph
459 graphWidget->close();
459 helper.delayedCloseWidget(graphWidget);
460 460 }
461 461
462 462 // Creates the new graph in the zone
General Comments 0
You need to be logged in to leave comments. Login now