mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-02-03 09:49:13 +08:00
Added context menu actions for titleBar and dock widget tab auto hide
This commit is contained in:
parent
9c14c62637
commit
b5a179555a
@ -27,7 +27,6 @@
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <AutoHideDockContainer.h>
|
||||
#include "DockAreaTitleBar.h"
|
||||
|
||||
#include <QPushButton>
|
||||
@ -53,6 +52,7 @@
|
||||
#include "DockComponentsFactory.h"
|
||||
#include "DockFocusController.h"
|
||||
#include "ElidingLabel.h"
|
||||
#include "AutoHideDockContainer.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -137,7 +137,6 @@ struct DockAreaTitleBarPrivate
|
||||
return this->DragState == dragState;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Starts floating
|
||||
*/
|
||||
@ -493,7 +492,21 @@ void CDockAreaTitleBar::onCurrentTabChanged(int Index)
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::onAutoHideButtonClicked()
|
||||
{
|
||||
d->DockArea->setAutoHide(!d->DockArea->isAutoHide());
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideButtonTogglesArea))
|
||||
{
|
||||
d->DockArea->toggleAutoHide();
|
||||
}
|
||||
else
|
||||
{
|
||||
d->DockArea->currentDockWidget()->toggleAutoHide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::onAutoHideDockAreaClicked()
|
||||
{
|
||||
d->DockArea->toggleAutoHide();
|
||||
}
|
||||
|
||||
|
||||
@ -538,7 +551,6 @@ void CDockAreaTitleBar::mousePressEvent(QMouseEvent* ev)
|
||||
|
||||
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
|
||||
{
|
||||
//d->TabBar->currentTab()->setFocus(Qt::OtherFocusReason);
|
||||
d->dockManager()->dockFocusController()->setDockWidgetTabFocused(d->TabBar->currentTab());
|
||||
}
|
||||
return;
|
||||
@ -652,13 +664,23 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
return;
|
||||
}
|
||||
|
||||
bool IsAutoHide = d->DockArea->isAutoHide();
|
||||
QMenu Menu(this);
|
||||
auto Action = Menu.addAction(tr("Detach Group"), this, SLOT(onUndockButtonClicked()));
|
||||
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();
|
||||
Action = Menu.addAction(tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||
Action = Menu.addAction(IsAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
Menu.addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
|
||||
if (!IsAutoHide)
|
||||
{
|
||||
Menu.addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
|
||||
}
|
||||
Menu.exec(ev->globalPos());
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ private Q_SLOTS:
|
||||
void onTabsMenuActionTriggered(QAction* Action);
|
||||
void onCurrentTabChanged(int Index);
|
||||
void onAutoHideButtonClicked();
|
||||
void onAutoHideDockAreaClicked();
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -1304,23 +1304,20 @@ void CDockAreaWidget::setAutoHide(bool Enable)
|
||||
return;
|
||||
}
|
||||
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideButtonTogglesArea)
|
||||
&& features().testFlag(CDockWidget::DockWidgetPinnable))
|
||||
auto area = calculateSideTabBarArea();
|
||||
for (const auto DockWidget : openedDockWidgets())
|
||||
{
|
||||
auto area = calculateSideTabBarArea();
|
||||
for (const auto DockWidget : openedDockWidgets())
|
||||
if (Enable == isAutoHide())
|
||||
{
|
||||
if (Enable == isAutoHide())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
dockContainer()->createAndSetupAutoHideContainer(area, DockWidget);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentDockWidget()->setAutoHide(true);
|
||||
|
||||
if (!DockWidget->features().testFlag(CDockWidget::DockWidgetPinnable))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
dockContainer()->createAndSetupAutoHideContainer(area, DockWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,9 @@ public Q_SLOTS:
|
||||
void closeArea();
|
||||
|
||||
/**
|
||||
* Sets the dock area into auto hide mode or into normal mode
|
||||
* Sets the dock area into auto hide mode or into normal mode.
|
||||
* If the dock area is switched to auto hide mode, then all dock widgets
|
||||
* that are pinable will be added to the sidebar
|
||||
*/
|
||||
void setAutoHide(bool Enable);
|
||||
|
||||
|
@ -515,6 +515,11 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
||||
|
||||
auto Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
|
||||
Action->setEnabled(isDetachable);
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
Action = Menu.addAction(tr("Auto Hide"), this, SLOT(autoHideDockWidget()));
|
||||
Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetPinnable));
|
||||
}
|
||||
Menu.addSeparator();
|
||||
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
||||
Action->setEnabled(isClosable());
|
||||
@ -700,6 +705,13 @@ void CDockWidgetTab::detachDockWidget()
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
void CDockWidgetTab::autoHideDockWidget()
|
||||
{
|
||||
d->DockWidget->setAutoHide(true);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
bool CDockWidgetTab::event(QEvent *e)
|
||||
{
|
||||
|
@ -63,6 +63,7 @@ private:
|
||||
|
||||
private Q_SLOTS:
|
||||
void detachDockWidget();
|
||||
void autoHideDockWidget();
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent* ev) override;
|
||||
|
Loading…
Reference in New Issue
Block a user