@@ -61,6 +61,7 @@ struct AutoHideTabPrivate
61
61
QPoint GlobalDragStartMousePosition;
62
62
QPoint DragStartMousePosition;
63
63
IFloatingWidget* FloatingWidget = nullptr ;
64
+ Qt::Orientation DragStartOrientation;
64
65
65
66
/* *
66
67
* Private data constructor
@@ -182,6 +183,7 @@ bool AutoHideTabPrivate::startFloating(eDragState DraggingState)
182
183
auto Size = DockArea->size ();
183
184
auto StartPos = DragStartMousePosition;
184
185
auto AutoHideContainer = DockWidget->autoHideDockContainer ();
186
+ DragStartOrientation = AutoHideContainer->orientation ();
185
187
switch (SideBar->sideBarLocation ())
186
188
{
187
189
case SideBarLeft:
@@ -373,13 +375,12 @@ bool CAutoHideTab::iconOnly() const
373
375
void CAutoHideTab::contextMenuEvent (QContextMenuEvent* ev)
374
376
{
375
377
ev->accept ();
376
- // d->saveDragStartMousePosition(ev->globalPos());
378
+ d->saveDragStartMousePosition (ev->globalPos ());
377
379
378
380
const bool isFloatable = d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable);
379
381
QAction* Action;
380
382
QMenu Menu (this );
381
383
382
-
383
384
Action = Menu.addAction (tr (" Detach" ), this , SLOT (setDockWidgetFloating ()));
384
385
Action->setEnabled (isFloatable);
385
386
auto IsPinnable = d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetPinnable);
@@ -392,33 +393,13 @@ void CAutoHideTab::contextMenuEvent(QContextMenuEvent* ev)
392
393
d->createAutoHideToAction (tr (" Right" ), SideBarRight, menu);
393
394
d->createAutoHideToAction (tr (" Bottom" ), SideBarBottom, menu);
394
395
395
- /* Menu.addSeparator();
396
- Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
397
- Action->setEnabled(isClosable());
398
- if (d->DockArea->openDockWidgetsCount() > 1)
399
- {
400
- Action = Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
401
- }*/
402
396
Menu.exec (ev->globalPos ());
403
397
}
404
398
405
399
406
400
// ============================================================================
407
401
void CAutoHideTab::setDockWidgetFloating ()
408
402
{
409
- /* auto DockArea = dockWidget()->dockAreaWidget();
410
- auto AutoHideContainer = dockWidget()->autoHideDockContainer();
411
- auto OriginalSize = AutoHideContainer->originalDockWidgetSize();
412
- auto DockAreaSize = DockArea->size();
413
- if (ads::internal::isHorizontalSideBarLocation(sideBarLocation()))
414
- {
415
- DockAreaSize.setHeight(OriginalSize.height());
416
- }
417
- else
418
- {
419
- DockAreaSize.setWidth(OriginalSize.width());
420
- }
421
- DockArea->resize(DockAreaSize);*/
422
403
dockWidget ()->setFloating ();
423
404
}
424
405
@@ -427,7 +408,6 @@ void CAutoHideTab::setDockWidgetFloating()
427
408
void CAutoHideTab::onAutoHideToActionClicked ()
428
409
{
429
410
int Location = sender ()->property (LocationProperty).toInt ();
430
- std::cout << " CAutoHideTab::onAutoHideToActionClicked " << Location << std::endl;
431
411
d->DockWidget ->setAutoHide (true , (SideBarLocation)Location);
432
412
}
433
413
@@ -484,15 +464,16 @@ void CAutoHideTab::mouseReleaseEvent(QMouseEvent* ev)
484
464
break ;
485
465
486
466
case DraggingFloatingWidget:
467
+ std::cout << " CAutoHideTab::mouseReleaseEvent" << std::endl;
487
468
ev->accept ();
488
469
d->FloatingWidget ->finishDragging ();
470
+ if (d->DockWidget ->isAutoHide () && d->DragStartOrientation != orientation ())
471
+ {
472
+ d->DockWidget ->autoHideDockContainer ()->resetToInitialDockWidgetSize ();
473
+ }
489
474
break ;
490
475
491
476
default :
492
- /* if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
493
- {
494
- d->focusController()->setDockWidgetTabPressed(false);
495
- }*/
496
477
break ; // do nothing
497
478
}
498
479
}
@@ -504,7 +485,6 @@ void CAutoHideTab::mouseReleaseEvent(QMouseEvent* ev)
504
485
// ============================================================================
505
486
void CAutoHideTab::mouseMoveEvent (QMouseEvent* ev)
506
487
{
507
- std::cout << " CAutoHideTab::mouseMoveEvent" << std::endl;
508
488
if (!(ev->buttons () & Qt::LeftButton) || d->isDraggingState (DraggingInactive))
509
489
{
510
490
d->DragState = DraggingInactive;
@@ -532,38 +512,19 @@ void CAutoHideTab::mouseMoveEvent(QMouseEvent* ev)
532
512
bool MouseOutsideBar = (MappedPos.x () < 0 ) || (MappedPos.x () > parentWidget ()->rect ().right ());
533
513
// Maybe a fixed drag distance is better here ?
534
514
int DragDistanceY = qAbs (d->GlobalDragStartMousePosition .y () - internal::globalPositionOf (ev).y ());
535
- std::cout << " DragDistanceY " << DragDistanceY << " MouseOutsideBar " << MouseOutsideBar << std::endl;
536
515
if (DragDistanceY >= CDockManager::startDragDistance () || MouseOutsideBar)
537
516
{
538
517
// Floating is only allowed for widgets that are floatable
539
518
// We can create the drag preview if the widget is movable.
540
519
auto Features = d->DockWidget ->features ();
541
520
if (Features.testFlag (CDockWidget::DockWidgetFloatable) || (Features.testFlag (CDockWidget::DockWidgetMovable)))
542
521
{
543
- // If we undock, we need to restore the initial position of this
544
- // tab because it looks strange if it remains on its dragged position
545
- /* if (d->isDraggingState(DraggingTab))
546
- {
547
- parentWidget()->layout()->update();
548
- }*/
549
522
d->startFloating ();
550
523
}
551
524
return ;
552
525
}
553
- /* else if (d->DockArea->openDockWidgetsCount() > 1
554
- && (internal::globalPositionOf(ev) - d->GlobalDragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
555
- {
556
- // If we start dragging the tab, we save its inital position to
557
- // restore it later
558
- if (DraggingTab != d->DragState)
559
- {
560
- d->TabDragStartPosition = this->pos();
561
- }
562
- d->DragState = DraggingTab;
563
- return;
564
- }*/
565
526
566
- Super::mouseMoveEvent (ev);
527
+ Super::mouseMoveEvent (ev);
567
528
}
568
529
569
530
0 commit comments