forked from qt-creator/qt-creator
Add option to place shadow build directory parallel to source tree.
This option requires that the projects directory setting is enabled. For example with the following settings: Projects directory: $HOME/depot Build directory: $HOME/build This will by default place the default shadow build directory in the $HOME/build tree instead of adjacent to the source in $HOME/depot. Change-Id: I74bfc00883d0479d5965350c760d14ef7602cc34 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -97,6 +97,8 @@ static const char editorsKeyC[] = "EditorIds";
|
||||
static const char directoryGroupC[] = "Directories";
|
||||
static const char projectDirectoryKeyC[] = "Projects";
|
||||
static const char useProjectDirectoryKeyC[] = "UseProjectsDirectory";
|
||||
static const char buildDirectoryKeyC[] = "BuildDirectory";
|
||||
static const char useBuildDirectoryKeyC[] = "UseBuildDirectory";
|
||||
|
||||
|
||||
namespace Core {
|
||||
@@ -156,6 +158,8 @@ struct DocumentManagerPrivate
|
||||
QString m_lastVisitedDirectory;
|
||||
QString m_projectsDirectory;
|
||||
bool m_useProjectsDirectory;
|
||||
QString m_buildDirectory;
|
||||
bool m_useBuildDirectory;
|
||||
// When we are callling into a IDocument
|
||||
// we don't want to receive a changed()
|
||||
// signal
|
||||
@@ -198,6 +202,7 @@ DocumentManagerPrivate::DocumentManagerPrivate(QMainWindow *mw) :
|
||||
m_blockActivated(false),
|
||||
m_lastVisitedDirectory(QDir::currentPath()),
|
||||
m_useProjectsDirectory(Utils::HostOsInfo::isMacHost()), // Creator is in bizarre places when launched via finder.
|
||||
m_useBuildDirectory(false),
|
||||
m_blockedIDocument(0)
|
||||
{
|
||||
}
|
||||
@@ -1165,6 +1170,8 @@ void DocumentManager::saveSettings()
|
||||
s->beginGroup(QLatin1String(directoryGroupC));
|
||||
s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory);
|
||||
s->setValue(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory);
|
||||
s->setValue(QLatin1String(buildDirectoryKeyC), d->m_buildDirectory);
|
||||
s->setValue(QLatin1String(useBuildDirectoryKeyC), d->m_useBuildDirectory);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
@@ -1197,6 +1204,16 @@ void readSettings()
|
||||
}
|
||||
d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC),
|
||||
d->m_useProjectsDirectory).toBool();
|
||||
|
||||
const QString settingsShadowDir = s->value(QLatin1String(buildDirectoryKeyC),
|
||||
QString()).toString();
|
||||
if (!settingsShadowDir.isEmpty() && QFileInfo(settingsShadowDir).isDir())
|
||||
d->m_buildDirectory = settingsShadowDir;
|
||||
else
|
||||
d->m_buildDirectory = Utils::PathChooser::homePath();
|
||||
|
||||
d->m_useBuildDirectory = s->value(QLatin1String(useBuildDirectoryKeyC),
|
||||
d->m_useBuildDirectory).toBool();
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
@@ -1267,6 +1284,47 @@ void DocumentManager::setProjectsDirectory(const QString &dir)
|
||||
d->m_projectsDirectory = dir;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns whether the default shadow build directory is placed adjacent to the source in the
|
||||
projects directory or in a separate build tree.
|
||||
|
||||
\sa setUseBuildDirectory, setBuildDirectory
|
||||
*/
|
||||
bool DocumentManager::useBuildDirectory()
|
||||
{
|
||||
return d->m_useBuildDirectory;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets whether a separate build directory is to the used when shadow building.
|
||||
|
||||
\sa buildDirectory, usebuildDirectory
|
||||
*/
|
||||
void DocumentManager::setUseBuildDirectory(bool use)
|
||||
{
|
||||
d->m_useBuildDirectory = use;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the shadow build directory.
|
||||
|
||||
\sa setBuildDirectory, useBuildDirectory
|
||||
*/
|
||||
QString DocumentManager::buildDirectory()
|
||||
{
|
||||
return d->m_buildDirectory;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the shadow build directory to \a directory.
|
||||
|
||||
\sa buildDirectory, useBuildDirectory
|
||||
*/
|
||||
void DocumentManager::setBuildDirectory(const QString &directory)
|
||||
{
|
||||
d->m_buildDirectory = directory;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Returns whether the directory for projects is to be
|
||||
|
||||
@@ -129,6 +129,12 @@ public:
|
||||
static QString projectsDirectory();
|
||||
static void setProjectsDirectory(const QString &);
|
||||
|
||||
static bool useBuildDirectory();
|
||||
static void setUseBuildDirectory(bool use);
|
||||
|
||||
static QString buildDirectory();
|
||||
static void setBuildDirectory(const QString &directory);
|
||||
|
||||
static void populateOpenWithMenu(QMenu *menu, const QString &fileName);
|
||||
|
||||
/* Used to notify e.g. the code model to update the given files. Does *not*
|
||||
|
||||
Reference in New Issue
Block a user