Added minimize and close action to Auto Hide context menu

This commit is contained in:
Uwe Kindler 2023-10-19 09:10:26 +02:00
parent 9ec97a8867
commit 0f8096e314
3 changed files with 34 additions and 2 deletions

View File

@ -527,6 +527,7 @@ void MainWindowPrivate::createContent()
// Tests CustomCloseHandling without DeleteOnClose
LabelDockWidget->setFeature(ads::CDockWidget::CustomCloseHandling, true);
LabelDockWidget->setWindowTitle(LabelDockWidget->windowTitle() + " [Custom Close]");
QObject::connect(LabelDockWidget, &ads::CDockWidget::closeRequested, [LabelDockWidget, this]()
{
int Result = QMessageBox::question(_this, "Custom Close Request",

View File

@ -431,6 +431,24 @@ void CDockAreaTitleBar::onCloseButtonClicked()
}
//============================================================================
void CDockAreaTitleBar::onAutoHideCloseActionTriggered()
{
d->DockArea->closeArea();
}
//============================================================================
void CDockAreaTitleBar::onAutoHideMinimizeActionTriggered()
{
auto AutoHideContainer = d->DockArea->autoHideDockContainer();
if (AutoHideContainer)
{
AutoHideContainer->collapseView(true);
}
}
//============================================================================
void CDockAreaTitleBar::onUndockButtonClicked()
{
@ -735,7 +753,17 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
}
Menu.addSeparator();
}
Action = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
if (isAutoHide)
{
Action = Menu.addAction(tr("Minimize"), this, SLOT(onAutoHideMinimizeActionTriggered()));
Action = Menu.addAction(tr("Close"), this, SLOT(onAutoHideCloseActionTriggered()));
}
else
{
Action = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
}
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
if (!isAutoHide && !isTopLevelArea)
{
@ -782,7 +810,8 @@ QString CDockAreaTitleBar::titleBarButtonToolTip(TitleBarButton Button) const
case TitleBarButtonClose:
if (d->DockArea->isAutoHide())
{
return tr("Close");
bool Minimize = CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideCloseButtonCollapsesDock);
return Minimize ? tr("Minimize") : tr("Close");
}
if (CDockManager::testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))

View File

@ -97,6 +97,8 @@ private:
private Q_SLOTS:
void onTabsMenuAboutToShow();
void onCloseButtonClicked();
void onAutoHideCloseActionTriggered();
void onAutoHideMinimizeActionTriggered();
void onUndockButtonClicked();
void onTabsMenuActionTriggered(QAction* Action);
void onCurrentTabChanged(int Index);