Skip to content

Commit dc08db7

Browse files
committed
[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 annoying.
1 parent 46938c0 commit dc08db7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/gui/qgsfilewidget.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,18 @@ void QgsFileWidget::openFileDialog()
221221
QgsSettings settings;
222222
QString oldPath;
223223

224-
// If we use fixed default path
225-
if ( !mDefaultRoot.isEmpty() )
226-
{
227-
oldPath = QDir::cleanPath( mDefaultRoot );
228-
}
229224
// if we use a relative path option, we need to obtain the full path
230-
else if ( !mFilePath.isEmpty() )
225+
// first choice is the current file path, if one is entered
226+
if ( !mFilePath.isEmpty() )
231227
{
232228
oldPath = relativePath( mFilePath, false );
233229
}
230+
// If we use fixed default path
231+
// second choice is the default root
232+
else if ( !mDefaultRoot.isEmpty() )
233+
{
234+
oldPath = QDir::cleanPath( mDefaultRoot );
235+
}
234236

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

0 commit comments

Comments
 (0)