Improved context menu of DockAreaWidget

This commit is contained in:
Uwe Kindler
2022-11-02 13:06:42 +01:00
parent b5a179555a
commit d2c08aca70
4 changed files with 37 additions and 11 deletions

View File

@@ -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());
}