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 "AutoHideDockContainer.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
#include "DockAreaTitleBar.h"
|
#include "DockAreaTitleBar.h"
|
||||||
|
#include "IconProvider.h"
|
||||||
|
|
||||||
using namespace ads;
|
using namespace ads;
|
||||||
|
|
||||||
@ -24,11 +25,15 @@ CMainWindow::CMainWindow(QWidget *parent)
|
|||||||
, ui(new Ui::CMainWindow)
|
, ui(new Ui::CMainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
CDockManager::iconProvider().registerCustomIcon(DockAreaMinimizeIcon, QIcon()); // TODO: CP: Icon.
|
||||||
|
|
||||||
CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true);
|
CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true);
|
||||||
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
|
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
|
||||||
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
||||||
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideDockAreaCloseable, false);
|
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideDockAreaCloseable, false);
|
||||||
|
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideDockHasMinimizeButton, true);
|
||||||
|
|
||||||
DockManager = new CDockManager(this);
|
DockManager = new CDockManager(this);
|
||||||
|
|
||||||
// Set central widget
|
// Set central widget
|
||||||
|
@ -71,6 +71,7 @@ struct DockAreaTitleBarPrivate
|
|||||||
QPointer<CTitleBarButton> TabsMenuButton;
|
QPointer<CTitleBarButton> TabsMenuButton;
|
||||||
QPointer<CTitleBarButton> AutoHideButton;
|
QPointer<CTitleBarButton> AutoHideButton;
|
||||||
QPointer<CTitleBarButton> UndockButton;
|
QPointer<CTitleBarButton> UndockButton;
|
||||||
|
QPointer<CTitleBarButton> MinimizeButton;
|
||||||
QPointer<CTitleBarButton> CloseButton;
|
QPointer<CTitleBarButton> CloseButton;
|
||||||
QBoxLayout* Layout;
|
QBoxLayout* Layout;
|
||||||
CDockAreaWidget* DockArea;
|
CDockAreaWidget* DockArea;
|
||||||
@ -218,6 +219,17 @@ void DockAreaTitleBarPrivate::createButtons()
|
|||||||
Layout->addWidget(AutoHideButton, 0);
|
Layout->addWidget(AutoHideButton, 0);
|
||||||
_this->connect(AutoHideButton, SIGNAL(clicked()), SLOT(onAutoHideButtonClicked()));
|
_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
|
// Close button
|
||||||
CloseButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasCloseButton));
|
CloseButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasCloseButton));
|
||||||
CloseButton->setObjectName("dockAreaCloseButton");
|
CloseButton->setObjectName("dockAreaCloseButton");
|
||||||
@ -228,6 +240,7 @@ void DockAreaTitleBarPrivate::createButtons()
|
|||||||
CloseButton->setIconSize(QSize(16, 16));
|
CloseButton->setIconSize(QSize(16, 16));
|
||||||
Layout->addWidget(CloseButton, 0);
|
Layout->addWidget(CloseButton, 0);
|
||||||
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
|
_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()
|
void CDockAreaTitleBar::onAutoHideDockAreaActionClicked()
|
||||||
@ -551,6 +572,7 @@ CTitleBarButton* CDockAreaTitleBar::button(TitleBarButton which) const
|
|||||||
case TitleBarButtonTabsMenu: return d->TabsMenuButton;
|
case TitleBarButtonTabsMenu: return d->TabsMenuButton;
|
||||||
case TitleBarButtonUndock: return d->UndockButton;
|
case TitleBarButtonUndock: return d->UndockButton;
|
||||||
case TitleBarButtonClose: return d->CloseButton;
|
case TitleBarButtonClose: return d->CloseButton;
|
||||||
|
case TitleBarButtonMinimize: return d->MinimizeButton;
|
||||||
case TitleBarButtonAutoHide: return d->AutoHideButton;
|
case TitleBarButtonAutoHide: return d->AutoHideButton;
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -740,6 +762,12 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
|||||||
}
|
}
|
||||||
Menu.addSeparator();
|
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 = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||||
if (!isAutoHide && !isTopLevelArea)
|
if (!isAutoHide && !isTopLevelArea)
|
||||||
@ -800,6 +828,10 @@ QString CDockAreaTitleBar::titleBarButtonToolTip(TitleBarButton Button) const
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TitleBarButtonMinimize:
|
||||||
|
return tr("Minimize");
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ private Q_SLOTS:
|
|||||||
void onTabsMenuActionTriggered(QAction* Action);
|
void onTabsMenuActionTriggered(QAction* Action);
|
||||||
void onCurrentTabChanged(int Index);
|
void onCurrentTabChanged(int Index);
|
||||||
void onAutoHideButtonClicked();
|
void onAutoHideButtonClicked();
|
||||||
|
void onMinimizeButtonClicked();
|
||||||
void onAutoHideDockAreaActionClicked();
|
void onAutoHideDockAreaActionClicked();
|
||||||
void onAutoHideToActionClicked();
|
void onAutoHideToActionClicked();
|
||||||
|
|
||||||
|
@ -394,6 +394,7 @@ void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool IsTopLevel)
|
|||||||
if (IsTopLevel)
|
if (IsTopLevel)
|
||||||
{
|
{
|
||||||
TitleBar->button(TitleBarButtonClose)->setVisible(!container->isFloating());
|
TitleBar->button(TitleBarButtonClose)->setVisible(!container->isFloating());
|
||||||
|
TitleBar->button(TitleBarButtonMinimize)->setVisible(!container->isFloating());
|
||||||
TitleBar->button(TitleBarButtonAutoHide)->setVisible(!container->isFloating());
|
TitleBar->button(TitleBarButtonAutoHide)->setVisible(!container->isFloating());
|
||||||
// Undock and tabs should never show when auto hidden
|
// Undock and tabs should never show when auto hidden
|
||||||
TitleBar->button(TitleBarButtonUndock)->setVisible(!container->isFloating() && !_this->isAutoHide());
|
TitleBar->button(TitleBarButtonUndock)->setVisible(!container->isFloating() && !_this->isAutoHide());
|
||||||
@ -402,6 +403,7 @@ void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool IsTopLevel)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
TitleBar->button(TitleBarButtonClose)->setVisible(true);
|
TitleBar->button(TitleBarButtonClose)->setVisible(true);
|
||||||
|
TitleBar->button(TitleBarButtonMinimize)->setVisible(_this->isAutoHide() && CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideDockHasMinimizeButton));
|
||||||
TitleBar->button(TitleBarButtonAutoHide)->setVisible(true);
|
TitleBar->button(TitleBarButtonAutoHide)->setVisible(true);
|
||||||
TitleBar->button(TitleBarButtonUndock)->setVisible(!_this->isAutoHide());
|
TitleBar->button(TitleBarButtonUndock)->setVisible(!_this->isAutoHide());
|
||||||
TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isAutoHide());
|
TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isAutoHide());
|
||||||
@ -888,6 +890,8 @@ void CDockAreaWidget::updateTitleBarButtonsToolTips()
|
|||||||
{
|
{
|
||||||
internal::setToolTip(titleBarButton(TitleBarButtonClose),
|
internal::setToolTip(titleBarButton(TitleBarButtonClose),
|
||||||
titleBar()->titleBarButtonToolTip(TitleBarButtonClose));
|
titleBar()->titleBarButtonToolTip(TitleBarButtonClose));
|
||||||
|
internal::setToolTip(titleBarButton(TitleBarButtonMinimize),
|
||||||
|
titleBar()->titleBarButtonToolTip(TitleBarButtonMinimize));
|
||||||
internal::setToolTip(titleBarButton(TitleBarButtonAutoHide),
|
internal::setToolTip(titleBarButton(TitleBarButtonAutoHide),
|
||||||
titleBar()->titleBarButtonToolTip(TitleBarButtonAutoHide));
|
titleBar()->titleBarButtonToolTip(TitleBarButtonAutoHide));
|
||||||
}
|
}
|
||||||
|
@ -911,6 +911,7 @@ void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*
|
|||||||
for (auto DockArea : NewDockAreas)
|
for (auto DockArea : NewDockAreas)
|
||||||
{
|
{
|
||||||
DockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
|
DockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
|
||||||
|
DockArea->titleBarButton(TitleBarButtonMinimize)->setVisible(true);
|
||||||
DockArea->titleBarButton(TitleBarButtonAutoHide)->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
|
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
|
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.
|
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
|
DefaultAutoHideConfig = AutoHideFeatureEnabled
|
||||||
| DockAreaHasAutoHideButton
|
| DockAreaHasAutoHideButton
|
||||||
|
@ -107,7 +107,8 @@ enum TitleBarButton
|
|||||||
TitleBarButtonTabsMenu,
|
TitleBarButtonTabsMenu,
|
||||||
TitleBarButtonUndock,
|
TitleBarButtonUndock,
|
||||||
TitleBarButtonClose,
|
TitleBarButtonClose,
|
||||||
TitleBarButtonAutoHide
|
TitleBarButtonAutoHide,
|
||||||
|
TitleBarButtonMinimize
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,6 +132,7 @@ enum eIcon
|
|||||||
DockAreaMenuIcon, //!< DockAreaMenuIcon
|
DockAreaMenuIcon, //!< DockAreaMenuIcon
|
||||||
DockAreaUndockIcon, //!< DockAreaUndockIcon
|
DockAreaUndockIcon, //!< DockAreaUndockIcon
|
||||||
DockAreaCloseIcon, //!< DockAreaCloseIcon
|
DockAreaCloseIcon, //!< DockAreaCloseIcon
|
||||||
|
DockAreaMinimizeIcon, //!< DockAreaMinimizeIcon
|
||||||
|
|
||||||
IconCount, //!< just a delimiter for range checks
|
IconCount, //!< just a delimiter for range checks
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user