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
8bbf212d
Commit
8bbf212d
authored
May 02, 2021
by
Waqar Ahmed
Browse files
Fix changing branch doesn't update the branch button
Signed-off-by:
Waqar Ahmed
<
waqar.17a@gmail.com
>
parent
e979cc2e
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/project/kateprojectview.cpp
View file @
8bbf212d
...
...
@@ -72,26 +72,14 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject
/**
* Setup git checkout stuff
*/
m_branchBtn
->
setHidden
(
!
GitUtils
::
isGitRepo
(
m_project
->
baseDir
()));
connect
(
m_branchBtn
,
&
QPushButton
::
clicked
,
this
,
[
this
,
mainWindow
]
{
BranchCheckoutDialog
bd
(
mainWindow
->
window
(),
m_pluginView
,
m_project
->
baseDir
());
bd
.
openDialog
();
});
connect
(
m_project
,
&
KateProject
::
modelChanged
,
this
,
[
this
]
{
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
);
}
});
checkAndRefreshGit
();
connect
(
m_project
,
&
KateProject
::
modelChanged
,
this
,
&
KateProjectView
::
checkAndRefreshGit
);
connect
(
&
m_branchChangedWatcher
,
&
QFileSystemWatcher
::
fileChanged
,
this
,
[
this
]
{
m_project
->
reload
(
true
);
});
...
...
@@ -159,3 +147,19 @@ void KateProjectView::showFileGitHistory(const QString &file)
m_stackWidget
->
addWidget
(
fhs
);
m_stackWidget
->
setCurrentWidget
(
fhs
);
}
void
KateProjectView
::
checkAndRefreshGit
()
{
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
);
}
}
addons/project/kateprojectview.h
View file @
8bbf212d
...
...
@@ -73,6 +73,13 @@ private Q_SLOTS:
void
showFileGitHistory
(
const
QString
&
file
);
/**
* On project model change, check if project
* is a git repo and then show/hide the branch
* button accordingly
*/
void
checkAndRefreshGit
();
private:
/**
* our plugin view
...
...
Waqar Ahmed
@waqar
mentioned in commit
144dab94
·
May 02, 2021
mentioned in commit
144dab94
mentioned in commit 144dab9446e0c8adabcdc859a219c9add62f7543
Toggle commit list
Write
Preview
Markdown
is supported
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