Support tabs at the bottom of dock widgets.
This commit is contained in:
@@ -260,10 +260,10 @@ void DockAreaTitleBarPrivate::createAutoHideTitleLabel()
|
||||
{
|
||||
AutoHideTitleLabel = new CElidingLabel("");
|
||||
AutoHideTitleLabel->setObjectName("autoHideTitleLabel");
|
||||
// At position 0 is the tab bar - insert behind tab bar
|
||||
Layout->insertWidget(1, AutoHideTitleLabel);
|
||||
AutoHideTitleLabel->setVisible(false); // Default hidden
|
||||
Layout->insertWidget(2 ,new CSpacerWidget(_this));
|
||||
// When the tabs are at the top, they will be at position 0, insert the label behind them, and hide it.
|
||||
Layout->addWidget(AutoHideTitleLabel);
|
||||
AutoHideTitleLabel->setVisible(CDockManager::testConfigFlag(CDockManager::TabsAtBottom));
|
||||
Layout->addWidget(new CSpacerWidget(_this));
|
||||
}
|
||||
|
||||
|
||||
@@ -272,7 +272,9 @@ void DockAreaTitleBarPrivate::createTabBar()
|
||||
{
|
||||
TabBar = componentsFactory()->createDockAreaTabBar(DockArea);
|
||||
TabBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
if (!CDockManager::testConfigFlag(CDockManager::TabsAtBottom))
|
||||
Layout->addWidget(TabBar);
|
||||
|
||||
_this->connect(TabBar, SIGNAL(tabClosed(int)), SLOT(markTabsMenuOutdated()));
|
||||
_this->connect(TabBar, SIGNAL(tabOpened(int)), SLOT(markTabsMenuOutdated()));
|
||||
_this->connect(TabBar, SIGNAL(tabInserted(int)), SLOT(markTabsMenuOutdated()));
|
||||
@@ -351,8 +353,8 @@ CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) :
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
|
||||
d->createTabBar();
|
||||
d->createButtons();
|
||||
d->createAutoHideTitleLabel();
|
||||
d->createButtons();
|
||||
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
@@ -900,8 +902,11 @@ QString CDockAreaTitleBar::titleBarButtonToolTip(TitleBarButton Button) const
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::showAutoHideControls(bool Show)
|
||||
{
|
||||
d->TabBar->setVisible(!Show); // Auto hide toolbar never has tabs
|
||||
if (Show)
|
||||
d->TabBar->setVisible(false); // Auto hide toolbar never has tabs
|
||||
|
||||
d->MinimizeButton->setVisible(Show);
|
||||
if (!CDockManager::testConfigFlag(CDockManager::TabsAtBottom))
|
||||
d->AutoHideTitleLabel->setVisible(Show);
|
||||
}
|
||||
|
||||
|
||||
@@ -179,14 +179,17 @@ public:
|
||||
parent->setUpdatesEnabled(false);
|
||||
}
|
||||
|
||||
if (m_CurrentWidget)
|
||||
{
|
||||
auto LayoutItem = m_ParentLayout->takeAt(1);
|
||||
if (LayoutItem)
|
||||
{
|
||||
LayoutItem->widget()->setParent(nullptr);
|
||||
}
|
||||
delete LayoutItem;
|
||||
}
|
||||
|
||||
m_ParentLayout->addWidget(next);
|
||||
m_ParentLayout->insertWidget(1, next);
|
||||
if (prev)
|
||||
{
|
||||
prev->hide();
|
||||
@@ -362,6 +365,14 @@ void DockAreaWidgetPrivate::createTitleBar()
|
||||
{
|
||||
TitleBar = componentsFactory()->createDockAreaTitleBar(_this);
|
||||
Layout->addWidget(TitleBar);
|
||||
if (CDockManager::testConfigFlag(CDockManager::TabsAtBottom))
|
||||
{
|
||||
// Title bar will be index 0, container widgets will be index 1,
|
||||
// so tabs will always be at the end of the layout.
|
||||
Layout->addWidget(tabBar());
|
||||
tabBar()->setVisible(CDockManager::testConfigFlag(CDockManager::AlwaysShowTabs));
|
||||
}
|
||||
|
||||
QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested);
|
||||
QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex);
|
||||
QObject::connect(tabBar(), &CDockAreaTabBar::tabMoved, _this, &CDockAreaWidget::reorderDockWidget);
|
||||
@@ -726,6 +737,7 @@ void CDockAreaWidget::setCurrentIndex(int index)
|
||||
TabBar->setCurrentIndex(index);
|
||||
d->ContentsLayout->setCurrentIndex(index);
|
||||
d->ContentsLayout->currentWidget()->show();
|
||||
d->TitleBar->autoHideTitleLabel()->setText(d->ContentsLayout->currentWidget()->windowTitle());
|
||||
Q_EMIT currentChanged(index);
|
||||
}
|
||||
|
||||
@@ -889,6 +901,8 @@ void CDockAreaWidget::updateTitleBarVisibility()
|
||||
}
|
||||
}
|
||||
d->TitleBar->setVisible(!Hidden);
|
||||
if (CDockManager::testConfigFlag(CDockManager::TabsAtBottom))
|
||||
d->TitleBar->tabBar()->setVisible(openDockWidgetsCount() > 1);
|
||||
}
|
||||
|
||||
if (isAutoHideFeatureEnabled())
|
||||
|
||||
@@ -216,6 +216,7 @@ public:
|
||||
DisableTabTextEliding = 0x4000000, //! Set this flag to disable eliding of tab texts in dock area tabs
|
||||
ShowTabTextOnlyForActiveTab =0x8000000, //! Set this flag to show label texts in dock area tabs only for active tabs
|
||||
DoubleClickUndocksWidget = 0x10000000, //!< If the flag is set, a double click on a tab undocks the widget
|
||||
TabsAtBottom = 0x20000000, //!< If the flag is set, tabs will be shown at the bottom instead of in the title bar.
|
||||
|
||||
|
||||
DefaultDockAreaButtons = DockAreaHasCloseButton
|
||||
|
||||
@@ -82,6 +82,10 @@ ads--CDockWidgetTab[activeTab="true"] QLabel {
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
#autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
#tabCloseButton {
|
||||
margin-top: 2px;
|
||||
@@ -278,7 +282,7 @@ ads--CAutoHideDockContainer ads--CDockAreaWidget[focused="true"] ads--CDockAreaT
|
||||
}
|
||||
|
||||
|
||||
#autoHideTitleLabel {
|
||||
ads--CAutoHideDockContainer #autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(light);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user