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
10760d27
Commit
10760d27
authored
Feb 09, 2021
by
Waqar Ahmed
Browse files
Change branch & reload if a branch was changed outside Kate
parent
d43bfa6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/project/kateprojectview.cpp
View file @
10760d27
...
...
@@ -53,13 +53,18 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject
});
chckbr
->
setText
(
QStringLiteral
(
"Checkout Git Branch"
));
m_branchesDialog
=
new
BranchesDialog
(
this
,
mainWindow
,
m_project
->
baseDir
());
/**
* setup filter line edit
*/
m_filter
->
setPlaceholderText
(
i18n
(
"Filter..."
));
m_filter
->
setClearButtonEnabled
(
true
);
connect
(
m_filter
,
&
KLineEdit
::
textChanged
,
this
,
&
KateProjectView
::
filterTextChanged
);
/**
* Setup git checkout stuff
*/
m_branchBtn
->
setHidden
(
true
);
m_branchesDialog
=
new
BranchesDialog
(
this
,
mainWindow
,
m_project
->
baseDir
());
connect
(
m_branchBtn
,
&
QPushButton
::
clicked
,
this
,
[
this
]
{
m_branchesDialog
->
openDialog
();
});
...
...
@@ -71,14 +76,19 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject
if
(
GitUtils
::
isGitRepo
(
m_project
->
baseDir
()))
{
m_branchBtn
->
setHidden
(
false
);
m_branchBtn
->
setText
(
GitUtils
::
getCurrentBranchName
(
m_project
->
baseDir
()));
if
(
m_branchChangedWatcher
.
files
().
isEmpty
())
{
m_branchChangedWatcher
.
addPath
(
m_project
->
baseDir
()
+
QStringLiteral
(
"/.git/HEAD"
));
}
}
else
{
if
(
!
m_branchChangedWatcher
.
files
().
isEmpty
())
{
m_branchChangedWatcher
.
removePaths
(
m_branchChangedWatcher
.
files
());
}
m_branchBtn
->
setHidden
(
true
);
}
});
if
(
!
GitUtils
::
isGitRepo
(
m_project
->
baseDir
()))
{
m_branchBtn
->
setHidden
(
true
);
}
connect
(
&
m_branchChangedWatcher
,
&
QFileSystemWatcher
::
fileChanged
,
this
,
[
this
]
{
m_project
->
reload
(
true
);
});
}
KateProjectView
::~
KateProjectView
()
...
...
addons/project/kateprojectview.h
View file @
10760d27
...
...
@@ -11,6 +11,8 @@
#include "kateproject.h"
#include "kateprojectviewtree.h"
#include <QFileSystemWatcher>
class
KLineEdit
;
class
QPushButton
;
class
KateProjectPluginView
;
...
...
@@ -90,7 +92,15 @@ private:
*/
QPushButton
*
m_branchBtn
;
/**
* The dialog which displays git branches
*/
BranchesDialog
*
m_branchesDialog
;
/**
* watches for changes to .git/HEAD
*/
QFileSystemWatcher
m_branchChangedWatcher
;
};
#endif
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