Commit 10760d27 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Change branch & reload if a branch was changed outside Kate

parent d43bfa6f
......@@ -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()
......
......@@ -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
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