Commit 9d1b6e6e authored by Daniel Teske's avatar Daniel Teske

Find: Fix Current Project find to fall back to startup project

If no files are open.

Change-Id: I78f695fbc128c0e4dc093ac2afef6b68ea20ba93
Task-number: QTCREATORBUG-13998
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent 5a05255f
......@@ -44,6 +44,14 @@ using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
using namespace TextEditor;
static Project *currentProject()
{
Project *p = ProjectTree::currentProject();
if (p)
return p;
return SessionManager::startupProject();
}
CurrentProjectFind::CurrentProjectFind()
{
connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
......@@ -68,12 +76,12 @@ QString CurrentProjectFind::displayName() const
bool CurrentProjectFind::isEnabled() const
{
return ProjectTree::currentProject() != 0 && BaseFileFind::isEnabled();
return currentProject() != 0 && BaseFileFind::isEnabled();
}
QVariant CurrentProjectFind::additionalParameters() const
{
Project *project = ProjectTree::currentProject();
Project *project = currentProject();
if (project && project->document())
return qVariantFromValue(project->projectFilePath().toString());
return QVariant();
......@@ -94,8 +102,9 @@ Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters,
QString CurrentProjectFind::label() const
{
QTC_ASSERT(ProjectTree::currentProject(), return QString());
return tr("Project \"%1\":").arg(ProjectTree::currentProject()->displayName());
Project *p = currentProject();
QTC_ASSERT(p, return QString());
return tr("Project \"%1\":").arg(p->displayName());
}
void CurrentProjectFind::handleProjectChanged()
......
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