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