Added option to auto hide a DockWidget or a DockArea to a specific sidebar location
This commit is contained in:
@@ -53,11 +53,13 @@
|
||||
#include "DockFocusController.h"
|
||||
#include "ElidingLabel.h"
|
||||
#include "AutoHideDockContainer.h"
|
||||
#include "IconProvider.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace ads
|
||||
{
|
||||
static const char* const LocationProperty = "Location";
|
||||
|
||||
/**
|
||||
* Private data class of CDockAreaTitleBar class (pimpl)
|
||||
@@ -146,6 +148,19 @@ struct DockAreaTitleBarPrivate
|
||||
* Makes the dock area floating
|
||||
*/
|
||||
IFloatingWidget* makeAreaFloating(const QPoint& Offset, eDragState DragState);
|
||||
|
||||
/**
|
||||
* Helper function to create and initialize the menu entries for
|
||||
* the "Auto Hide Group To..." menu
|
||||
*/
|
||||
QAction* createAutoHideToAction(const QString& Title, SideBarLocation Location,
|
||||
QMenu* Menu)
|
||||
{
|
||||
auto Action = Menu->addAction(Title);
|
||||
Action->setProperty("Location", Location);
|
||||
QObject::connect(Action, &QAction::triggered, _this, &CDockAreaTitleBar::onAutoHideToActionClicked);
|
||||
return Action;
|
||||
}
|
||||
};// struct DockAreaTitleBarPrivate
|
||||
|
||||
//============================================================================
|
||||
@@ -511,6 +526,15 @@ void CDockAreaTitleBar::onAutoHideDockAreaActionClicked()
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::onAutoHideToActionClicked()
|
||||
{
|
||||
qDebug() << "CDockAreaTitleBar::onAutoHideToActionClicked()";
|
||||
int Location = sender()->property(LocationProperty).toInt();
|
||||
d->DockArea->toggleAutoHide((SideBarLocation)Location);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
QAbstractButton* CDockAreaTitleBar::button(TitleBarButton which) const
|
||||
{
|
||||
@@ -677,7 +701,18 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
Action = Menu.addAction(IsAutoHide ? tr("Dock") : tr("Auto Hide Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable));
|
||||
auto AreaIsPinnable = d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||
Action->setEnabled(AreaIsPinnable);
|
||||
|
||||
if (!IsAutoHide)
|
||||
{
|
||||
auto menu = Menu.addMenu(tr("Auto Hide Group To..."));
|
||||
menu->setEnabled(AreaIsPinnable);
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user