forked from qt-creator/qt-creator
QmlDesigner: Improve keyboard navigation on assets view
keyboard navigation now works when you focus the tab without requiring to also click on the treeview itself. Fixes: QDS-10397 Change-Id: I2cda08365c1a68c72121166d4fd50f1786f913bc Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -264,6 +264,7 @@ Item {
|
||||
contextMenu: contextMenu
|
||||
width: parent.width
|
||||
height: parent.height - assetsView.y
|
||||
focus: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user