Pulled latest changes from duer autohide branch

This commit is contained in:
Uwe Kindler 2022-10-12 10:58:47 +02:00
parent 53e8010732
commit 8fc333806a
3 changed files with 29 additions and 12 deletions

View File

@ -315,6 +315,11 @@ struct DockAreaWidgetPrivate
*/ */
void updateTitleBarButtonVisibility(bool isTopLevel); void updateTitleBarButtonVisibility(bool isTopLevel);
/**
* Convenience function to know if all dock widgets are focusable
*/
bool allDockWidgetsFocusable() const;
/** /**
* Scans all contained dock widgets for the max. minimum size hint * Scans all contained dock widgets for the max. minimum size hint
*/ */
@ -382,7 +387,7 @@ void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool IsTopLevel)
if (IsTopLevel) if (IsTopLevel)
{ {
TitleBar->button(TitleBarButtonClose)->setVisible(!container->isFloating()); TitleBar->button(TitleBarButtonClose)->setVisible(!container->isFloating());
TitleBar->button(TitleBarButtonAutoHide)->setVisible(!container->isFloating()); TitleBar->button(TitleBarButtonAutoHide)->setVisible(!container->isFloating() && allDockWidgetsFocusable());
// Undock and tabs should never show when overlayed // Undock and tabs should never show when overlayed
TitleBar->button(TitleBarButtonUndock)->setVisible(!container->isFloating() && !_this->isOverlayed()); TitleBar->button(TitleBarButtonUndock)->setVisible(!container->isFloating() && !_this->isOverlayed());
TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isOverlayed()); TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isOverlayed());
@ -390,12 +395,25 @@ void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool IsTopLevel)
else else
{ {
TitleBar->button(TitleBarButtonClose)->setVisible(true); TitleBar->button(TitleBarButtonClose)->setVisible(true);
TitleBar->button(TitleBarButtonAutoHide)->setVisible(true); TitleBar->button(TitleBarButtonAutoHide)->setVisible(allDockWidgetsFocusable());
TitleBar->button(TitleBarButtonUndock)->setVisible(!_this->isOverlayed()); TitleBar->button(TitleBarButtonUndock)->setVisible(!_this->isOverlayed());
TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isOverlayed()); TitleBar->button(TitleBarButtonTabsMenu)->setVisible(!_this->isOverlayed());
} }
} }
bool DockAreaWidgetPrivate::allDockWidgetsFocusable() const
{
for (const auto &dockWidget : _this->dockWidgets())
{
if (!dockWidget->features().testFlag(CDockWidget::DockWidgetFocusable))
{
return false;
}
}
return true;
}
//============================================================================ //============================================================================
CDockAreaWidget::CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget* parent) : CDockAreaWidget::CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget* parent) :

View File

@ -1521,11 +1521,7 @@ CDockWidgetSideTab::SideTabBarArea CDockContainerWidget::getDockAreaPosition(CDo
// It's bottom if the width is wider than the height, and if it's below 50% of the window // It's bottom if the width is wider than the height, and if it's below 50% of the window
const auto dockWidgetFrameGeometry = DockAreaWidget->frameGeometry(); const auto dockWidgetFrameGeometry = DockAreaWidget->frameGeometry();
const auto splitterCenter = rootSplitter()->mapToGlobal(rootSplitter()->frameGeometry().center()); const auto splitterCenter = rootSplitter()->mapToGlobal(rootSplitter()->frameGeometry().center());
const auto a = dockWidgetFrameGeometry.width();
const auto b = dockWidgetFrameGeometry.height();
const auto c = DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.topLeft()).y();
const auto d = splitterCenter.y();
const auto e = CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar);
if (dockWidgetFrameGeometry.width() > dockWidgetFrameGeometry.height() if (dockWidgetFrameGeometry.width() > dockWidgetFrameGeometry.height()
&& DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.topLeft()).y() > splitterCenter.y() && DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.topLeft()).y() > splitterCenter.y()
&& CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar)) && CDockManager::testConfigFlag(CDockManager::DockContainerHasBottomSideBar))

View File

@ -204,7 +204,6 @@ void COverlayDockContainer::updateSize()
const auto rect = rootSplitter->frameGeometry(); const auto rect = rootSplitter->frameGeometry();
move(rect.topLeft()); move(rect.topLeft());
resize(rect.width(), rect.height()); resize(rect.width(), rect.height());
d->DockArea->updateGeometry();
} }
//============================================================================ //============================================================================
@ -313,6 +312,8 @@ CDockAreaWidget* COverlayDockContainer::dockAreaWidget() const
//============================================================================ //============================================================================
void COverlayDockContainer::moveContentsToParent() void COverlayDockContainer::moveContentsToParent()
{ {
cleanupAndDelete();
const auto position = mapToGlobal(d->getSimplifiedDockAreaPosition()); const auto position = mapToGlobal(d->getSimplifiedDockAreaPosition());
const auto dockAreaWidget = parentContainer()->dockAreaAt(position); const auto dockAreaWidget = parentContainer()->dockAreaAt(position);
@ -324,7 +325,8 @@ void COverlayDockContainer::moveContentsToParent()
{ {
parentContainer()->addDockWidget(d->getArea(d->Area), d->DockWidget); parentContainer()->addDockWidget(d->getArea(d->Area), d->DockWidget);
} }
cleanupAndDelete();
parentContainer()->removeDockArea(d->DockArea);
} }
@ -457,14 +459,15 @@ bool COverlayDockContainer::eventFilter(QObject* watched, QEvent* event)
updateSize(); updateSize();
updateMask(); updateMask();
} }
return QWidget::eventFilter(watched, event);
return QSplitter::eventFilter(watched, event);
} }
//============================================================================ //============================================================================
void COverlayDockContainer::mousePressEvent(QMouseEvent* event) void COverlayDockContainer::mousePressEvent(QMouseEvent* event)
{ {
QWidget::mousePressEvent(event); QSplitter::mousePressEvent(event);
} }
@ -472,7 +475,7 @@ void COverlayDockContainer::mousePressEvent(QMouseEvent* event)
void COverlayDockContainer::resizeEvent(QResizeEvent* event) void COverlayDockContainer::resizeEvent(QResizeEvent* event)
{ {
updateMask(); updateMask();
QWidget::resizeEvent(event); QSplitter::resizeEvent(event);
} }
} }