Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
75d962d8
Commit
75d962d8
authored
Mar 11, 2021
by
Waqar Ahmed
Committed by
Christoph Cullmann
Mar 12, 2021
Browse files
Allow opening any directory from kate as project
Signed-off-by:
Waqar Ahmed
<
waqar.17a@gmail.com
>
parent
f8a41e57
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/project/kateprojectplugin.cpp
View file @
75d962d8
...
...
@@ -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
;
...
...
addons/project/kateprojectplugin.h
View file @
75d962d8
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment