forked from qt-creator/qt-creator
QmlDesigner: Focus the content widget of the dock when focusing tab
When DockWidgetTab or DockWidget is focused, typically user actually wants to focus the content widget, so we now do that. Focusing content widget is done asynchronously to avoid complications from doing another setFocus in middle of setFocus handling. Fixes: QDS-9104 Change-Id: I569639c2f36f0721aafcdcab3498c875e98993a9 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -9,6 +9,7 @@ import StudioTheme 1.0 as StudioTheme
|
||||
|
||||
Item {
|
||||
id: root
|
||||
focus: true
|
||||
|
||||
readonly property int cellWidth: 100
|
||||
readonly property int cellHeight: 120
|
||||
|
@@ -162,6 +162,8 @@ namespace ADS
|
||||
if (!dockWidget)
|
||||
dockWidget = qobject_cast<DockWidget *>(focusedNow);
|
||||
|
||||
bool focusActual = dockWidget && dockWidget->widget();
|
||||
|
||||
if (!dockWidget)
|
||||
dockWidget = internal::findParent<DockWidget *>(focusedNow);
|
||||
|
||||
@@ -174,6 +176,12 @@ namespace ADS
|
||||
#endif
|
||||
|
||||
d->updateDockWidgetFocus(dockWidget);
|
||||
|
||||
if (focusActual) {
|
||||
// Do this async to avoid issues when changing focus in middle of another focus handling
|
||||
QMetaObject::invokeMethod(dockWidget->widget(), QOverload<>::of(&QWidget::setFocus),
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void DockFocusController::setDockWidgetFocused(DockWidget *focusedNow)
|
||||
|
@@ -207,6 +207,8 @@ MaterialBrowserWidget::MaterialBrowserWidget(AsynchronousImageCache &imageCache,
|
||||
QmlDesignerPlugin::trackWidgetFocusTime(this, Constants::EVENT_MATERIALBROWSER_TIME);
|
||||
|
||||
reloadQmlSource();
|
||||
|
||||
setFocusProxy(m_quickWidget.data());
|
||||
}
|
||||
|
||||
void MaterialBrowserWidget::updateMaterialPreview(const ModelNode &node, const QPixmap &pixmap)
|
||||
|
@@ -66,6 +66,8 @@ NavigatorWidget::NavigatorWidget(NavigatorView *view)
|
||||
setStyleSheet(Theme::replaceCssColors(QString::fromUtf8(sheet)));
|
||||
|
||||
QmlDesignerPlugin::trackWidgetFocusTime(this, Constants::EVENT_NAVIGATORVIEW_TIME);
|
||||
|
||||
setFocusProxy(m_treeView);
|
||||
}
|
||||
|
||||
void NavigatorWidget::setTreeModel(QAbstractItemModel *model)
|
||||
|
Reference in New Issue
Block a user