summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorAaron McCarthy <mccarthy.aaron@gmail.com>2012-10-05 21:34:09 +1000
committerAaron McCarthy <mccarthy.aaron@gmail.com>2012-10-27 10:27:50 +0200
commit1b3909e45a18648cd635c082b0839688206ae3cb (patch)
treed41bcea80e6621fbe3b48234f48e7af29256f83b /src/plugins
parent2198fa90eb078a130a77924fbea56fda1696a365 (diff)
downloadqt-creator-1b3909e45a18648cd635c082b0839688206ae3cb.tar.gz
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>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp58
-rw-r--r--src/plugins/coreplugin/documentmanager.h6
-rw-r--r--src/plugins/projectexplorer/projectexplorersettingspage.cpp39
-rw-r--r--src/plugins/projectexplorer/projectexplorersettingspage.h7
-rw-r--r--src/plugins/projectexplorer/projectexplorersettingspage.ui24
-rw-r--r--src/plugins/qt4projectmanager/qt4project.cpp23
6 files changed, 150 insertions, 7 deletions
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index 88f55cdd2b..50d818b851 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -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();
}
@@ -1268,6 +1285,47 @@ void DocumentManager::setProjectsDirectory(const QString &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
used or the user wants the current directory.
diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h
index 939f1bfdc5..7d5ba7a84d 100644
--- a/src/plugins/coreplugin/documentmanager.h
+++ b/src/plugins/coreplugin/documentmanager.h
@@ -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*
diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp
index 830efb5f5d..bb40f64a20 100644
--- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp
+++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp
@@ -53,6 +53,8 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget(QWidget *parent) :
m_ui.directoryButtonGroup->setId(m_ui.directoryRadioButton, UseProjectDirectory);
connect(m_ui.directoryButtonGroup, SIGNAL(buttonClicked(int)),
this, SLOT(slotDirectoryButtonGroupChanged()));
+ connect(m_ui.buildDirectoryCheckBox, SIGNAL(toggled(bool)),
+ this, SLOT(slotBuildDirectoryCheckBoxChanged(bool)));
}
void ProjectExplorerSettingsWidget::setJomVisible(bool v)
@@ -118,9 +120,40 @@ void ProjectExplorerSettingsWidget::setUseProjectsDirectory(bool b)
}
}
+bool ProjectExplorerSettingsWidget::useBuildDirectory() const
+{
+ return m_ui.buildDirectoryCheckBox->isChecked();
+}
+
+void ProjectExplorerSettingsWidget::setUseBuildDirectory(bool v)
+{
+ if (useBuildDirectory() != v) {
+ m_ui.buildDirectoryCheckBox->setChecked(v);
+ slotBuildDirectoryCheckBoxChanged(v);
+ }
+}
+
+QString ProjectExplorerSettingsWidget::buildDirectory() const
+{
+ return m_ui.buildDirectoryPathChooser->path();
+}
+
+void ProjectExplorerSettingsWidget::setBuildDirectory(const QString &bd)
+{
+ m_ui.buildDirectoryPathChooser->setPath(bd);
+}
+
void ProjectExplorerSettingsWidget::slotDirectoryButtonGroupChanged()
{
- m_ui.projectsDirectoryPathChooser->setEnabled(useProjectsDirectory());
+ bool enable = useProjectsDirectory();
+ m_ui.projectsDirectoryPathChooser->setEnabled(enable);
+ m_ui.buildDirectoryCheckBox->setEnabled(enable);
+ m_ui.buildDirectoryPathChooser->setEnabled(enable && useBuildDirectory());
+}
+
+void ProjectExplorerSettingsWidget::slotBuildDirectoryCheckBoxChanged(bool checked)
+{
+ m_ui.buildDirectoryPathChooser->setEnabled(useProjectsDirectory() && checked);
}
QString ProjectExplorerSettingsWidget::searchKeywords() const
@@ -167,6 +200,8 @@ QWidget *ProjectExplorerSettingsPage::createPage(QWidget *parent)
m_widget->setSettings(ProjectExplorerPlugin::instance()->projectExplorerSettings());
m_widget->setProjectsDirectory(Core::DocumentManager::projectsDirectory());
m_widget->setUseProjectsDirectory(Core::DocumentManager::useProjectsDirectory());
+ m_widget->setUseBuildDirectory(Core::DocumentManager::useBuildDirectory());
+ m_widget->setBuildDirectory(Core::DocumentManager::buildDirectory());
if (m_searchKeywords.isEmpty())
m_searchKeywords = m_widget->searchKeywords();
return m_widget;
@@ -178,6 +213,8 @@ void ProjectExplorerSettingsPage::apply()
ProjectExplorerPlugin::instance()->setProjectExplorerSettings(m_widget->settings());
Core::DocumentManager::setProjectsDirectory(m_widget->projectsDirectory());
Core::DocumentManager::setUseProjectsDirectory(m_widget->useProjectsDirectory());
+ Core::DocumentManager::setUseBuildDirectory(m_widget->useBuildDirectory());
+ Core::DocumentManager::setBuildDirectory(m_widget->buildDirectory());
}
}
diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.h b/src/plugins/projectexplorer/projectexplorersettingspage.h
index ad6e928db5..5e37b23eaa 100644
--- a/src/plugins/projectexplorer/projectexplorersettingspage.h
+++ b/src/plugins/projectexplorer/projectexplorersettingspage.h
@@ -55,10 +55,17 @@ public:
bool useProjectsDirectory();
void setUseProjectsDirectory(bool v);
+ bool useBuildDirectory() const;
+ void setUseBuildDirectory(bool v);
+
+ QString buildDirectory() const;
+ void setBuildDirectory(const QString &bd);
+
QString searchKeywords() const;
private slots:
void slotDirectoryButtonGroupChanged();
+ void slotBuildDirectoryCheckBoxChanged(bool checked);
private:
void setJomVisible(bool);
diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.ui b/src/plugins/projectexplorer/projectexplorersettingspage.ui
index 6f13f17fd7..ec29fa134b 100644
--- a/src/plugins/projectexplorer/projectexplorersettingspage.ui
+++ b/src/plugins/projectexplorer/projectexplorersettingspage.ui
@@ -20,6 +20,9 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
+ <property name="labelAlignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
<item row="0" column="0" colspan="2">
<widget class="QRadioButton" name="currentDirectoryRadioButton">
<property name="text">
@@ -30,6 +33,23 @@
</attribute>
</widget>
</item>
+ <item row="1" column="1">
+ <widget class="Utils::PathChooser" name="projectsDirectoryPathChooser" native="true"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="buildDirectoryCheckBox">
+ <property name="text">
+ <string>Build directory</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="Utils::PathChooser" name="buildDirectoryPathChooser" native="true">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
<item row="1" column="0">
<widget class="QRadioButton" name="directoryRadioButton">
<property name="text">
@@ -43,9 +63,6 @@
</attribute>
</widget>
</item>
- <item row="1" column="1">
- <widget class="Utils::PathChooser" name="projectsDirectoryPathChooser" native="true"/>
- </item>
</layout>
</widget>
</item>
@@ -237,6 +254,7 @@
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
+ <container>1</container>
</customwidget>
</customwidgets>
<resources/>
diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index 2212a7b9fe..27342e7f65 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -46,6 +46,7 @@
#include <coreplugin/messagemanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/progressmanager/progressmanager.h>
+#include <coreplugin/documentmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <cpptools/ModelManagerInterface.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
@@ -1426,9 +1427,25 @@ QString Qt4Project::shadowBuildDirectory(const QString &profilePath, const Kit *
if (version && !version->supportsShadowBuilds())
return info.absolutePath();
- QString base = QDir::cleanPath(projectDirectory(profilePath) + QLatin1String("/../")
- + info.baseName() + QLatin1String("-build-"));
- return base + buildNameFor(k) + QLatin1String("-") + sanitize(suffix);
+ Utils::FileName buildDirBase = Utils::FileName::fromString(projectDirectory(profilePath));
+ if (Core::DocumentManager::useProjectsDirectory() &&
+ Core::DocumentManager::useBuildDirectory()) {
+ const Utils::FileName projectsDirectory =
+ Utils::FileName::fromString(Core::DocumentManager::projectsDirectory());
+
+ if (buildDirBase.isChildOf(projectsDirectory)) {
+ Utils::FileName buildDirectory =
+ Utils::FileName::fromString(Core::DocumentManager::buildDirectory());
+
+ buildDirectory.appendPath(buildDirBase.relativeChildPath(projectsDirectory).toString());
+ buildDirBase = buildDirectory;
+ }
+ }
+
+ buildDirBase.append(QLatin1String("-build-") + buildNameFor(k) +
+ QLatin1Char('-') + sanitize(suffix));
+
+ return QDir::cleanPath(buildDirBase.toString());
}
QString Qt4Project::buildNameFor(const Kit *k)