Commit 08f807a1 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Core: Use a consistent initial directory in open/save/locator

Use fileDialogInitialDirectory() for all of them.

Conditionally initialize lastVisitedDirectory to projects directory to
preserve existing behavior on Open, when no project is open yet.

Change-Id: I318a7c7741e70a68758f0cc068ce956135103f3f
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent cc80ba2a
......@@ -229,6 +229,9 @@ DocumentManager::DocumentManager(QObject *parent)
qApp->installEventFilter(this);
readSettings();
if (d->m_useProjectsDirectory)
setFileDialogLastVisitedDirectory(d->m_projectsDirectory);
}
DocumentManager::~DocumentManager()
......@@ -886,13 +889,7 @@ QStringList DocumentManager::getOpenFileNames(const QString &filters,
const QString &pathIn,
QString *selectedFilter)
{
QString path = pathIn;
if (path.isEmpty()) {
if (EditorManager::currentDocument() && !EditorManager::currentDocument()->isTemporary())
path = EditorManager::currentDocument()->filePath().toString();
if (path.isEmpty() && useProjectsDirectory())
path = projectsDirectory();
}
const QString &path = pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn;
const QStringList files = QFileDialog::getOpenFileNames(ICore::dialogParent(),
tr("Open File"),
path, filters,
......
......@@ -26,6 +26,7 @@
#include "filesystemfilter.h"
#include "locatorwidget.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/idocument.h>
......@@ -63,13 +64,7 @@ FileSystemFilter::FileSystemFilter(LocatorWidget *locatorWidget)
void FileSystemFilter::prepareSearch(const QString &entry)
{
Q_UNUSED(entry)
IDocument *document= EditorManager::currentDocument();
if (document && !document->filePath().isEmpty()) {
const QFileInfo info = document->filePath().toFileInfo();
m_currentDocumentDirectory = info.absolutePath() + QLatin1Char('/');
} else {
m_currentDocumentDirectory.clear();
}
m_currentDocumentDirectory = DocumentManager::fileDialogInitialDirectory();
}
QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment