mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-24 05:22:06 +08:00
Added support for auto hiding a dock area / widget to a specific border via context menu
This commit is contained in:
parent
04ea1c68a7
commit
409d4489cc
@ -655,6 +655,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
// uncomment the following line to enable focus highlighting of the dock
|
||||
// widget that has the focus
|
||||
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||
CDockManager::setConfigFlag(CDockManager::AlwaysShowTabs, true);
|
||||
|
||||
// uncomment if you would like to enable dock widget auto hiding
|
||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
||||
|
@ -150,9 +150,6 @@ public:
|
||||
* Setter for spacing property - sets the spacing
|
||||
*/
|
||||
void setSpacing(int Spacing);
|
||||
|
||||
Q_SIGNALS:
|
||||
void sideTabAutoHideToggleRequested();
|
||||
};
|
||||
} // namespace ads
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -689,22 +689,22 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
return;
|
||||
}
|
||||
|
||||
bool IsAutoHide = d->DockArea->isAutoHide();
|
||||
bool IsTopLevelArea = d->DockArea->isTopLevelArea();
|
||||
const bool isAutoHide = d->DockArea->isAutoHide();
|
||||
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
|
||||
QAction* Action;
|
||||
QMenu Menu(this);
|
||||
if (!IsTopLevelArea)
|
||||
if (!isTopLevelArea)
|
||||
{
|
||||
Action = Menu.addAction(IsAutoHide ? tr("Detach") : tr("Detach Group"),
|
||||
Action = Menu.addAction(isAutoHide ? tr("Detach") : tr("Detach Group"),
|
||||
this, SLOT(onUndockButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
Action = Menu.addAction(IsAutoHide ? tr("Dock") : tr("Auto Hide Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
|
||||
Action = Menu.addAction(isAutoHide ? tr("Dock") : tr("Auto Hide Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
|
||||
auto AreaIsPinnable = d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||
Action->setEnabled(AreaIsPinnable);
|
||||
|
||||
if (!IsAutoHide)
|
||||
if (!isAutoHide)
|
||||
{
|
||||
auto menu = Menu.addMenu(tr("Auto Hide Group To..."));
|
||||
menu->setEnabled(AreaIsPinnable);
|
||||
@ -716,12 +716,11 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
}
|
||||
Menu.addSeparator();
|
||||
}
|
||||
Action = Menu.addAction(IsAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||
Action = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
if (!IsAutoHide)
|
||||
if (!isAutoHide && !isTopLevelArea)
|
||||
{
|
||||
Action = Menu.addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
|
||||
Action->setEnabled(!IsTopLevelArea);
|
||||
}
|
||||
Menu.exec(ev->globalPos());
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
||||
{
|
||||
setCurrentDockWidget(NextOpenDockWidget);
|
||||
}
|
||||
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() >= 1) // Don't remove empty dock areas that are auto hidden, they'll be deleted by the auto hide dock
|
||||
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() >= 1)
|
||||
{
|
||||
ADS_PRINT("Dock Area empty");
|
||||
DockContainer->removeDockArea(this);
|
||||
@ -827,22 +827,20 @@ void CDockAreaWidget::updateTitleBarVisibility()
|
||||
return;
|
||||
}
|
||||
|
||||
if (CDockManager::testConfigFlag(CDockManager::AlwaysShowTabs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!d->TitleBar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating()
|
||||
|| CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar));
|
||||
Hidden |= (d->Flags.testFlag(HideSingleWidgetTitleBar) && openDockWidgetsCount() == 1);
|
||||
bool IsAutoHide = isAutoHide();
|
||||
Hidden &= !IsAutoHide; // Titlebar must always be visible when auto hidden so it can be dragged
|
||||
d->TitleBar->setVisible(!Hidden);
|
||||
bool IsAutoHide = isAutoHide();
|
||||
if (!CDockManager::testConfigFlag(CDockManager::AlwaysShowTabs))
|
||||
{
|
||||
bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating()
|
||||
|| CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar));
|
||||
Hidden |= (d->Flags.testFlag(HideSingleWidgetTitleBar) && openDockWidgetsCount() == 1);
|
||||
Hidden &= !IsAutoHide; // Titlebar must always be visible when auto hidden so it can be dragged
|
||||
d->TitleBar->setVisible(!Hidden);
|
||||
}
|
||||
|
||||
if (isAutoHideFeatureEnabled())
|
||||
{
|
||||
|
@ -518,32 +518,40 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
||||
}
|
||||
|
||||
d->saveDragStartMousePosition(ev->globalPos());
|
||||
QMenu Menu(this);
|
||||
|
||||
const bool isFloatable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable);
|
||||
const bool isNotOnlyTabInContainer = !d->DockArea->dockContainer()->hasTopLevelDockWidget();
|
||||
|
||||
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
|
||||
const bool isDetachable = isFloatable && isNotOnlyTabInContainer;
|
||||
QAction* Action;
|
||||
QMenu Menu(this);
|
||||
|
||||
auto Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
|
||||
Action->setEnabled(isDetachable);
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
if (!isTopLevelArea)
|
||||
{
|
||||
Action = Menu.addAction(tr("Auto Hide"), this, SLOT(autoHideDockWidget()));
|
||||
auto IsPinnable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||
Action->setEnabled(IsPinnable);
|
||||
Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
|
||||
Action->setEnabled(isDetachable);
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
Action = Menu.addAction(tr("Auto Hide"), this, SLOT(autoHideDockWidget()));
|
||||
auto IsPinnable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||
Action->setEnabled(IsPinnable);
|
||||
|
||||
auto menu = Menu.addMenu(tr("Auto Hide To..."));
|
||||
menu->setEnabled(IsPinnable);
|
||||
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
||||
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
||||
d->createAutoHideToAction(tr("Right"), SideBarRight, menu);
|
||||
d->createAutoHideToAction(tr("Bottom"), SideBarBottom, menu);
|
||||
auto menu = Menu.addMenu(tr("Auto Hide To..."));
|
||||
menu->setEnabled(IsPinnable);
|
||||
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
||||
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
||||
d->createAutoHideToAction(tr("Right"), SideBarRight, menu);
|
||||
d->createAutoHideToAction(tr("Bottom"), SideBarBottom, menu);
|
||||
}
|
||||
}
|
||||
|
||||
Menu.addSeparator();
|
||||
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
||||
Action->setEnabled(isClosable());
|
||||
Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
|
||||
if (d->DockArea->openDockWidgetsCount() > 1)
|
||||
{
|
||||
Action = Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
|
||||
}
|
||||
Menu.exec(ev->globalPos());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user