@@ -61,6 +61,7 @@ struct AutoHideTabPrivate
6161 QPoint GlobalDragStartMousePosition;
6262 QPoint DragStartMousePosition;
6363 IFloatingWidget* FloatingWidget = nullptr ;
64+ Qt::Orientation DragStartOrientation;
6465
6566 /* *
6667 * Private data constructor
@@ -182,6 +183,7 @@ bool AutoHideTabPrivate::startFloating(eDragState DraggingState)
182183 auto Size = DockArea->size ();
183184 auto StartPos = DragStartMousePosition;
184185 auto AutoHideContainer = DockWidget->autoHideDockContainer ();
186+ DragStartOrientation = AutoHideContainer->orientation ();
185187 switch (SideBar->sideBarLocation ())
186188 {
187189 case SideBarLeft:
@@ -373,13 +375,12 @@ bool CAutoHideTab::iconOnly() const
373375void CAutoHideTab::contextMenuEvent (QContextMenuEvent* ev)
374376{
375377 ev->accept ();
376- // d->saveDragStartMousePosition(ev->globalPos());
378+ d->saveDragStartMousePosition (ev->globalPos ());
377379
378380 const bool isFloatable = d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable);
379381 QAction* Action;
380382 QMenu Menu (this );
381383
382-
383384 Action = Menu.addAction (tr (" Detach" ), this , SLOT (setDockWidgetFloating ()));
384385 Action->setEnabled (isFloatable);
385386 auto IsPinnable = d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetPinnable);
@@ -392,33 +393,13 @@ void CAutoHideTab::contextMenuEvent(QContextMenuEvent* ev)
392393 d->createAutoHideToAction (tr (" Right" ), SideBarRight, menu);
393394 d->createAutoHideToAction (tr (" Bottom" ), SideBarBottom, menu);
394395
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- }*/
402396 Menu.exec (ev->globalPos ());
403397}
404398
405399
406400// ============================================================================
407401void CAutoHideTab::setDockWidgetFloating ()
408402{
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);*/
422403 dockWidget ()->setFloating ();
423404}
424405
@@ -427,7 +408,6 @@ void CAutoHideTab::setDockWidgetFloating()
427408void CAutoHideTab::onAutoHideToActionClicked ()
428409{
429410 int Location = sender ()->property (LocationProperty).toInt ();
430- std::cout << " CAutoHideTab::onAutoHideToActionClicked " << Location << std::endl;
431411 d->DockWidget ->setAutoHide (true , (SideBarLocation)Location);
432412}
433413
@@ -484,15 +464,16 @@ void CAutoHideTab::mouseReleaseEvent(QMouseEvent* ev)
484464 break ;
485465
486466 case DraggingFloatingWidget:
467+ std::cout << " CAutoHideTab::mouseReleaseEvent" << std::endl;
487468 ev->accept ();
488469 d->FloatingWidget ->finishDragging ();
470+ if (d->DockWidget ->isAutoHide () && d->DragStartOrientation != orientation ())
471+ {
472+ d->DockWidget ->autoHideDockContainer ()->resetToInitialDockWidgetSize ();
473+ }
489474 break ;
490475
491476 default :
492- /* if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
493- {
494- d->focusController()->setDockWidgetTabPressed(false);
495- }*/
496477 break ; // do nothing
497478 }
498479 }
@@ -504,7 +485,6 @@ void CAutoHideTab::mouseReleaseEvent(QMouseEvent* ev)
504485// ============================================================================
505486void CAutoHideTab::mouseMoveEvent (QMouseEvent* ev)
506487{
507- std::cout << " CAutoHideTab::mouseMoveEvent" << std::endl;
508488 if (!(ev->buttons () & Qt::LeftButton) || d->isDraggingState (DraggingInactive))
509489 {
510490 d->DragState = DraggingInactive;
@@ -532,38 +512,19 @@ void CAutoHideTab::mouseMoveEvent(QMouseEvent* ev)
532512 bool MouseOutsideBar = (MappedPos.x () < 0 ) || (MappedPos.x () > parentWidget ()->rect ().right ());
533513 // Maybe a fixed drag distance is better here ?
534514 int DragDistanceY = qAbs (d->GlobalDragStartMousePosition .y () - internal::globalPositionOf (ev).y ());
535- std::cout << " DragDistanceY " << DragDistanceY << " MouseOutsideBar " << MouseOutsideBar << std::endl;
536515 if (DragDistanceY >= CDockManager::startDragDistance () || MouseOutsideBar)
537516 {
538517 // Floating is only allowed for widgets that are floatable
539518 // We can create the drag preview if the widget is movable.
540519 auto Features = d->DockWidget ->features ();
541520 if (Features.testFlag (CDockWidget::DockWidgetFloatable) || (Features.testFlag (CDockWidget::DockWidgetMovable)))
542521 {
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- }*/
549522 d->startFloating ();
550523 }
551524 return ;
552525 }
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- }*/
565526
566- Super::mouseMoveEvent (ev);
527+ Super::mouseMoveEvent (ev);
567528}
568529
569530
0 commit comments