##// END OF EJS Templates
Fixed Drag&Drop issue on some platforms and made more consistent plugin install path with Meson...
jeandet -
r1397:348e733132e4
parent child
Show More
@@ -28,9 +28,10 else
28 28 endif
29 29
30 30 app_libs = []
31
31 cpp_args = []
32 32 if 'static' == get_option('default_library')
33 33 app_libs = [ sciqlop_amdaplugin, sciqlop_mockplugin]
34 cpp_args += ['-DQT_STATICPLUGIN']
34 35 endif
35 36
36 37 sciqlop_app = executable('sciqlop',
@@ -39,7 +40,7 sciqlop_app = executable('sciqlop',
39 40 rc,
40 41 include_directories : [ app_inc],
41 42 link_with: app_libs,
43 cpp_args: cpp_args,
42 44 dependencies : [sciqlop_gui, sciqlop_core],
43 45 install : true
44 46 )
45
@@ -5,7 +5,6 meson --prefix=/usr ..
5 5 ninja
6 6 DESTDIR=AppDir ninja install
7 7 mv AppDir/usr/lib64 AppDir/usr/lib
8 mv AppDir/usr/lib/*plugin.so AppDir/usr/bin/
9 8 wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
10 9 chmod +x linuxdeployqt-continuous-x86_64.AppImage && ./linuxdeployqt-continuous-x86_64.AppImage --appimage-extract
11 10 LD_LIBRARY_PATH=AppDir/usr/lib64/ ./squashfs-root/AppRun AppDir/usr/share/applications/*.desktop -appimage
@@ -16,7 +16,8 Q_LOGGING_CATEGORY(LOG_VisualizationDragDropContainer, "VisualizationDragDropCon
16 16
17 17 auto DRAGGED_MINIATURE_WIDTH = 200; // in pixels
18 18
19 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
19 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate
20 {
20 21
21 22 QVBoxLayout *m_Layout;
22 23 QHash<QString, VisualizationDragDropContainer::DropBehavior> m_AcceptedMimeTypes;
@@ -40,23 +41,27 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
40 41 bool acceptMimeData(const QMimeData *data) const
41 42 {
42 43 auto accepted = false;
43 for (auto it = m_AcceptedMimeTypes.constBegin(); it != m_AcceptedMimeTypes.constEnd();
44 ++it) {
44 for (auto it = m_AcceptedMimeTypes.constBegin(); it != m_AcceptedMimeTypes.constEnd(); ++it)
45 {
45 46 const auto &type = it.key();
46 47 const auto &behavior = it.value();
47 48
48 if (data->hasFormat(type)) {
49 if (behavior != DropBehavior::Forbidden) {
49 if (data->hasFormat(type))
50 {
51 if (behavior != DropBehavior::Forbidden)
52 {
50 53 accepted = true;
51 54 }
52 else {
55 else
56 {
53 57 accepted = false;
54 58 break;
55 59 }
56 60 }
57 61 }
58 62
59 if (accepted) {
63 if (accepted)
64 {
60 65 accepted = m_AcceptMimeDataFun(data);
61 66 }
62 67
@@ -66,17 +71,19 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
66 71 bool allowMergeForMimeData(const QMimeData *data) const
67 72 {
68 73 auto result = false;
69 for (auto it = m_AcceptedMimeTypes.constBegin(); it != m_AcceptedMimeTypes.constEnd();
70 ++it) {
74 for (auto it = m_AcceptedMimeTypes.constBegin(); it != m_AcceptedMimeTypes.constEnd(); ++it)
75 {
71 76
72 77 if (data->hasFormat(it.key())
73 78 && (it.value() == VisualizationDragDropContainer::DropBehavior::Merged
74 79 || it.value()
75 == VisualizationDragDropContainer::DropBehavior::InsertedAndMerged)) {
80 == VisualizationDragDropContainer::DropBehavior::InsertedAndMerged))
81 {
76 82 result = true;
77 83 }
78 84 else if (data->hasFormat(it.key())
79 && it.value() == VisualizationDragDropContainer::DropBehavior::Inserted) {
85 && it.value() == VisualizationDragDropContainer::DropBehavior::Inserted)
86 {
80 87 // Merge is forbidden if the mime data contain an acceptable type which cannot be
81 88 // merged
82 89 result = false;
@@ -89,12 +96,13 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
89 96
90 97 bool allowInsertForMimeData(const QMimeData *data) const
91 98 {
92 for (auto it = m_AcceptedMimeTypes.constBegin(); it != m_AcceptedMimeTypes.constEnd();
93 ++it) {
99 for (auto it = m_AcceptedMimeTypes.constBegin(); it != m_AcceptedMimeTypes.constEnd(); ++it)
100 {
94 101 if (data->hasFormat(it.key())
95 102 && (it.value() == VisualizationDragDropContainer::DropBehavior::Inserted
96 103 || it.value()
97 == VisualizationDragDropContainer::DropBehavior::InsertedAndMerged)) {
104 == VisualizationDragDropContainer::DropBehavior::InsertedAndMerged))
105 {
98 106 return true;
99 107 }
100 108 }
@@ -112,10 +120,13 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
112 120 {
113 121 VisualizationDragWidget *dragWidget = nullptr;
114 122
115 for (auto child : parent->children()) {
123 for (auto child : parent->children())
124 {
116 125 auto widget = qobject_cast<VisualizationDragWidget *>(child);
117 if (widget && widget->isVisible()) {
118 if (widget->frameGeometry().contains(pos)) {
126 if (widget && widget->isVisible())
127 {
128 if (widget->frameGeometry().contains(pos))
129 {
119 130 dragWidget = widget;
120 131 break;
121 132 }
@@ -135,9 +146,12 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
135 146 int countDragWidget(const QWidget *parent, bool onlyVisible = false) const
136 147 {
137 148 auto nbGraph = 0;
138 for (auto child : parent->children()) {
139 if (qobject_cast<VisualizationDragWidget *>(child)) {
140 if (!onlyVisible || qobject_cast<VisualizationDragWidget *>(child)->isVisible()) {
149 for (auto child : parent->children())
150 {
151 if (qobject_cast<VisualizationDragWidget*>(child))
152 {
153 if (!onlyVisible || qobject_cast<VisualizationDragWidget*>(child)->isVisible())
154 {
141 155 nbGraph += 1;
142 156 }
143 157 }
@@ -151,8 +165,8 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
151 165 };
152 166
153 167 VisualizationDragDropContainer::VisualizationDragDropContainer(QWidget *parent)
154 : QFrame{parent},
155 impl{spimpl::make_unique_impl<VisualizationDragDropContainerPrivate>(this)}
168 : QFrame { parent }
169 , impl { spimpl::make_unique_impl<VisualizationDragDropContainerPrivate>(this) }
156 170 {
157 171 setAcceptDrops(true);
158 172 }
@@ -165,8 +179,8 void VisualizationDragDropContainer::addDragWidget(VisualizationDragWidget *drag
165 179 &VisualizationDragDropContainer::startDrag);
166 180 }
167 181
168 void VisualizationDragDropContainer::insertDragWidget(int index,
169 VisualizationDragWidget *dragWidget)
182 void VisualizationDragDropContainer::insertDragWidget(
183 int index, VisualizationDragWidget* dragWidget)
170 184 {
171 185 impl->m_Layout->insertWidget(index, dragWidget);
172 186 disconnect(dragWidget, &VisualizationDragWidget::dragDetected, nullptr, nullptr);
@@ -197,15 +211,15 void VisualizationDragDropContainer::setAcceptDragWidgetFunction(
197 211 impl->m_AcceptDragWidgetFun = fun;
198 212 }
199 213
200 void VisualizationDragDropContainer::setPlaceHolderType(DragDropGuiController::PlaceHolderType type,
201 const QString &placeHolderText)
214 void VisualizationDragDropContainer::setPlaceHolderType(
215 DragDropGuiController::PlaceHolderType type, const QString& placeHolderText)
202 216 {
203 217 impl->m_PlaceHolderType = type;
204 218 impl->m_PlaceHolderText = placeHolderText;
205 219 }
206 220
207 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidget,
208 const QPoint &dragPosition)
221 void VisualizationDragDropContainer::startDrag(
222 VisualizationDragWidget* dragWidget, const QPoint& dragPosition)
209 223 {
210 224 auto &helper = sqpApp->dragDropGuiController();
211 225 helper.resetDragAndDrop();
@@ -217,7 +231,8 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidg
217 231 drag->setMimeData(mimeData);
218 232
219 233 auto pixmap = dragWidget->customDragPixmap(dragPosition);
220 if (pixmap.isNull()) {
234 if (pixmap.isNull())
235 {
221 236 pixmap = QPixmap{dragWidget->size()};
222 237 dragWidget->render(&pixmap);
223 238 }
@@ -229,18 +244,22 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidg
229 244 mimeData->setImageData(image);
230 245 mimeData->setUrls({helper.imageTemporaryUrl(image)});
231 246
232 if (impl->m_Layout->indexOf(dragWidget) >= 0) {
247 if (impl->m_Layout->indexOf(dragWidget) >= 0)
248 {
233 249
234 if (impl->acceptMimeData(mimeData) && impl->allowInsertForMimeData(mimeData)) {
250 if (impl->acceptMimeData(mimeData) && impl->allowInsertForMimeData(mimeData))
251 {
235 252 helper.setCurrentDragWidget(dragWidget);
236 253
237 if (impl->cursorIsInContainer(this)) {
254 if (impl->cursorIsInContainer(this))
255 {
238 256 auto dragWidgetIndex = impl->m_Layout->indexOf(dragWidget);
239 257 helper.insertPlaceHolder(impl->m_Layout, dragWidgetIndex, impl->m_PlaceHolderType,
240 258 impl->m_PlaceHolderText);
241 259 dragWidget->setVisible(false);
242 260 }
243 else {
261 else
262 {
244 263 // The drag starts directly outside the drop zone
245 264 // do not add the placeHolder
246 265 }
@@ -250,7 +269,8 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidg
250 269
251 270 helper.doCloseWidgets();
252 271 }
253 else {
272 else
273 {
254 274 qCWarning(LOG_VisualizationDragDropContainer())
255 275 << tr("VisualizationDragDropContainer::startDrag, drag aborted, the specified "
256 276 "VisualizationDragWidget is not found in this container.");
@@ -259,36 +279,43 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidg
259 279
260 280 void VisualizationDragDropContainer::dragEnterEvent(QDragEnterEvent *event)
261 281 {
262 if (impl->acceptMimeData(event->mimeData())) {
282 if (impl->acceptMimeData(event->mimeData()))
283 {
263 284 event->acceptProposedAction();
264 285
265 286 auto &helper = sqpApp->dragDropGuiController();
266 287
267 if (!impl->hasPlaceHolder()) {
288 if (!impl->hasPlaceHolder())
289 {
268 290 auto dragWidget = helper.getCurrentDragWidget();
269 291
270 if (dragWidget) {
292 if (dragWidget)
293 {
271 294 // If the drag&drop is internal to the visualization, entering the container hide
272 295 // the dragWidget which was made visible by the dragLeaveEvent
273 296 auto parentWidget
274 297 = qobject_cast<VisualizationDragDropContainer *>(dragWidget->parentWidget());
275 if (parentWidget) {
298 if (parentWidget)
299 {
276 300 dragWidget->setVisible(false);
277 301 }
278 302 }
279 303
280 304 auto canMerge = impl->allowMergeForMimeData(event->mimeData());
281 305 auto canInsert = impl->allowInsertForMimeData(event->mimeData());
282 if (!impl->findPlaceHolderPosition(event->pos(), event->mimeData(), canInsert, canMerge,
283 this)) {
306 if (!impl->findPlaceHolderPosition(
307 event->pos(), event->mimeData(), canInsert, canMerge, this))
308 {
284 309 event->ignore();
285 310 }
286 311 }
287 else {
312 else
313 {
288 314 // do nothing
289 315 }
290 316 }
291 else {
317 else
318 {
292 319 event->ignore();
293 320 }
294 321
@@ -301,24 +328,28 void VisualizationDragDropContainer::dragLeaveEvent(QDragLeaveEvent *event)
301 328
302 329 auto &helper = sqpApp->dragDropGuiController();
303 330
304 if (!impl->cursorIsInContainer(this)) {
331 if (!impl->cursorIsInContainer(this))
332 {
305 333 helper.removePlaceHolder();
306 334 helper.setHightlightedDragWidget(nullptr);
307 335 impl->m_MinContainerHeight = 0;
308 336
309 337 auto dragWidget = helper.getCurrentDragWidget();
310 if (dragWidget) {
338 if (dragWidget)
339 {
311 340 // dragWidget has a value only if the drag is started from the visualization
312 341 // In that case, shows the drag widget at its original place
313 342 // So the drag widget doesn't stay hidden if the drop occurs outside the visualization
314 343 // drop zone (It is not possible to catch a drop event outside of the application)
315 344
316 if (dragWidget) {
345 if (dragWidget)
346 {
317 347 dragWidget->setVisible(true);
318 348 }
319 349 }
320 350 }
321 else {
351 else
352 {
322 353 // Leave event probably received for a child widget.
323 354 // Do nothing.
324 355 // Note: The DragLeave event, doesn't have any mean to determine who sent it.
@@ -329,12 +360,15 void VisualizationDragDropContainer::dragLeaveEvent(QDragLeaveEvent *event)
329 360
330 361 void VisualizationDragDropContainer::dragMoveEvent(QDragMoveEvent *event)
331 362 {
332 if (impl->acceptMimeData(event->mimeData())) {
363 if (impl->acceptMimeData(event->mimeData()))
364 {
365 event->acceptProposedAction();
333 366 auto canMerge = impl->allowMergeForMimeData(event->mimeData());
334 367 auto canInsert = impl->allowInsertForMimeData(event->mimeData());
335 368 impl->findPlaceHolderPosition(event->pos(), event->mimeData(), canInsert, canMerge, this);
336 369 }
337 else {
370 else
371 {
338 372 event->ignore();
339 373 }
340 374
@@ -345,18 +379,23 void VisualizationDragDropContainer::dropEvent(QDropEvent *event)
345 379 {
346 380 auto &helper = sqpApp->dragDropGuiController();
347 381
348 if (impl->acceptMimeData(event->mimeData())) {
382 if (impl->acceptMimeData(event->mimeData()))
383 {
349 384 auto dragWidget = helper.getCurrentDragWidget();
350 if (impl->hasPlaceHolder()) {
385 if (impl->hasPlaceHolder())
386 {
351 387 // drop where the placeHolder is located
352 388
353 389 auto canInsert = impl->allowInsertForMimeData(event->mimeData());
354 if (canInsert) {
390 if (canInsert)
391 {
355 392 auto droppedIndex = impl->m_Layout->indexOf(&helper.placeHolder());
356 393
357 if (dragWidget) {
394 if (dragWidget)
395 {
358 396 auto dragWidgetIndex = impl->m_Layout->indexOf(dragWidget);
359 if (dragWidgetIndex >= 0 && dragWidgetIndex < droppedIndex) {
397 if (dragWidgetIndex >= 0 && dragWidgetIndex < droppedIndex)
398 {
360 399 // Correction of the index if the drop occurs in the same container
361 400 // and if the drag is started from the visualization (in that case, the
362 401 // dragWidget is hidden)
@@ -372,22 +411,26 void VisualizationDragDropContainer::dropEvent(QDropEvent *event)
372 411
373 412 emit dropOccuredInContainer(droppedIndex, event->mimeData());
374 413 }
375 else {
414 else
415 {
376 416 qCWarning(LOG_VisualizationDragDropContainer()) << tr(
377 417 "VisualizationDragDropContainer::dropEvent, dropping on the placeHolder, but "
378 418 "the insertion is forbidden.");
379 419 Q_ASSERT(false);
380 420 }
381 421 }
382 else if (helper.getHightlightedDragWidget()) {
422 else if (helper.getHightlightedDragWidget())
423 {
383 424 // drop on the highlighted widget
384 425
385 426 auto canMerge = impl->allowMergeForMimeData(event->mimeData());
386 if (canMerge) {
427 if (canMerge)
428 {
387 429 event->acceptProposedAction();
388 430 emit dropOccuredOnWidget(helper.getHightlightedDragWidget(), event->mimeData());
389 431 }
390 else {
432 else
433 {
391 434 qCWarning(LOG_VisualizationDragDropContainer())
392 435 << tr("VisualizationDragDropContainer::dropEvent, dropping on a widget, but "
393 436 "the merge is forbidden.");
@@ -395,7 +438,8 void VisualizationDragDropContainer::dropEvent(QDropEvent *event)
395 438 }
396 439 }
397 440 }
398 else {
441 else
442 {
399 443 event->ignore();
400 444 }
401 445
@@ -415,15 +459,19 bool VisualizationDragDropContainer::VisualizationDragDropContainerPrivate::find
415 459 auto absPos = container->mapToGlobal(pos);
416 460 auto isOnPlaceHolder = helper.placeHolder().isAncestorOf(sqpApp->widgetAt(absPos));
417 461
418 if (countDragWidget(container, true) == 0) {
462 if (countDragWidget(container, true) == 0)
463 {
419 464 // Drop on an empty container, just add the placeHolder at the top
420 465 helper.insertPlaceHolder(m_Layout, 0, m_PlaceHolderType, m_PlaceHolderText);
421 466 }
422 else if (!isOnPlaceHolder) {
467 else if (!isOnPlaceHolder)
468 {
423 469 auto nbDragWidget = countDragWidget(container);
424 if (nbDragWidget > 0) {
470 if (nbDragWidget > 0)
471 {
425 472
426 if (m_MinContainerHeight == 0) {
473 if (m_MinContainerHeight == 0)
474 {
427 475 m_MinContainerHeight = container->size().height();
428 476 }
429 477
@@ -444,14 +492,18 bool VisualizationDragDropContainer::VisualizationDragDropContainerPrivate::find
444 492
445 493 auto acceptMerge = m_AcceptDragWidgetFun(dragWidgetHovered, mimeData);
446 494
447 if (canInsert && (isOnTop || isOnBottom || !canMerge || !acceptMerge)) {
448 if (posY > (dropIndex + 1) * graphHeight - graphHeight / 2.0) {
495 if (canInsert && (isOnTop || isOnBottom || !canMerge || !acceptMerge))
496 {
497 if (posY > (dropIndex + 1) * graphHeight - graphHeight / 2.0)
498 {
449 499 dropIndex += 1;
450 500 }
451 501
452 if (helper.getCurrentDragWidget()) {
502 if (helper.getCurrentDragWidget())
503 {
453 504 auto dragWidgetIndex = m_Layout->indexOf(helper.getCurrentDragWidget());
454 if (dragWidgetIndex >= 0 && dragWidgetIndex <= dropIndex) {
505 if (dragWidgetIndex >= 0 && dragWidgetIndex <= dropIndex)
506 {
455 507 // Correction of the index if the drop occurs in the same container
456 508 // and if the drag is started from the visualization (in that case, the
457 509 // dragWidget is hidden)
@@ -459,35 +511,41 bool VisualizationDragDropContainer::VisualizationDragDropContainerPrivate::find
459 511 }
460 512 }
461 513
462 if (dropIndex != placeHolderIndex) {
463 helper.insertPlaceHolder(m_Layout, dropIndex, m_PlaceHolderType,
464 m_PlaceHolderText);
514 if (dropIndex != placeHolderIndex)
515 {
516 helper.insertPlaceHolder(
517 m_Layout, dropIndex, m_PlaceHolderType, m_PlaceHolderText);
465 518 }
466 519
467 520 helper.setHightlightedDragWidget(nullptr);
468 521 }
469 else if (canMerge && dragWidgetHovered) {
522 else if (canMerge && dragWidgetHovered)
523 {
470 524 // drop on the middle -> merge
471 if (hasPlaceHolder()) {
525 if (hasPlaceHolder())
526 {
472 527 helper.removePlaceHolder();
473 528 }
474 529
475 530 helper.setHightlightedDragWidget(dragWidgetHovered);
476 531 }
477 else {
532 else
533 {
478 534 qCWarning(LOG_VisualizationDragDropContainer())
479 535 << tr("VisualizationDragDropContainer::findPlaceHolderPosition, no valid drop "
480 536 "action.");
481 537 }
482 538 }
483 else {
539 else
540 {
484 541 qCInfo(LOG_VisualizationDragDropContainer())
485 542 << tr("VisualizationDragDropContainer::findPlaceHolderPosition, no widget "
486 543 "found in the "
487 544 "container");
488 545 }
489 546 }
490 else {
547 else
548 {
491 549 // the mouse is hover the placeHolder
492 550 // Do nothing
493 551 }
1 NO CONTENT: modified file
@@ -30,13 +30,21 amdaplugin_prep_files = qt5.preprocess(moc_headers : amdaplugin_moc_headers,
30 30 qresources : amdaplugin_resources_files,
31 31 ui_files : amdaplugin_ui_files)
32 32
33 cpp_args = ['-DAMDA_LIB','-DQT_PLUGIN']
34 message('======================='+get_option('default_library')+'==========================')
35 if(get_option('default_library') == 'static')
36 message('building amda plugin as static lib')
37 cpp_args += ['-DQT_STATICPLUGIN']
38 endif
39
33 40 sciqlop_amdaplugin = library('amdaplugin',
34 41 amdaplugin_sources,
35 42 amdaplugin_prep_files,
36 cpp_args : ['-DAMDA_LIB','-DQT_PLUGIN'],
43 cpp_args : cpp_args,
37 44 include_directories : [amdaplugin_inc],
38 45 dependencies : [sciqlop_core, sciqlop_gui],
39 install : true
46 install : true,
47 install_dir : join_paths(get_option('libdir'), 'SciQLop')
40 48 )
41 49
42 50
@@ -22,11 +22,17 gen = generator(moc,
22 22
23 23 mockplugin_moc_files = gen.process(mockplugin_moc_headers)
24 24
25 cpp_args = ['-DMOCKPLUGIN_LIB','-DQT_PLUGIN']
26 if(get_option('default_library')=='static')
27 cpp_args += ['-DQT_STATICPLUGIN']
28 endif
29
25 30 sciqlop_mockplugin = library('mockplugin',
26 31 mockplugin_sources,
27 32 mockplugin_moc_files,
28 cpp_args : '-DMOCKPLUGIN_LIB',
33 cpp_args : cpp_args,
29 34 include_directories : [mockplugin_inc],
30 35 dependencies : [sciqlop_core, sciqlop_gui],
31 install : true
36 install : true,
37 install_dir : join_paths(get_option('libdir'), 'SciQLop')
32 38 )
General Comments 0
You need to be logged in to leave comments. Login now