1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-04-01 02:42:39 +08:00

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; 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 * dock area at this position
*/ */
CDockAreaWidget* dockAreaAt(const QPoint& GlobalPos) const; CDockAreaWidget* dockAreaAt(const QPoint& GlobalPos) const;

View File

@ -943,6 +943,7 @@ void CDockManager::onFocusObjectChanged(QObject *focusObject)
if (d->FocusedArea) if (d->FocusedArea)
{ {
disconnect(d->FocusedArea, SIGNAL(viewToggled(bool)), this, SLOT(onFocusedDockAreaViewToggled(bool)));
d->FocusedArea->setProperty("focused", false); d->FocusedArea->setProperty("focused", false);
internal::repolishStyle(d->FocusedArea); internal::repolishStyle(d->FocusedArea);
internal::repolishStyle(d->FocusedArea->titleBar()); internal::repolishStyle(d->FocusedArea->titleBar());
@ -952,8 +953,10 @@ void CDockManager::onFocusObjectChanged(QObject *focusObject)
internal::repolishStyle(NewFocusedDockArea); internal::repolishStyle(NewFocusedDockArea);
internal::repolishStyle(NewFocusedDockArea->titleBar()); internal::repolishStyle(NewFocusedDockArea->titleBar());
d->FocusedArea = NewFocusedDockArea; d->FocusedArea = NewFocusedDockArea;
connect(d->FocusedArea, SIGNAL(viewToggled(bool)), this, SLOT(onFocusedDockAreaViewToggled(bool)));
} }
//=========================================================================== //===========================================================================
void CDockManager::onFocusedDockWidgetClosed() 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 } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

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