Skip to content


[ux] Make QgsFileWidget file picker default to opening at the
Browse files Browse the repository at this point in the history
currently displayed folder, if one is shown

And only fallback to the default root path if no file name has
been entered.

This change improves the UX of the widget, because it allows
users to manually enter a path (or paste a filename, etc)
into the widget and THEN click the browse button to tweak
that current location. Otherwise we always jump back to
some historic location on clicking that button, which is
  • Loading branch information
nyalldawson committed Oct 11, 2018
1 parent 46938c0 commit dc08db7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/gui/qgsfilewidget.cpp
Expand Up @@ -221,16 +221,18 @@ void QgsFileWidget::openFileDialog()
QgsSettings settings;
QString oldPath;

// If we use fixed default path
if ( !mDefaultRoot.isEmpty() )
oldPath = QDir::cleanPath( mDefaultRoot );
// if we use a relative path option, we need to obtain the full path
else if ( !mFilePath.isEmpty() )
// first choice is the current file path, if one is entered
if ( !mFilePath.isEmpty() )
oldPath = relativePath( mFilePath, false );
// If we use fixed default path
// second choice is the default root
else if ( !mDefaultRoot.isEmpty() )
oldPath = QDir::cleanPath( mDefaultRoot );

// If there is no valid value, find a default path to use
QUrl url = QUrl::fromUserInput( oldPath );
Expand Down

0 comments on commit dc08db7

Please sign in to comment.