Commit 70474ab9 authored by loh.tar's avatar loh.tar
Browse files

Auto update git widget by watching .git/index

parent 70535b26
......@@ -133,6 +133,9 @@ KateProjectPluginView::KateProjectPluginView(KateProjectPlugin *plugin, KTextEdi
connect(&m_gitWidgetReloadTrigger, &QTimer::timeout, this, [this] {
slotUpdateStatus(true);
});
connect(&m_gitChangedWatcher, &QFileSystemWatcher::fileChanged, this, [this] {
m_gitWidgetReloadTrigger.start();
});
/**
* create views for all already existing projects
......@@ -509,9 +512,10 @@ void KateProjectPluginView::slotCurrentChanged(int index)
// update git focus proxy + update status
if (QWidget *current = m_stackedGitViews->currentWidget()) {
m_stackedGitViews->setFocusProxy(current);
static_cast<GitWidget *>(current)->updateStatus();
}
slotUpdateStatus(true);
// project file name might have changed
Q_EMIT projectFileNameChanged();
Q_EMIT projectMapChanged();
......@@ -779,6 +783,8 @@ void KateProjectPluginView::slotUpdateStatus(bool visible)
if (!visible) {
return;
}
// We need to add the path every time again because it's always a different file
m_gitChangedWatcher.addPath(projectBaseDir() + QStringLiteral("/.git/index"));
if (auto widget = m_stackedGitViews->currentWidget()) {
static_cast<GitWidget *>(widget)->updateStatus();
......
......@@ -340,6 +340,11 @@ private:
QString currentWord() const;
private:
/**
* Watches for changes to .git/indiex
*/
QFileSystemWatcher m_gitChangedWatcher;
/**
* Helper to avoid multiple reloads at a time
* @see slotDocumentSaved
......
Supports Markdown
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