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>
This commit is contained in:
Daniel Teske
2015-01-16 17:47:11 +01:00
parent 1ed12d39f1
commit 230be99474
4 changed files with 48 additions and 1 deletions

View File

@@ -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;