Added DockAreaHasTabsMenuButton and DockAreaHasUndockButton to CDockManager config (#108)

* Added DockAreaHasUndockButton and DockAreaHasTabsMenuButton configuration flag
This commit is contained in:
mvidelgauz 2020-02-02 17:22:05 +02:00 committed by GitHub
parent 1dbd3f3f06
commit 1d68e27558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 25 deletions

View File

@ -418,12 +418,19 @@ CMainWindow::CMainWindow(QWidget *parent) :
// comment the following line if you want to use opaque undocking and
// opaque splitter resizing
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
//CDockManager::setConfigFlag(CDockManager::DockAreaHasCloseButton, false);
// uncomment the following line if you want a fixed tab width that does
// not change if the visibility of the close button changes
//CDockManager::setConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden, true);
// uncomment the following line if you don't want close button on DockArea's title bar
//CDockManager::setConfigFlag(CDockManager::DockAreaHasCloseButton, false);
// uncomment the following line if you don't want undock button on DockArea's title bar
//CDockManager::setConfigFlag(CDockManager::DockAreaHasUndockButton, false);
// uncomment the following line if you don't want tabs menu button on DockArea's title bar
//CDockManager::setConfigFlag(CDockManager::DockAreaHasTabsMenuButton, false);
// Now create the dock manager and its content
d->DockManager = new CDockManager(this);

View File

@ -167,6 +167,9 @@ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
void DockAreaTitleBarPrivate::createButtons()
{
QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
if (testConfigFlag(CDockManager::DockAreaHasTabsMenuButton))
{
// Tabs menu button
TabsMenuButton = new tTitleBarButton();
TabsMenuButton->setObjectName("tabsMenuButton");
@ -186,8 +189,15 @@ void DockAreaTitleBarPrivate::createButtons()
TopLayout->addWidget(TabsMenuButton, 0);
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
SLOT(onTabsMenuActionTriggered(QAction*)));
}
else
{
TabsMenuButton = new CInvisibleButton();
}
if (testConfigFlag(CDockManager::DockAreaHasUndockButton))
{
// Undock button
UndockButton = new tTitleBarButton();
UndockButton->setObjectName("undockButton");
@ -199,6 +209,11 @@ void DockAreaTitleBarPrivate::createButtons()
UndockButton->setSizePolicy(ButtonSizePolicy);
TopLayout->addWidget(UndockButton, 0);
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
}
else
{
UndockButton = new CInvisibleButton();
}
if (testConfigFlag(CDockManager::DockAreaHasCloseButton))
{

View File

@ -157,17 +157,25 @@ public:
DragPreviewShowsContentPixmap = 0x0800,///< If opaque undocking is disabled, the created drag preview window shows a copy of the content of the dock widget / dock are that is dragged
DragPreviewHasWindowFrame = 0x1000,///< If opaque undocking is disabled, then this flag configures if the drag preview is frameless or looks like a real window
AlwaysShowTabs = 0x2000,///< If this option is enabled, the tab of a dock widget is always displayed - even if it is the only visible dock widget in a floating widget.
DockAreaHasUndockButton = 0x4000, //!< If the flag is set each dock area has an undock button
DockAreaHasTabsMenuButton = 0x8000, //!< If the flag is set each dock area has a tabs menu button
DefaultConfig = ActiveTabHasCloseButton
| DockAreaHasCloseButton
| DockAreaHasUndockButton
| DockAreaHasTabsMenuButton
| OpaqueSplitterResize
| XmlCompressionEnabled
| OpaqueUndocking, ///< the default configuration
DefaultNonOpaqueConfig = ActiveTabHasCloseButton
| DockAreaHasCloseButton
| DockAreaHasUndockButton
| DockAreaHasTabsMenuButton
| XmlCompressionEnabled
| DragPreviewShowsContentPixmap, ///< the default configuration for non opaque operations
NonOpaqueWithWindowFrame = ActiveTabHasCloseButton
| DockAreaHasCloseButton
| DockAreaHasUndockButton
| DockAreaHasTabsMenuButton
| XmlCompressionEnabled
| DragPreviewShowsContentPixmap
| DragPreviewHasWindowFrame ///< the default configuration for non opaque operations that show a real window with frame