Improved focus setting when closing a dock area widget

This commit is contained in:
Uwe Kindler 2020-05-13 13:18:05 +02:00
parent 64a2024513
commit 4c75168152
3 changed files with 24 additions and 1 deletions

View File

@ -193,7 +193,7 @@ public:
bool isInFrontOf(CDockContainerWidget* Other) const;
/**
* Returns the dock area at teh given global position or 0 if there is no
* Returns the dock area at the given global position or 0 if there is no
* dock area at this position
*/
CDockAreaWidget* dockAreaAt(const QPoint& GlobalPos) const;

View File

@ -943,6 +943,7 @@ void CDockManager::onFocusObjectChanged(QObject *focusObject)
if (d->FocusedArea)
{
disconnect(d->FocusedArea, SIGNAL(viewToggled(bool)), this, SLOT(onFocusedDockAreaViewToggled(bool)));
d->FocusedArea->setProperty("focused", false);
internal::repolishStyle(d->FocusedArea);
internal::repolishStyle(d->FocusedArea->titleBar());
@ -952,8 +953,10 @@ void CDockManager::onFocusObjectChanged(QObject *focusObject)
internal::repolishStyle(NewFocusedDockArea);
internal::repolishStyle(NewFocusedDockArea->titleBar());
d->FocusedArea = NewFocusedDockArea;
connect(d->FocusedArea, SIGNAL(viewToggled(bool)), this, SLOT(onFocusedDockAreaViewToggled(bool)));
}
//===========================================================================
void CDockManager::onFocusedDockWidgetClosed()
{
@ -961,6 +964,25 @@ void CDockManager::onFocusedDockWidgetClosed()
}
//===========================================================================
void CDockManager::onFocusedDockAreaViewToggled(bool Open)
{
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(sender());
if (!DockArea || Open)
{
return;
}
auto Container = DockArea->dockContainer();
auto OpenedDockAreas = Container->openedDockAreas();
if (OpenedDockAreas.isEmpty())
{
return;
}
OpenedDockAreas[0]->currentDockWidget()->tabWidget()->setFocus(Qt::OtherFocusReason);
}
} // namespace ads
//---------------------------------------------------------------------------

View File

@ -87,6 +87,7 @@ private:
private slots:
void onFocusObjectChanged(QObject *focusObject);
void onFocusedDockWidgetClosed();
void onFocusedDockAreaViewToggled(bool Open);
protected:
/**