mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-01 02:42:39 +08:00
Add minimize button to auto hide widget.
This commit is contained in:
parent
3247054969
commit
521f47f74c
@ -15,6 +15,7 @@
|
||||
#include "AutoHideDockContainer.h"
|
||||
#include "DockAreaWidget.h"
|
||||
#include "DockAreaTitleBar.h"
|
||||
#include "IconProvider.h"
|
||||
|
||||
using namespace ads;
|
||||
|
||||
@ -24,11 +25,15 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||
, ui(new Ui::CMainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
CDockManager::iconProvider().registerCustomIcon(DockAreaMinimizeIcon, QIcon()); // TODO: CP: Icon.
|
||||
|
||||
CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true);
|
||||
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
|
||||
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
||||
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideDockAreaCloseable, false);
|
||||
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideDockHasMinimizeButton, true);
|
||||
|
||||
DockManager = new CDockManager(this);
|
||||
|
||||
// Set central widget
|
||||
|
@ -71,6 +71,7 @@ struct DockAreaTitleBarPrivate
|
||||
QPointer<CTitleBarButton> TabsMenuButton;
|
||||
QPointer<CTitleBarButton> AutoHideButton;
|
||||
QPointer<CTitleBarButton> UndockButton;
|
||||
QPointer<CTitleBarButton> MinimizeButton;
|
||||
QPointer<CTitleBarButton> CloseButton;
|
||||
QBoxLayout* Layout;
|
||||
CDockAreaWidget* DockArea;
|
||||
@ -218,6 +219,17 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
Layout->addWidget(AutoHideButton, 0);
|
||||
_this->connect(AutoHideButton, SIGNAL(clicked()), SLOT(onAutoHideButtonClicked()));
|
||||
|
||||
// Minimize button
|
||||
MinimizeButton = new CTitleBarButton(testAutoHideConfigFlag(CDockManager::AutoHideDockHasMinimizeButton));
|
||||
MinimizeButton->setObjectName("autoHideDockAreaMinimizeButton");
|
||||
MinimizeButton->setAutoRaise(true);
|
||||
internal::setButtonIcon(MinimizeButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaMinimizeIcon);
|
||||
internal::setToolTip(MinimizeButton, _this->titleBarButtonToolTip(TitleBarButtonMinimize));
|
||||
MinimizeButton->setSizePolicy(ButtonSizePolicy);
|
||||
MinimizeButton->setIconSize(QSize(16, 16));
|
||||
Layout->addWidget(MinimizeButton, 0);
|
||||
_this->connect(MinimizeButton, SIGNAL(clicked()), SLOT(onMinimizeButtonClicked()));
|
||||
|
||||
// Close button
|
||||
CloseButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasCloseButton));
|
||||
CloseButton->setObjectName("dockAreaCloseButton");
|
||||
@ -228,6 +240,7 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
CloseButton->setIconSize(QSize(16, 16));
|
||||
Layout->addWidget(CloseButton, 0);
|
||||
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -527,6 +540,14 @@ void CDockAreaTitleBar::onAutoHideButtonClicked()
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::onMinimizeButtonClicked()
|
||||
{
|
||||
if (d->DockArea->autoHideDockContainer())
|
||||
{
|
||||
d->DockArea->autoHideDockContainer()->collapseView(true);
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::onAutoHideDockAreaActionClicked()
|
||||
@ -551,6 +572,7 @@ CTitleBarButton* CDockAreaTitleBar::button(TitleBarButton which) const
|
||||
case TitleBarButtonTabsMenu: return d->TabsMenuButton;
|
||||
case TitleBarButtonUndock: return d->UndockButton;
|
||||
case TitleBarButtonClose: return d->CloseButton;
|
||||
case TitleBarButtonMinimize: return d->MinimizeButton;
|
||||
case TitleBarButtonAutoHide: return d->AutoHideButton;
|
||||
default:
|
||||
return nullptr;
|
||||
@ -740,6 +762,12 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
}
|
||||
Menu.addSeparator();
|
||||
}
|
||||
if (isAutoHide && CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideDockHasMinimizeButton))
|
||||
{
|
||||
Action = Menu.addAction(tr("Minimize"), this, SLOT(onMinimizeButtonClicked()));
|
||||
Action->setEnabled(true);
|
||||
}
|
||||
|
||||
Action = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
if (!isAutoHide && !isTopLevelArea)
|
||||
@ -800,6 +828,10 @@ QString CDockAreaTitleBar::titleBarButtonToolTip(TitleBarButton Button) const
|
||||
}
|
||||
break;
|
||||
|
||||
case TitleBarButtonMinimize:
|
||||
return tr("Minimize");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ private Q_SLOTS:
|
||||
void onTabsMenuActionTriggered(QAction* Action);
|
||||
void onCurrentTabChanged(int Index);
|
||||
void onAutoHideButtonClicked();
|
||||
void onMinimizeButtonClicked();
|
||||
void onAutoHideDockAreaActionClicked();
|
||||
void onAutoHideToActionClicked();
|
||||
|
||||
|
@ -394,6 +394,7 @@ void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool IsTopLevel)
|
||||
if (IsTopLevel)
|
||||
{
|
||||
TitleBar->button(TitleBarButtonClose)->setVisible(!container->isFloating());
|
||||
TitleBar->button(TitleBarButtonMinimize)->setVisible(!container->isFloating());
|
||||
TitleBar->button(TitleBarButtonAutoHide)->setVisible(!container->isFloating());
|
||||
// Undock and tabs should never show when auto hidden
|
||||
TitleBar->button(TitleBarButtonUndock)->setVisible(!container->isFloating() && !_this->isAutoHide());
|
||||
@ -402,6 +403,7 @@ void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool IsTopLevel)
|
||||
else
|
||||
{
|
||||
TitleBar->button(TitleBarButtonClose)->setVisible(true);
|
||||
TitleBar->button(TitleBarButtonMinimize)->setVisible(_this->isAutoHide() && CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideDockHasMinimizeButton));
|
||||
TitleBar->button(TitleBarButtonAutoHide)->setVisible(true);
|
||||
TitleBar->button(TitleBarButtonUndock)->setVisible(!_this->isAutoHide());
|
||||
TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isAutoHide());
|
||||
@ -888,6 +890,8 @@ void CDockAreaWidget::updateTitleBarButtonsToolTips()
|
||||
{
|
||||
internal::setToolTip(titleBarButton(TitleBarButtonClose),
|
||||
titleBar()->titleBarButtonToolTip(TitleBarButtonClose));
|
||||
internal::setToolTip(titleBarButton(TitleBarButtonMinimize),
|
||||
titleBar()->titleBarButtonToolTip(TitleBarButtonMinimize));
|
||||
internal::setToolTip(titleBarButton(TitleBarButtonAutoHide),
|
||||
titleBar()->titleBarButtonToolTip(TitleBarButtonAutoHide));
|
||||
}
|
||||
|
@ -911,6 +911,7 @@ void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*
|
||||
for (auto DockArea : NewDockAreas)
|
||||
{
|
||||
DockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
|
||||
DockArea->titleBarButton(TitleBarButtonMinimize)->setVisible(true);
|
||||
DockArea->titleBarButton(TitleBarButtonAutoHide)->setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -251,6 +251,7 @@ public:
|
||||
AutoHideShowOnMouseOver = 0x20, ///< show the auto hide window on mouse over tab and hide it if mouse leaves auto hide container
|
||||
AutoHideCloseButtonCollapsesDock = 0x40, ///< Close button of an auto hide container collapses the dock instead of hiding it completely
|
||||
AutoHideDockAreaCloseable = 0x080,///< if this flag is set, the auto hide dock area can be closed.
|
||||
AutoHideDockHasMinimizeButton = 0x100,///< if the flag is set each auto hide dock area has a minimize button.
|
||||
|
||||
DefaultAutoHideConfig = AutoHideFeatureEnabled
|
||||
| DockAreaHasAutoHideButton
|
||||
|
@ -107,7 +107,8 @@ enum TitleBarButton
|
||||
TitleBarButtonTabsMenu,
|
||||
TitleBarButtonUndock,
|
||||
TitleBarButtonClose,
|
||||
TitleBarButtonAutoHide
|
||||
TitleBarButtonAutoHide,
|
||||
TitleBarButtonMinimize
|
||||
};
|
||||
|
||||
/**
|
||||
@ -129,8 +130,9 @@ enum eIcon
|
||||
TabCloseIcon, //!< TabCloseIcon
|
||||
AutoHideIcon, //!< AutoHideIcon
|
||||
DockAreaMenuIcon, //!< DockAreaMenuIcon
|
||||
DockAreaUndockIcon,//!< DockAreaUndockIcon
|
||||
DockAreaUndockIcon, //!< DockAreaUndockIcon
|
||||
DockAreaCloseIcon, //!< DockAreaCloseIcon
|
||||
DockAreaMinimizeIcon, //!< DockAreaMinimizeIcon
|
||||
|
||||
IconCount, //!< just a delimiter for range checks
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user