forked from qt-creator/qt-creator
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 <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
cc80ba2a7e
commit
08f807a134
@@ -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,
|
||||
|
Reference in New Issue
Block a user