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
|
contextMenu: contextMenu
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height - assetsView.y
|
height: parent.height - assetsView.y
|
||||||
|
focus: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -348,22 +348,21 @@ TreeView {
|
|||||||
root.currentFilePath = filePath
|
root.currentFilePath = filePath
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.enabled: true
|
function moveSelection(amount)
|
||||||
|
{
|
||||||
Keys.onUpPressed: {
|
if (!assetsModel.haveFiles || !amount)
|
||||||
if (!root.currentFilePath)
|
|
||||||
return
|
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 row = root.rowAtIndex(index)
|
||||||
let nextRow = row
|
let nextRow = row
|
||||||
let nextIndex = index
|
let nextIndex = index
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (nextRow <= root.firstRow)
|
nextRow = nextRow + amount
|
||||||
return // don't select hidden rows
|
if ((amount < 0 && nextRow < root.firstRow) || (amount > 0 && nextRow > root.lastRow))
|
||||||
|
return
|
||||||
nextRow--
|
|
||||||
nextIndex = root.__modelIndex(nextRow)
|
nextIndex = root.__modelIndex(nextRow)
|
||||||
} while (assetsModel.isDirectory(nextIndex))
|
} while (assetsModel.isDirectory(nextIndex))
|
||||||
|
|
||||||
@@ -371,26 +370,14 @@ TreeView {
|
|||||||
root.positionViewAtRow(nextRow, TableView.Contain)
|
root.positionViewAtRow(nextRow, TableView.Contain)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Keys.enabled: true
|
||||||
|
|
||||||
|
Keys.onUpPressed: {
|
||||||
|
moveSelection(-1)
|
||||||
|
}
|
||||||
|
|
||||||
Keys.onDownPressed: {
|
Keys.onDownPressed: {
|
||||||
if (!root.currentFilePath)
|
moveSelection(1)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmDeleteFilesDialog {
|
ConfirmDeleteFilesDialog {
|
||||||
|
@@ -151,6 +151,8 @@ AssetsLibraryWidget::AssetsLibraryWidget(AsynchronousImageCache &asynchronousFon
|
|||||||
|
|
||||||
// init the first load of the QML UI elements
|
// init the first load of the QML UI elements
|
||||||
reloadQmlSource();
|
reloadQmlSource();
|
||||||
|
|
||||||
|
setFocusProxy(m_assetsWidget->quickWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetsLibraryWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
void AssetsLibraryWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||||
|
Reference in New Issue
Block a user