From 0fbb7178033fd02a7a6d26e5d3c9a1421c90aeec Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 6 Sep 2018 12:32:30 +0100 Subject: [PATCH] Allow hitting enter with a selected filename to enter a directory --- .../Windows/Dialogs/VirtualFileDialog.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp b/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp index f1671bdc1..5328108b1 100644 --- a/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp @@ -765,21 +765,21 @@ void VirtualFileDialog::on_filename_keyPress(QKeyEvent *e) re.setPatternSyntax(QRegExp::Wildcard); int fileCount = m_FileProxy->rowCount(curDir); - int matches = 0; + int matches = 0, dirmatches = 0; QString match; + QModelIndex idx; for(int f = 0; f < fileCount; f++) { QModelIndex file = m_FileProxy->index(f, 0, curDir); bool isDir = m_FileProxy->data(file, RemoteFileModel::FileIsDirRole).toBool(); - if(isDir) - continue; - QString filename = m_FileProxy->data(file, RemoteFileModel::FileNameRole).toString(); if(re.exactMatch(filename)) { + idx = file; + dirmatches += isDir ? 1 : 0; matches++; match = m_FileProxy->data(file, RemoteFileModel::FilePathRole).toString(); } @@ -787,8 +787,16 @@ void VirtualFileDialog::on_filename_keyPress(QKeyEvent *e) if(matches == 1) { - m_ChosenPath = match; - QDialog::accept(); + if(dirmatches == 1) + { + changeCurrentDir(m_FileProxy->mapToSource(idx)); + return; + } + else + { + m_ChosenPath = match; + QDialog::accept(); + } } if(matches == 0 && !text.trimmed().isEmpty())