mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Improved context menu of DockAreaWidget
This commit is contained in:
parent
b5a179555a
commit
d2c08aca70
@ -665,21 +665,27 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
}
|
||||
|
||||
bool IsAutoHide = d->DockArea->isAutoHide();
|
||||
bool IsTopLevelArea = d->DockArea->isTopLevelArea();
|
||||
QAction* Action;
|
||||
QMenu Menu(this);
|
||||
auto 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(onAutoHideDockAreaClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable));
|
||||
}
|
||||
Menu.addSeparator();
|
||||
if (!IsTopLevelArea)
|
||||
{
|
||||
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(onAutoHideDockAreaClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable));
|
||||
}
|
||||
Menu.addSeparator();
|
||||
}
|
||||
Action = Menu.addAction(IsAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
if (!IsAutoHide)
|
||||
{
|
||||
Menu.addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
|
||||
Action = Menu.addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
|
||||
Action->setEnabled(!IsTopLevelArea);
|
||||
}
|
||||
Menu.exec(ev->globalPos());
|
||||
}
|
||||
|
@ -1405,6 +1405,19 @@ void CDockAreaWidget::onDockWidgetFeaturesChanged()
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
bool CDockAreaWidget::isTopLevelArea() const
|
||||
{
|
||||
auto Container = dockContainer();
|
||||
if (!Container)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (Container->topLevelDockArea() == this);
|
||||
}
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
//============================================================================
|
||||
bool CDockAreaWidget::event(QEvent *e)
|
||||
|
@ -376,6 +376,12 @@ public:
|
||||
*/
|
||||
bool containsCentralWidget() const;
|
||||
|
||||
/**
|
||||
* If this dock area is the one and only visible area in a container, then
|
||||
* this function returns true
|
||||
*/
|
||||
bool isTopLevelArea() const;
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
|
@ -163,7 +163,8 @@ protected:
|
||||
CDockWidget* topLevelDockWidget() const;
|
||||
|
||||
/**
|
||||
* Returns the top level dock area.
|
||||
* If the container has only one single visible dock area, then this
|
||||
* functions returns this top level dock area
|
||||
*/
|
||||
CDockAreaWidget* topLevelDockArea() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user