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

Only create a project for a directory if explicitly asked by user


Signed-off-by: Waqar Ahmed's avatarWaqar Ahmed <waqar.17a@gmail.com>
parent 75d962d8
......@@ -64,7 +64,7 @@ KateProjectPlugin::KateProjectPlugin(QObject *parent, const QList<QVariant> &)
for (const QString &arg : qAsConst(args)) {
QFileInfo info(arg);
if (info.isDir()) {
projectForDir(info.absoluteFilePath());
projectForDir(info.absoluteFilePath(), true);
projectSpecified = true;
}
}
......@@ -136,7 +136,7 @@ KateProject *KateProjectPlugin::createProjectForFileName(const QString &fileName
return project;
}
KateProject *KateProjectPlugin::projectForDir(QDir dir)
KateProject *KateProjectPlugin::projectForDir(QDir dir, bool userSpecified)
{
/**
* Save dir to create a project from directory if nothing works
......@@ -193,7 +193,14 @@ KateProject *KateProjectPlugin::projectForDir(QDir dir)
/**
* Version control not found? Load the directory as project
*/
return createProjectForDirectory(originalDir);
if (userSpecified) {
return createProjectForDirectory(originalDir);
}
/**
* Give up
*/
return nullptr;
}
KateProject *KateProjectPlugin::projectForUrl(const QUrl &url)
......@@ -303,7 +310,6 @@ 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);
......
......@@ -55,9 +55,10 @@ public:
* Will search upwards for .kateproject file.
* Will use internally projectForFileName if project file is found.
* @param dir dir to search matching project for
* @param userSpecified whether user asked to open a directory as project
* @return project or null if not openable
*/
KateProject *projectForDir(QDir dir);
KateProject *projectForDir(QDir dir, bool userSpecified = false);
/**
* Search and open project that contains given url, if possible.
......
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