Skip to content
Browse files
[ux] Make QgsFileWidget file picker default to opening at the
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 dc08db79ed637e40f188ebb7530014821af67080
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/gui/qgsfilewidget.cpp
@@ -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 );

0 comments on commit dc08db7

Please sign in to comment.