Commit 75d962d8 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Allow opening any directory from kate as project


Signed-off-by: Waqar Ahmed's avatarWaqar Ahmed <waqar.17a@gmail.com>
parent f8a41e57
......@@ -138,6 +138,11 @@ KateProject *KateProjectPlugin::createProjectForFileName(const QString &fileName
KateProject *KateProjectPlugin::projectForDir(QDir dir)
{
/**
* Save dir to create a project from directory if nothing works
*/
const QDir originalDir = dir;
/**
* search project file upwards
* with recursion guard
......@@ -185,8 +190,10 @@ KateProject *KateProjectPlugin::projectForDir(QDir dir)
}
}
// no project found, bad luck
return nullptr;
/**
* Version control not found? Load the directory as project
*/
return createProjectForDirectory(originalDir);
}
KateProject *KateProjectPlugin::projectForUrl(const QUrl &url)
......@@ -292,6 +299,23 @@ KateProject *KateProjectPlugin::createProjectForRepository(const QString &type,
return project;
}
KateProject *KateProjectPlugin::createProjectForDirectory(const QDir &dir)
{
QVariantMap cnf, files;
files[QStringLiteral("directory")] = QStringLiteral("./");
qWarning() << files;
cnf[QStringLiteral("name")] = dir.dirName();
cnf[QStringLiteral("files")] = (QVariantList() << files);
KateProject *project = new KateProject(m_threadPool, this);
project->loadFromData(cnf, dir.canonicalPath());
m_projects.append(project);
Q_EMIT projectCreated(project);
return project;
}
void KateProjectPlugin::setAutoRepository(bool onGit, bool onSubversion, bool onMercurial)
{
m_autoGit = onGit;
......
......@@ -163,6 +163,7 @@ public Q_SLOTS:
private:
KateProject *createProjectForRepository(const QString &type, const QDir &dir);
KateProject *createProjectForDirectory(const QDir &dir);
KateProject *detectGit(const QDir &dir);
KateProject *detectSubversion(const QDir &dir);
KateProject *detectMercurial(const QDir &dir);
......
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