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 // comment the following line if you want to use opaque undocking and
// opaque splitter resizing // opaque splitter resizing
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig); CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
//CDockManager::setConfigFlag(CDockManager::DockAreaHasCloseButton, false);
// uncomment the following line if you want a fixed tab width that does // uncomment the following line if you want a fixed tab width that does
// not change if the visibility of the close button changes // not change if the visibility of the close button changes
//CDockManager::setConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden, true); //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 // Now create the dock manager and its content
d->DockManager = new CDockManager(this); d->DockManager = new CDockManager(this);

View File

@ -167,38 +167,53 @@ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
void DockAreaTitleBarPrivate::createButtons() void DockAreaTitleBarPrivate::createButtons()
{ {
QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
// Tabs menu button
TabsMenuButton = new tTitleBarButton(); if (testConfigFlag(CDockManager::DockAreaHasTabsMenuButton))
TabsMenuButton->setObjectName("tabsMenuButton"); {
TabsMenuButton->setAutoRaise(true); // Tabs menu button
TabsMenuButton->setPopupMode(QToolButton::InstantPopup); TabsMenuButton = new tTitleBarButton();
setTitleBarButtonIcon(TabsMenuButton, QStyle::SP_TitleBarUnshadeButton, ads::DockAreaMenuIcon); TabsMenuButton->setObjectName("tabsMenuButton");
QMenu* TabsMenu = new QMenu(TabsMenuButton); TabsMenuButton->setAutoRaise(true);
TabsMenuButton->setPopupMode(QToolButton::InstantPopup);
setTitleBarButtonIcon(TabsMenuButton, QStyle::SP_TitleBarUnshadeButton, ads::DockAreaMenuIcon);
QMenu* TabsMenu = new QMenu(TabsMenuButton);
#ifndef QT_NO_TOOLTIP #ifndef QT_NO_TOOLTIP
TabsMenu->setToolTipsVisible(true); TabsMenu->setToolTipsVisible(true);
#endif #endif
_this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow())); _this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow()));
TabsMenuButton->setMenu(TabsMenu); TabsMenuButton->setMenu(TabsMenu);
#ifndef QT_NO_TOOLTIP #ifndef QT_NO_TOOLTIP
TabsMenuButton->setToolTip(QObject::tr("List all tabs")); TabsMenuButton->setToolTip(QObject::tr("List all tabs"));
#endif #endif
TabsMenuButton->setSizePolicy(ButtonSizePolicy); TabsMenuButton->setSizePolicy(ButtonSizePolicy);
TopLayout->addWidget(TabsMenuButton, 0); TopLayout->addWidget(TabsMenuButton, 0);
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)), _this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
SLOT(onTabsMenuActionTriggered(QAction*))); SLOT(onTabsMenuActionTriggered(QAction*)));
}
else
{
TabsMenuButton = new CInvisibleButton();
}
// Undock button if (testConfigFlag(CDockManager::DockAreaHasUndockButton))
UndockButton = new tTitleBarButton(); {
UndockButton->setObjectName("undockButton"); // Undock button
UndockButton->setAutoRaise(true); UndockButton = new tTitleBarButton();
UndockButton->setObjectName("undockButton");
UndockButton->setAutoRaise(true);
#ifndef QT_NO_TOOLTIP #ifndef QT_NO_TOOLTIP
UndockButton->setToolTip(QObject::tr("Detach Group")); UndockButton->setToolTip(QObject::tr("Detach Group"));
#endif #endif
setTitleBarButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon); setTitleBarButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon);
UndockButton->setSizePolicy(ButtonSizePolicy); UndockButton->setSizePolicy(ButtonSizePolicy);
TopLayout->addWidget(UndockButton, 0); TopLayout->addWidget(UndockButton, 0);
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked())); _this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
}
else
{
UndockButton = new CInvisibleButton();
}
if (testConfigFlag(CDockManager::DockAreaHasCloseButton)) 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 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 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. 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 DefaultConfig = ActiveTabHasCloseButton
| DockAreaHasCloseButton | DockAreaHasCloseButton
| DockAreaHasUndockButton
| DockAreaHasTabsMenuButton
| OpaqueSplitterResize | OpaqueSplitterResize
| XmlCompressionEnabled | XmlCompressionEnabled
| OpaqueUndocking, ///< the default configuration | OpaqueUndocking, ///< the default configuration
DefaultNonOpaqueConfig = ActiveTabHasCloseButton DefaultNonOpaqueConfig = ActiveTabHasCloseButton
| DockAreaHasCloseButton | DockAreaHasCloseButton
| DockAreaHasUndockButton
| DockAreaHasTabsMenuButton
| XmlCompressionEnabled | XmlCompressionEnabled
| DragPreviewShowsContentPixmap, ///< the default configuration for non opaque operations | DragPreviewShowsContentPixmap, ///< the default configuration for non opaque operations
NonOpaqueWithWindowFrame = ActiveTabHasCloseButton NonOpaqueWithWindowFrame = ActiveTabHasCloseButton
| DockAreaHasCloseButton | DockAreaHasCloseButton
| DockAreaHasUndockButton
| DockAreaHasTabsMenuButton
| XmlCompressionEnabled | XmlCompressionEnabled
| DragPreviewShowsContentPixmap | DragPreviewShowsContentPixmap
| DragPreviewHasWindowFrame ///< the default configuration for non opaque operations that show a real window with frame | DragPreviewHasWindowFrame ///< the default configuration for non opaque operations that show a real window with frame