Improved focus handling when dropping a dock widget

This commit is contained in:
Uwe Kindler 2020-05-14 09:06:04 +02:00
parent c5333a2414
commit e760d3e967
2 changed files with 12 additions and 6 deletions

View File

@ -413,6 +413,7 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
bool Activate)
{
d->ContentsLayout->insertWidget(index, DockWidget);
DockWidget->setDockArea(this);
DockWidget->tabWidget()->setDockAreaWidget(this);
auto TabWidget = DockWidget->tabWidget();
// Inserting the tab will change the current index which in turn will
@ -428,7 +429,6 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
{
setCurrentIndex(index);
}
DockWidget->setDockArea(this);
d->updateTitleBarButtonStates();
}

View File

@ -463,15 +463,21 @@ void CDockWidgetTab::setActiveTab(bool active)
bool AllTabsHaveCloseButton = d->testConfigFlag(CDockManager::AllTabsHaveCloseButton);
bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton;
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
if (d->IsActiveTab == active)
{
return;
}
bool UpdateFocusStyle = false;
if (active && !hasFocus())
{
std::cout << "setFocus(Qt::OtherFocusReason);" << std::endl;
setFocus(Qt::OtherFocusReason);
UpdateFocusStyle = true;
}
if (d->IsActiveTab == active)
{
if (UpdateFocusStyle)
{
updateStyle();
}
return;
}
d->IsActiveTab = active;
updateStyle();