Commit 8e62881b authored by Eike Ziller's avatar Eike Ziller

Make DocumentManager::projectsDirectory a FileName

Change-Id: I9454c2148c398939c64bfa6b1fc182670a1d5f99
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent a7e2d0cf
......@@ -184,7 +184,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
expander->registerVariable("CurrentTime:Locale", tr("The current time (Locale)."),
[]() { return QTime::currentTime().toString(Qt::DefaultLocaleShortDate); });
expander->registerVariable("Config:DefaultProjectDirectory", tr("The configured default directory for projects."),
[]() { return DocumentManager::projectsDirectory(); });
[]() { return DocumentManager::projectsDirectory().toString(); });
expander->registerVariable("Config:LastFileDialogDirectory", tr("The directory last visited in a file dialog."),
[]() { return DocumentManager::fileDialogLastVisitedDirectory(); });
expander->registerVariable("HostOs:isWindows",
......
......@@ -159,7 +159,7 @@ public:
bool m_checkOnFocusChange = false;
QString m_lastVisitedDirectory;
QString m_defaultLocationForNewFiles;
QString m_projectsDirectory;
FileName m_projectsDirectory;
bool m_useProjectsDirectory;
QString m_buildDirectory;
// When we are calling into an IDocument
......@@ -238,7 +238,7 @@ DocumentManager::DocumentManager(QObject *parent)
readSettings();
if (d->m_useProjectsDirectory)
setFileDialogLastVisitedDirectory(d->m_projectsDirectory);
setFileDialogLastVisitedDirectory(d->m_projectsDirectory.toString());
}
DocumentManager::~DocumentManager()
......@@ -1260,7 +1260,7 @@ void DocumentManager::saveSettings()
s->setValue(QLatin1String(editorsKeyC), recentEditorIds);
s->endGroup();
s->beginGroup(QLatin1String(directoryGroupC));
s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory);
s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory.toString());
s->setValue(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory);
s->setValue(QLatin1String(buildDirectoryKeyC), d->m_buildDirectory);
s->endGroup();
......@@ -1286,12 +1286,12 @@ void readSettings()
}
s->beginGroup(QLatin1String(directoryGroupC));
const QString settingsProjectDir = s->value(QLatin1String(projectDirectoryKeyC),
QString()).toString();
if (!settingsProjectDir.isEmpty() && QFileInfo(settingsProjectDir).isDir())
const FileName settingsProjectDir = FileName::fromString(s->value(QLatin1String(projectDirectoryKeyC),
QString()).toString());
if (!settingsProjectDir.isEmpty() && settingsProjectDir.toFileInfo().isDir())
d->m_projectsDirectory = settingsProjectDir;
else
d->m_projectsDirectory = PathChooser::homePath();
d->m_projectsDirectory = FileName::fromString(PathChooser::homePath());
d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC),
d->m_useProjectsDirectory).toBool();
......@@ -1351,7 +1351,7 @@ void DocumentManager::setDefaultLocationForNewFiles(const QString &location)
\sa setProjectsDirectory, setUseProjectsDirectory
*/
QString DocumentManager::projectsDirectory()
FileName DocumentManager::projectsDirectory()
{
return d->m_projectsDirectory;
}
......@@ -1363,9 +1363,9 @@ QString DocumentManager::projectsDirectory()
\sa projectsDirectory, useProjectsDirectory
*/
void DocumentManager::setProjectsDirectory(const QString &dir)
void DocumentManager::setProjectsDirectory(const FileName &directory)
{
d->m_projectsDirectory = dir;
d->m_projectsDirectory = directory;
}
/*!
......
......@@ -128,8 +128,8 @@ public:
static bool useProjectsDirectory();
static void setUseProjectsDirectory(bool);
static QString projectsDirectory();
static void setProjectsDirectory(const QString &);
static Utils::FileName projectsDirectory();
static void setProjectsDirectory(const Utils::FileName &directory);
static QString buildDirectory();
static void setBuildDirectory(const QString &directory);
......
......@@ -33,6 +33,7 @@
#include <extensionsystem/pluginspec.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <utils/wizard.h>
......@@ -255,9 +256,9 @@ QString IWizardFactory::runPath(const QString &defaultPath)
// Project wizards: Check for projects directory or
// use last visited directory of file dialog. Never start
// at current.
path = DocumentManager::useProjectsDirectory() ?
DocumentManager::projectsDirectory() :
DocumentManager::fileDialogLastVisitedDirectory();
path = DocumentManager::useProjectsDirectory()
? DocumentManager::projectsDirectory().toString()
: DocumentManager::fileDialogLastVisitedDirectory();
break;
default:
path = DocumentManager::fileDialogInitialDirectory();
......
......@@ -520,7 +520,7 @@ QString GerritPlugin::findLocalRepository(QString project, const QString &branch
} // for repositories
// No match, do we have a projects folder?
if (DocumentManager::useProjectsDirectory())
return DocumentManager::projectsDirectory();
return DocumentManager::projectsDirectory().toString();
return QDir::currentPath();
}
......
......@@ -26,6 +26,7 @@
#include "baseprojectwizarddialog.h"
#include <coreplugin/documentmanager.h>
#include <utils/fileutils.h>
#include <utils/projectintropage.h>
#include <QDir>
......@@ -144,7 +145,7 @@ void BaseProjectWizardDialog::slotAccepted()
{
if (d->introPage->useAsDefaultPath()) {
// Store the path as default path for new projects if desired.
Core::DocumentManager::setProjectsDirectory(path());
Core::DocumentManager::setProjectsDirectory(Utils::FileName::fromString(path()));
Core::DocumentManager::setUseProjectsDirectory(true);
}
}
......
......@@ -28,6 +28,7 @@
#include <coreplugin/documentmanager.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <QDir>
......@@ -51,7 +52,7 @@ bool JsonProjectPage::validatePage()
{
if (isComplete() && useAsDefaultPath()) {
// Store the path as default path for new projects if desired.
Core::DocumentManager::setProjectsDirectory(path());
Core::DocumentManager::setProjectsDirectory(Utils::FileName::fromString(path()));
Core::DocumentManager::setUseProjectsDirectory(true);
}
......
......@@ -3545,7 +3545,9 @@ QStringList ProjectExplorerPlugin::projectFilePatterns()
void ProjectExplorerPlugin::openOpenProjectDialog()
{
const QString path = DocumentManager::useProjectsDirectory() ? DocumentManager::projectsDirectory() : QString();
const QString path = DocumentManager::useProjectsDirectory()
? DocumentManager::projectsDirectory().toString()
: QString();
const QStringList files = DocumentManager::getOpenFileNames(dd->m_projectFilterString, path);
if (!files.isEmpty())
ICore::openFiles(files, ICore::SwitchMode);
......
......@@ -198,7 +198,7 @@ QWidget *ProjectExplorerSettingsPage::widget()
if (!m_widget) {
m_widget = new ProjectExplorerSettingsWidget;
m_widget->setSettings(ProjectExplorerPlugin::projectExplorerSettings());
m_widget->setProjectsDirectory(Core::DocumentManager::projectsDirectory());
m_widget->setProjectsDirectory(Core::DocumentManager::projectsDirectory().toString());
m_widget->setUseProjectsDirectory(Core::DocumentManager::useProjectsDirectory());
m_widget->setBuildDirectory(Core::DocumentManager::buildDirectory());
}
......@@ -209,7 +209,8 @@ void ProjectExplorerSettingsPage::apply()
{
if (m_widget) {
ProjectExplorerPlugin::setProjectExplorerSettings(m_widget->settings());
Core::DocumentManager::setProjectsDirectory(m_widget->projectsDirectory());
Core::DocumentManager::setProjectsDirectory(
Utils::FileName::fromString(m_widget->projectsDirectory()));
Core::DocumentManager::setUseProjectsDirectory(m_widget->useProjectsDirectory());
Core::DocumentManager::setBuildDirectory(m_widget->buildDirectory());
}
......
......@@ -124,7 +124,7 @@ QString ExamplesWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileI
chooser->setHistoryCompleter(QLatin1String("Qt.WritableExamplesDir.History"));
QSettings *settings = ICore::settings();
chooser->setPath(settings->value(QString::fromLatin1(C_FALLBACK_ROOT),
DocumentManager::projectsDirectory()).toString());
DocumentManager::projectsDirectory().toString()).toString());
lay->addWidget(txt, 1, 0);
lay->addWidget(chooser, 1, 1);
enum { Copy = QDialog::Accepted + 1, Keep = QDialog::Accepted + 2 };
......
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