forked from qt-creator/qt-creator
ADS: Focus content widget when tab is clicked or dockwidget gets focus
Fixes: QDS-10396 Change-Id: Ic7d4a73ff535c0c0cb73e1e5bd636bec00a1336c Reviewed-by: Henning Gründl <henning.gruendl@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -112,6 +112,14 @@ void DockAreaTabBar::onTabClicked(DockWidgetTab *sourceTab)
|
|||||||
|
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
emit tabBarClicked(index);
|
emit tabBarClicked(index);
|
||||||
|
|
||||||
|
// QDS: Focus the actual content widget on tab click
|
||||||
|
DockWidgetTab *tab = currentTab();
|
||||||
|
if (tab && tab->dockWidget() && tab->dockWidget()->widget()) {
|
||||||
|
QMetaObject::invokeMethod(tab->dockWidget()->widget(),
|
||||||
|
QOverload<>::of(&QWidget::setFocus),
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockAreaTabBar::onTabCloseRequested(DockWidgetTab *sourceTab)
|
void DockAreaTabBar::onTabCloseRequested(DockWidgetTab *sourceTab)
|
||||||
|
@@ -231,6 +231,9 @@ void DockFocusController::onApplicationFocusChanged(QWidget *focusedOld, QWidget
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
DockWidget *dockWidget = qobject_cast<DockWidget *>(focusedNow);
|
DockWidget *dockWidget = qobject_cast<DockWidget *>(focusedNow);
|
||||||
|
|
||||||
|
bool focusActual = dockWidget && dockWidget->widget();
|
||||||
|
|
||||||
if (!dockWidget)
|
if (!dockWidget)
|
||||||
dockWidget = internal::findParent<DockWidget *>(focusedNow);
|
dockWidget = internal::findParent<DockWidget *>(focusedNow);
|
||||||
|
|
||||||
@@ -243,6 +246,12 @@ void DockFocusController::onApplicationFocusChanged(QWidget *focusedOld, QWidget
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
d->updateDockWidgetFocus(dockWidget);
|
d->updateDockWidgetFocus(dockWidget);
|
||||||
|
|
||||||
|
if (focusActual) {
|
||||||
|
// QDS: Focus the actual content widget when dockWidget gets focus
|
||||||
|
QMetaObject::invokeMethod(dockWidget->widget(), QOverload<>::of(&QWidget::setFocus),
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockFocusController::setDockWidgetTabFocused(DockWidgetTab *tab)
|
void DockFocusController::setDockWidgetTabFocused(DockWidgetTab *tab)
|
||||||
|
Reference in New Issue
Block a user