diff options
author | Daniel Teske <daniel.teske@theqtcompany.com> | 2015-01-16 17:47:11 +0100 |
---|---|---|
committer | Daniel Teske <daniel.teske@theqtcompany.com> | 2015-01-19 13:34:10 +0100 |
commit | 230be99474adbe868c61885563ad18454dffbdd8 (patch) | |
tree | cf01ae8a9ec318e931906d8979bf9208adab6ae0 /src/plugins/projectexplorer | |
parent | 1ed12d39f13afcedd450b722a63470e9b8595712 (diff) | |
download | qt-creator-230be99474adbe868c61885563ad18454dffbdd8.tar.gz |
Fix default wrong directory if no files are open in the editor
Task-number: QTCREATORBUG-13831
Change-Id: Iaeb11014ed16bc9f08d7c12d81c1b7b8a4163d21
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r-- | src/plugins/projectexplorer/projecttree.cpp | 19 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projecttree.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/projecttree.cpp b/src/plugins/projectexplorer/projecttree.cpp index 53210312c7..95f95aab2f 100644 --- a/src/plugins/projectexplorer/projecttree.cpp +++ b/src/plugins/projectexplorer/projecttree.cpp @@ -43,6 +43,7 @@ #include <coreplugin/vcsmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actionmanager.h> +#include <coreplugin/documentmanager.h> #include <QApplication> #include <QTimer> @@ -72,6 +73,13 @@ ProjectTree::ProjectTree(QObject *parent) connect(qApp, &QApplication::focusChanged, this, &ProjectTree::focusChanged); + + connect(SessionManager::instance(), &SessionManager::projectAdded, + this, &ProjectTree::updateDefaultLocationForNewFiles); + connect(SessionManager::instance(), &SessionManager::projectRemoved, + this, &ProjectTree::updateDefaultLocationForNewFiles); + connect(SessionManager::instance(), &SessionManager::startupProjectChanged, + this, &ProjectTree::updateDefaultLocationForNewFiles); } void ProjectTree::aboutToShutDown() @@ -215,9 +223,20 @@ void ProjectTree::update(Node *node, Project *project) emit currentProjectChanged(m_currentProject); + updateDefaultLocationForNewFiles(); updateContext(); } +void ProjectTree::updateDefaultLocationForNewFiles() +{ + if (m_currentProject) + Core::DocumentManager::setDefaultLocationForNewFiles(m_currentProject->projectDirectory().toString()); + else if (SessionManager::startupProject()) + Core::DocumentManager::setDefaultLocationForNewFiles(SessionManager::startupProject()->projectDirectory().toString()); + else + Core::DocumentManager::setDefaultLocationForNewFiles(QString()); +} + void ProjectTree::updateContext() { Core::Context oldContext; diff --git a/src/plugins/projectexplorer/projecttree.h b/src/plugins/projectexplorer/projecttree.h index fbaef27bd4..642458221e 100644 --- a/src/plugins/projectexplorer/projecttree.h +++ b/src/plugins/projectexplorer/projecttree.h @@ -130,6 +130,7 @@ public: // for nodes to emit signals, do not call unless you are a node void collapseAll(); private: + void updateDefaultLocationForNewFiles(); void focusChanged(); void updateFromProjectTreeWidget(Internal::ProjectTreeWidget *widget); void documentManagerCurrentFileChanged(); |