Skip to content

Commit f00ef60

Browse files
Merge remote-tracking branch 'remotes/origin/autohide_drag'
2 parents 6e642ec + 1a1352e commit f00ef60

30 files changed

+1367
-216
lines changed

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,70 @@ integrated development environments (IDEs) such as Visual Studio.
2222

2323
## New and Noteworthy
2424

25+
Release [4.1](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/latest) significantly improves the Auto-Hide functionality and also brings improvements
26+
for Drag and Drop of dock widgets into dock area tabs. These are the highlights of the new version:
27+
28+
#### Drag & Drop to Auto-Hide
29+
30+
Now you can easily drag any dock widget or any floating widget to the
31+
borders of a window to pin it as a auto-hide tab in one of the 4 sidebars.
32+
If you drag a dock widget close the one of the four window borders, special
33+
drop overlays will be shown to indicate the drop area for auto-hide widgets:
34+
35+
![Auo-Hide drag to Sidebar](doc/AutoHide_Drag_to_Sidebar.gif)
36+
37+
Of course, this also works with dock areas:
38+
39+
![Auo-Hide drag Dock Area](doc/AutoHide_Drag_DockArea.gif)
40+
41+
If you drag a dock widget or dock area into a sidebar, then you even have
42+
control over where tabs are inserted. Simply drag your mouse over a specific
43+
auto-hide tab, and your dragged dock widget will be inserted before this tab.
44+
Drag to the sidebar area behind the last tab, and the dragged widget will be
45+
appended as last tab. In the following screen capture, the **Image Viewer 1** will
46+
be inserted before the **Table 0** Auto-Hide tab and the **Image Viewer 2**
47+
is appende behind the last tab:
48+
49+
![Auo-Hide tab insert order](doc/AutoHide_Tab_Insert_Order.gif)
50+
51+
#### Auto-Hide Tab Insertion Order
52+
53+
It is also possible to drag Auto-Hide tabs to a new auto-hide position.
54+
That means, you can drag them to a different border or sidebar:
55+
56+
![Auto-Hide change sidebar](doc/AutoHide_Change_Sidebar.gif)
57+
58+
#### Auto-Hide Tab Sorting
59+
60+
You can drag Auto-Hide tabs to a new position in the current sidebar
61+
to sort them:
62+
63+
![Auo-Hide sort tabs](doc/AutoHide_Sort_Tabs.gif)
64+
65+
#### Auto-Hide Drag to Float / Dock
66+
67+
But that is not all. You can also simply move Auto-Hide tabs to another
68+
floating widget or dock them via drag and drop:
69+
70+
![Auo-Hide drag to float or dock](doc/AutoHide_Drag_to_Float_or_Dock.gif)
71+
72+
#### Auto-Hide Context Menu
73+
74+
All Auto-Hide tabs now have a context menu, that provides all the functionality
75+
that you know from Dock widget tabs. With the **Pin To...** item from the
76+
context menu it is very easy to move an Auto-Hide tab to a different Auto-Hide
77+
sidebar:
78+
79+
![Auo-Hide context menu](doc/AutoHide_Context_Menu.png)
80+
81+
#### Dock Area Tab Insert Order
82+
83+
And last but not least the new version also improves the docking of widgets
84+
into the tabs of a Dock area. Just as with Auto-Hide tabs, you can now determine the position at which a tab is inserted by moving the mouse over an already existing tab (insertion before the tab) or behind the last tab
85+
(appending):
86+
87+
![Dock area tab insert order](doc/DockArea_Tab_Insertion_Order.gif)
88+
2589
The [release 4.0](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/latest)
2690
adds the following features:
2791

@@ -77,6 +141,12 @@ know it from Visual Studio.
77141
### Overview
78142

79143
- [New and Noteworthy](#new-and-noteworthy)
144+
- [Drag \& Drop to Auto-Hide](#drag--drop-to-auto-hide)
145+
- [Auto-Hide Tab Insertion Order](#auto-hide-tab-insertion-order)
146+
- [Auto-Hide Tab Sorting](#auto-hide-tab-sorting)
147+
- [Auto-Hide Drag to Float / Dock](#auto-hide-drag-to-float--dock)
148+
- [Auto-Hide Context Menu](#auto-hide-context-menu)
149+
- [Dock Area Tab Insert Order](#dock-area-tab-insert-order)
80150
- [Features](#features)
81151
- [Overview](#overview)
82152
- [Docking everywhere - no central widget](#docking-everywhere---no-central-widget)

demo/MainWindow.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ void MainWindowPrivate::createContent()
448448

449449
// For this Special Dock Area we want to avoid dropping on the center of it (i.e. we don't want this widget to be ever tabbified):
450450
{
451-
SpecialDockArea->setAllowedAreas(ads::OuterDockAreas);
452-
//SpecialDockArea->setAllowedAreas({ads::LeftDockWidgetArea, ads::RightDockWidgetArea}); // just for testing
451+
//SpecialDockArea->setAllowedAreas(ads::OuterDockAreas);
452+
SpecialDockArea->setAllowedAreas({ads::LeftDockWidgetArea, ads::RightDockWidgetArea, ads::TopDockWidgetArea}); // just for testing
453453
}
454454

455455
DockWidget = createLongTextLabelDockWidget();
@@ -517,7 +517,9 @@ void MainWindowPrivate::createContent()
517517

518518
// Test dock area docking
519519
auto RighDockArea = DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(), TopDockArea);
520-
DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
520+
DockWidget = createLongTextLabelDockWidget();
521+
DockWidget->setFeature(ads::CDockWidget::DockWidgetPinnable, false);
522+
DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget, RighDockArea);
521523
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
522524
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
523525
auto LabelDockWidget = createLongTextLabelDockWidget();

src/AutoHideDockContainer.cpp

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct AutoHideDockContainerPrivate
117117
CResizeHandle* ResizeHandle = nullptr;
118118
QSize Size; // creates invalid size
119119
QPointer<CAutoHideTab> SideTab;
120+
QSize SizeCache;
120121

121122
/**
122123
* Private data constructor
@@ -215,6 +216,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarL
215216
bool OpaqueResize = CDockManager::testConfigFlag(CDockManager::OpaqueSplitterResize);
216217
d->ResizeHandle->setOpaqueResize(OpaqueResize);
217218
d->Size = d->DockArea->size();
219+
d->SizeCache = DockWidget->size();
218220

219221
addDockWidget(DockWidget);
220222
parent->registerAutoHideWidget(this);
@@ -237,7 +239,6 @@ void CAutoHideDockContainer::updateSize()
237239
}
238240

239241
auto rect = dockContainerParent->contentRect();
240-
241242
switch (sideBarLocation())
242243
{
243244
case SideBarLocation::SideBarTop:
@@ -271,6 +272,15 @@ void CAutoHideDockContainer::updateSize()
271272
default:
272273
break;
273274
}
275+
276+
if (orientation() == Qt::Horizontal)
277+
{
278+
d->SizeCache.setHeight(this->height());
279+
}
280+
else
281+
{
282+
d->SizeCache.setWidth(this->width());
283+
}
274284
}
275285

276286
//============================================================================
@@ -294,7 +304,7 @@ CAutoHideDockContainer::~CAutoHideDockContainer()
294304
}
295305

296306
//============================================================================
297-
CAutoHideSideBar* CAutoHideDockContainer::sideBar() const
307+
CAutoHideSideBar* CAutoHideDockContainer::autoHideSideBar() const
298308
{
299309
if (d->SideTab)
300310
{
@@ -303,7 +313,7 @@ CAutoHideSideBar* CAutoHideDockContainer::sideBar() const
303313
else
304314
{
305315
auto DockContainer = dockContainer();
306-
return DockContainer ? DockContainer->sideTabBar(d->SideTabBarArea) : nullptr;
316+
return DockContainer ? DockContainer->autoHideSideBar(d->SideTabBarArea) : nullptr;
307317
}
308318
}
309319

@@ -344,6 +354,10 @@ void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget)
344354
}
345355
d->DockArea->addDockWidget(DockWidget);
346356
updateSize();
357+
// The dock area is not visible and will not update the size when updateSize()
358+
// is called for this auto hide container. Therefore we explicitely resize
359+
// it here. As soon as it will become visible, it will get the right size
360+
d->DockArea->resize(size());
347361
}
348362

349363

@@ -643,5 +657,56 @@ bool CAutoHideDockContainer::event(QEvent* event)
643657
return Super::event(event);
644658
}
645659

660+
661+
//============================================================================
662+
Qt::Orientation CAutoHideDockContainer::orientation() const
663+
{
664+
return ads::internal::isHorizontalSideBarLocation(d->SideTabBarArea)
665+
? Qt::Horizontal : Qt::Vertical;
666+
}
667+
668+
669+
//============================================================================
670+
void CAutoHideDockContainer::resetToInitialDockWidgetSize()
671+
{
672+
if (orientation() == Qt::Horizontal)
673+
{
674+
setSize(d->SizeCache.height());
675+
}
676+
else
677+
{
678+
setSize(d->SizeCache.width());
679+
}
680+
}
681+
682+
683+
//============================================================================
684+
void CAutoHideDockContainer::moveToNewSideBarLocation(SideBarLocation NewSideBarLocation,
685+
int TabIndex)
686+
{
687+
if (NewSideBarLocation == sideBarLocation() && TabIndex == this->tabIndex())
688+
{
689+
return;
690+
}
691+
692+
auto OldOrientation = orientation();
693+
auto SideBar = dockContainer()->autoHideSideBar(NewSideBarLocation);
694+
SideBar->addAutoHideWidget(this, TabIndex);
695+
// If we move a horizontal auto hide container to a vertical position
696+
// then we resize it to the orginal dock widget size, to avoid
697+
// an extremely streched dock widget after insertion
698+
if (SideBar->orientation() != OldOrientation)
699+
{
700+
resetToInitialDockWidgetSize();
701+
}
702+
}
703+
704+
705+
//============================================================================
706+
int CAutoHideDockContainer::tabIndex() const
707+
{
708+
return d->SideTab->tabIndex();
709+
}
710+
646711
}
647712

src/AutoHideDockContainer.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class ADS_EXPORT CAutoHideDockContainer : public QFrame
9393
/**
9494
* Get's the side tab bar
9595
*/
96-
CAutoHideSideBar* sideBar() const;
96+
CAutoHideSideBar* autoHideSideBar() const;
9797

9898
/**
9999
* Returns the side tab
@@ -105,6 +105,11 @@ class ADS_EXPORT CAutoHideDockContainer : public QFrame
105105
*/
106106
CDockWidget* dockWidget() const;
107107

108+
/**
109+
* Returns the index of this container in the sidebar
110+
*/
111+
int tabIndex() const;
112+
108113
/**
109114
* Adds a dock widget and removes the previous dock widget
110115
*/
@@ -166,6 +171,30 @@ class ADS_EXPORT CAutoHideDockContainer : public QFrame
166171
* of this auto hide container.
167172
*/
168173
void setSize(int Size);
174+
175+
/**
176+
* Resets the with or hight to the initial dock widget size dependinng on
177+
* the orientation.
178+
* If the orientation is Qt::Horizontal, then the height is reset to
179+
* the initial size and if orientation is Qt::Vertical, then the width is
180+
* reset to the initial size
181+
*/
182+
void resetToInitialDockWidgetSize();
183+
184+
/**
185+
* Returns orientation of this container.
186+
* Left and right containers have a Qt::Vertical orientation and top / bottom
187+
* containers have a Qt::Horizontal orientation.
188+
* The function returns the orientation of the corresponding auto hide
189+
* side bar.
190+
*/
191+
Qt::Orientation orientation() const;
192+
193+
/**
194+
* Removes the AutoHide container from the current side bar and adds
195+
* it to the new side bar given in SideBarLocation
196+
*/
197+
void moveToNewSideBarLocation(SideBarLocation SideBarLocation, int TabIndex = -1);
169198
};
170199
} // namespace ads
171200

0 commit comments

Comments
 (0)