mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 15:41:34 +08:00
Improved emission of focusedDockWidgetChanged signal to ensure, that the application can restore the focus of the focused application dock widget content
This commit is contained in:
parent
0459aff34f
commit
aa25e1fd56
@ -138,6 +138,8 @@ CDockAreaTabBar::CDockAreaTabBar(CDockAreaWidget* parent) :
|
|||||||
d->TabsLayout->addStretch(1);
|
d->TabsLayout->addStretch(1);
|
||||||
d->TabsContainerWidget->setLayout(d->TabsLayout);
|
d->TabsContainerWidget->setLayout(d->TabsLayout);
|
||||||
setWidget(d->TabsContainerWidget);
|
setWidget(d->TabsContainerWidget);
|
||||||
|
|
||||||
|
setFocusPolicy(Qt::NoFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -269,6 +269,8 @@ CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) :
|
|||||||
d->createTabBar();
|
d->createTabBar();
|
||||||
d->Layout->addWidget(new CSpacerWidget(this));
|
d->Layout->addWidget(new CSpacerWidget(this));
|
||||||
d->createButtons();
|
d->createButtons();
|
||||||
|
|
||||||
|
setFocusPolicy(Qt::NoFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -606,7 +608,7 @@ CTitleBarButton::CTitleBarButton(bool visible, QWidget* parent)
|
|||||||
Visible(visible),
|
Visible(visible),
|
||||||
HideWhenDisabled(CDockManager::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
|
HideWhenDisabled(CDockManager::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
|
||||||
{
|
{
|
||||||
|
setFocusPolicy(Qt::NoFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
@ -44,6 +44,7 @@ struct DockFocusControllerPrivate
|
|||||||
QPointer<CFloatingDockContainer> FloatingWidget = nullptr;
|
QPointer<CFloatingDockContainer> FloatingWidget = nullptr;
|
||||||
#endif
|
#endif
|
||||||
CDockManager* DockManager;
|
CDockManager* DockManager;
|
||||||
|
bool ForceFocusChangedSignal = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@ -161,11 +162,12 @@ void DockFocusControllerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (old == DockWidget)
|
if (old == DockWidget && !ForceFocusChangedSignal)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ForceFocusChangedSignal = false;
|
||||||
if (DockWidget->isVisible())
|
if (DockWidget->isVisible())
|
||||||
{
|
{
|
||||||
emit DockManager->focusedDockWidgetChanged(old, DockWidget);
|
emit DockManager->focusedDockWidgetChanged(old, DockWidget);
|
||||||
@ -243,15 +245,18 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
|
|||||||
auto DockWidgetTab = qobject_cast<CDockWidgetTab*>(focusedNow);
|
auto DockWidgetTab = qobject_cast<CDockWidgetTab*>(focusedNow);
|
||||||
if (DockWidgetTab)
|
if (DockWidgetTab)
|
||||||
{
|
{
|
||||||
DockWidget = DockWidgetTab->dockWidget();
|
DockWidget = DockWidgetTab->dockWidget();
|
||||||
// If the DockWidgetTab "steals" the focus from a widget in the same
|
// If the DockWidgetTab "steals" the focus from a widget in the same
|
||||||
// DockWidget, then we immediately give the focus back to the previous
|
// DockWidget, then we immediately give the focus back to the previous
|
||||||
// focused widget focusedOld
|
// focused widget focusedOld
|
||||||
if (DockWidget == d->FocusedDockWidget && focusedOld && focusedOld != focusedNow)
|
if (focusedOld)
|
||||||
{
|
{
|
||||||
focusedOld->setFocus();
|
auto OldFocusedDockWidget = internal::findParent<CDockWidget*>(focusedOld);
|
||||||
return;
|
if (OldFocusedDockWidget && OldFocusedDockWidget == DockWidget)
|
||||||
}
|
{
|
||||||
|
focusedOld->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DockWidget)
|
if (!DockWidget)
|
||||||
@ -322,6 +327,7 @@ void CDockFocusController::notifyWidgetOrAreaRelocation(QWidget* DroppedWidget)
|
|||||||
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(DroppedWidget);
|
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(DroppedWidget);
|
||||||
if (DockWidget)
|
if (DockWidget)
|
||||||
{
|
{
|
||||||
|
d->ForceFocusChangedSignal = true;
|
||||||
CDockManager::setWidgetFocus(DockWidget->tabWidget());
|
CDockManager::setWidgetFocus(DockWidget->tabWidget());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -333,6 +339,7 @@ void CDockFocusController::notifyWidgetOrAreaRelocation(QWidget* DroppedWidget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DockWidget = DockArea->currentDockWidget();
|
DockWidget = DockArea->currentDockWidget();
|
||||||
|
d->ForceFocusChangedSignal = true;
|
||||||
CDockManager::setWidgetFocus(DockWidget->tabWidget());
|
CDockManager::setWidgetFocus(DockWidget->tabWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user