Commit 5758c453 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Get status on project reload + btn press

parent 53174104
...@@ -68,8 +68,6 @@ GitWidget::GitWidget(KateProject *project, QWidget *parent, KTextEditor::MainWin ...@@ -68,8 +68,6 @@ GitWidget::GitWidget(KateProject *project, QWidget *parent, KTextEditor::MainWin
connect(&m_gitStatusWatcher, &QFutureWatcher<GitUtils::GitParsedStatus>::finished, this, &GitWidget::parseStatusReady); connect(&m_gitStatusWatcher, &QFutureWatcher<GitUtils::GitParsedStatus>::finished, this, &GitWidget::parseStatusReady);
connect(m_commitBtn, &QPushButton::clicked, this, &GitWidget::opencommitChangesDialog); connect(m_commitBtn, &QPushButton::clicked, this, &GitWidget::opencommitChangesDialog);
getStatus(m_project->baseDir());
} }
void GitWidget::sendMessage(const QString &message, bool warn) void GitWidget::sendMessage(const QString &message, bool warn)
...@@ -82,7 +80,7 @@ void GitWidget::sendMessage(const QString &message, bool warn) ...@@ -82,7 +80,7 @@ void GitWidget::sendMessage(const QString &message, bool warn)
m_mainWin->activeView()->document()->postMessage(msg); m_mainWin->activeView()->document()->postMessage(msg);
} }
void GitWidget::getStatus(const QString &repo, bool untracked, bool submodules) void GitWidget::getStatus(bool untracked, bool submodules)
{ {
disconnect(&git, &QProcess::finished, nullptr, nullptr); disconnect(&git, &QProcess::finished, nullptr, nullptr);
connect(&git, &QProcess::finished, this, &GitWidget::gitStatusReady); connect(&git, &QProcess::finished, this, &GitWidget::gitStatusReady);
...@@ -98,7 +96,7 @@ void GitWidget::getStatus(const QString &repo, bool untracked, bool submodules) ...@@ -98,7 +96,7 @@ void GitWidget::getStatus(const QString &repo, bool untracked, bool submodules)
} }
git.setArguments(args); git.setArguments(args);
git.setProgram(QStringLiteral("git")); git.setProgram(QStringLiteral("git"));
git.setWorkingDirectory(repo); git.setWorkingDirectory(m_project->baseDir());
git.start(); git.start();
} }
...@@ -117,7 +115,7 @@ void GitWidget::stage(const QStringList &files, bool) ...@@ -117,7 +115,7 @@ void GitWidget::stage(const QStringList &files, bool)
git.start(); git.start();
if (git.waitForStarted() && git.waitForFinished(-1)) { if (git.waitForStarted() && git.waitForFinished(-1)) {
getStatus(m_project->baseDir()); getStatus();
} }
} }
...@@ -137,7 +135,7 @@ void GitWidget::unstage(const QStringList &files) ...@@ -137,7 +135,7 @@ void GitWidget::unstage(const QStringList &files)
git.start(); git.start();
if (git.waitForStarted() && git.waitForFinished(-1)) { if (git.waitForStarted() && git.waitForFinished(-1)) {
getStatus(m_project->baseDir()); getStatus();
} }
} }
...@@ -160,7 +158,7 @@ void GitWidget::discard(const QStringList &files) ...@@ -160,7 +158,7 @@ void GitWidget::discard(const QStringList &files)
if (exitCode > 0) { if (exitCode > 0) {
sendMessage(i18n("Failed to discard changes. Error:\n%1", QString::fromUtf8(git.readAllStandardError())), true); sendMessage(i18n("Failed to discard changes. Error:\n%1", QString::fromUtf8(git.readAllStandardError())), true);
} else { } else {
getStatus(m_project->baseDir()); getStatus();
} }
}); });
} }
...@@ -184,7 +182,7 @@ void GitWidget::commitChanges(const QString &msg, const QString &desc) ...@@ -184,7 +182,7 @@ void GitWidget::commitChanges(const QString &msg, const QString &desc)
} else { } else {
sendMessage(i18n("Changes commited successfully."), false); sendMessage(i18n("Changes commited successfully."), false);
// refresh // refresh
getStatus(m_project->baseDir()); getStatus();
} }
}); });
} }
...@@ -309,7 +307,7 @@ void GitWidget::buildMenu() ...@@ -309,7 +307,7 @@ void GitWidget::buildMenu()
m_gitMenu = new QMenu(this); m_gitMenu = new QMenu(this);
m_gitMenu->addAction(i18n("Refresh"), this, [this] { m_gitMenu->addAction(i18n("Refresh"), this, [this] {
if (m_project) { if (m_project) {
getStatus(m_project->baseDir()); getStatus();
} }
}); });
m_gitMenu->addAction(i18n("Checkout Branch"), this, &GitWidget::checkoutBranch); m_gitMenu->addAction(i18n("Checkout Branch"), this, &GitWidget::checkoutBranch);
......
...@@ -28,6 +28,7 @@ public: ...@@ -28,6 +28,7 @@ public:
explicit GitWidget(KateProject *project, QWidget *parent = nullptr, KTextEditor::MainWindow *mainWindow = nullptr); explicit GitWidget(KateProject *project, QWidget *parent = nullptr, KTextEditor::MainWindow *mainWindow = nullptr);
bool eventFilter(QObject *o, QEvent *e) override; bool eventFilter(QObject *o, QEvent *e) override;
void getStatus(bool untracked = true, bool submodules = false);
private: private:
QToolButton *m_menuBtn; QToolButton *m_menuBtn;
...@@ -42,7 +43,6 @@ private: ...@@ -42,7 +43,6 @@ private:
QMenu *m_gitMenu; QMenu *m_gitMenu;
void buildMenu(); void buildMenu();
void getStatus(const QString &repo, bool untracked = true, bool submodules = false);
void stage(const QStringList &files, bool = false); void stage(const QStringList &files, bool = false);
void unstage(const QStringList &files); void unstage(const QStringList &files);
void discard(const QStringList &files); void discard(const QStringList &files);
......
...@@ -57,6 +57,7 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject ...@@ -57,6 +57,7 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject
m_stackWidget->addWidget(m_gitWidget); m_stackWidget->addWidget(m_gitWidget);
connect(m_gitBtn, &QPushButton::clicked, this, [this] { connect(m_gitBtn, &QPushButton::clicked, this, [this] {
m_gitWidget->getStatus();
m_stackWidget->setCurrentWidget(m_gitWidget); m_stackWidget->setCurrentWidget(m_gitWidget);
}); });
...@@ -103,6 +104,7 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject ...@@ -103,6 +104,7 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject
if (m_branchChangedWatcher.files().isEmpty()) { if (m_branchChangedWatcher.files().isEmpty()) {
m_branchChangedWatcher.addPath(m_project->baseDir() + QStringLiteral("/.git/HEAD")); m_branchChangedWatcher.addPath(m_project->baseDir() + QStringLiteral("/.git/HEAD"));
} }
m_gitWidget->getStatus();
} else { } else {
if (!m_branchChangedWatcher.files().isEmpty()) { if (!m_branchChangedWatcher.files().isEmpty()) {
m_branchChangedWatcher.removePaths(m_branchChangedWatcher.files()); m_branchChangedWatcher.removePaths(m_branchChangedWatcher.files());
......
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