diff --git a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/Assets.qml b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/Assets.qml index 211d3449a85..502b67f6c65 100644 --- a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/Assets.qml +++ b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/Assets.qml @@ -264,6 +264,7 @@ Item { contextMenu: contextMenu width: parent.width height: parent.height - assetsView.y + focus: true } } } diff --git a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetsView.qml b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetsView.qml index ede7f58cafb..e4380a19b39 100644 --- a/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetsView.qml +++ b/share/qtcreator/qmldesigner/assetsLibraryQmlSources/AssetsView.qml @@ -348,22 +348,21 @@ TreeView { root.currentFilePath = filePath } - Keys.enabled: true - - Keys.onUpPressed: { - if (!root.currentFilePath) + function moveSelection(amount) + { + if (!assetsModel.haveFiles || !amount) return - let index = assetsModel.indexForPath(root.currentFilePath) + let index = root.currentFilePath ? assetsModel.indexForPath(root.currentFilePath) + : root.__modelIndex(root.firstRow) let row = root.rowAtIndex(index) let nextRow = row let nextIndex = index do { - if (nextRow <= root.firstRow) - return // don't select hidden rows - - nextRow-- + nextRow = nextRow + amount + if ((amount < 0 && nextRow < root.firstRow) || (amount > 0 && nextRow > root.lastRow)) + return nextIndex = root.__modelIndex(nextRow) } while (assetsModel.isDirectory(nextIndex)) @@ -371,26 +370,14 @@ TreeView { root.positionViewAtRow(nextRow, TableView.Contain) } + Keys.enabled: true + + Keys.onUpPressed: { + moveSelection(-1) + } + Keys.onDownPressed: { - if (!root.currentFilePath) - return - - let index = assetsModel.indexForPath(root.currentFilePath) - let row = root.rowAtIndex(index) - - let nextRow = row - let nextIndex = index - - do { - if (nextRow >= root.lastRow) - return // don't select hidden rows - - nextRow++ - nextIndex = root.__modelIndex(nextRow) - } while (assetsModel.isDirectory(nextIndex)) - - root.__selectRow(nextRow) - root.positionViewAtRow(nextRow, TableView.Contain) + moveSelection(1) } ConfirmDeleteFilesDialog { diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp index 9a8a611c664..48d10a34d20 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp @@ -151,6 +151,8 @@ AssetsLibraryWidget::AssetsLibraryWidget(AsynchronousImageCache &asynchronousFon // init the first load of the QML UI elements reloadQmlSource(); + + setFocusProxy(m_assetsWidget->quickWidget()); } void AssetsLibraryWidget::contextHelp(const Core::IContext::HelpCallback &callback) const