Added "Close" action to AutoHideTab context menu

This commit is contained in:
Uwe Kindler 2023-07-10 10:38:21 +02:00
parent df1bc94d9e
commit 0627b3183f
5 changed files with 42 additions and 10 deletions

View File

@ -394,6 +394,9 @@ void CAutoHideTab::contextMenuEvent(QContextMenuEvent* ev)
d->createAutoHideToAction(tr("Bottom"), SideBarBottom, menu);
Action = Menu.addAction(tr("Unpin (Dock)"), this, SLOT(unpinDockWidget()));
Menu.addSeparator();
Action = Menu.addAction(tr("Close"), this, SLOT(requestCloseDockWidget()));
Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable));
Menu.exec(ev->globalPos());
}
@ -537,4 +540,11 @@ void CAutoHideTab::mouseMoveEvent(QMouseEvent* ev)
}
//============================================================================
void CAutoHideTab::requestCloseDockWidget()
{
d->DockWidget->requestCloseDockWidget();
}
}

View File

@ -150,6 +150,11 @@ public Q_SLOTS:
* Unpin and dock the auto hide widget
*/
void unpinDockWidget();
/**
* Calls the requestCloseDockWidget() function for the assigned dock widget
*/
void requestCloseDockWidget();
}; // class AutoHideTab
}
// namespace ads

View File

@ -626,15 +626,7 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent()
void CDockAreaWidget::onTabCloseRequested(int Index)
{
ADS_PRINT("CDockAreaWidget::onTabCloseRequested " << Index);
auto* DockWidget = dockWidget(Index);
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose) || DockWidget->features().testFlag(CDockWidget::CustomCloseHandling))
{
DockWidget->closeDockWidgetInternal();
}
else
{
DockWidget->toggleView(false);
}
dockWidget(Index)->requestCloseDockWidget();
}

View File

@ -1059,6 +1059,22 @@ void CDockWidget::closeDockWidget()
}
//============================================================================
void CDockWidget::requestCloseDockWidget()
{
if (features().testFlag(CDockWidget::DockWidgetDeleteOnClose)
|| features().testFlag(CDockWidget::CustomCloseHandling))
{
closeDockWidgetInternal(false);
}
else
{
toggleView(false);
}
}
//============================================================================
bool CDockWidget::closeDockWidgetInternal(bool ForceClose)
{

View File

@ -584,10 +584,19 @@ public Q_SLOTS:
void deleteDockWidget();
/**
* Closes the dock widget
* Closes the dock widget.
* The function forces closing of the dock widget even for CustomCloseHandling.
*/
void closeDockWidget();
/**
* Request closing of the dock widget.
* For DockWidget with default close handling, the function does the same
* like clodeDockWidget() but if the flas CustomCloseHandling is set,
* the function only emits the closeRequested() signal.
*/
void requestCloseDockWidget();
/**
* Shows the widget in full-screen mode.
* Normally this function only affects windows. To make the interface