Connect to project plugin projectChanged signal
Listen for Kate project switches via kateprojectplugin projectChanged() signal. When fired, re-detect workspace and refresh all state. This ensures the repo combo hides when switching to a non-workspace project.
This commit is contained in:
parent
5f3cb89b58
commit
1c81cd9cf5
|
|
@ -545,6 +545,12 @@ GitPlusPlusView::GitPlusPlusView(GitPlusPlusPlugin *plugin, KTextEditor::MainWin
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Connect to project plugin for project-switch detection
|
||||||
|
QObject *projectPluginView = m_mainWindow->pluginView(QStringLiteral("kateprojectplugin"));
|
||||||
|
if (projectPluginView) {
|
||||||
|
connect(projectPluginView, SIGNAL(projectChanged()), this, SLOT(onProjectChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh everything when the active view changes (project might have changed)
|
// Refresh everything when the active view changes (project might have changed)
|
||||||
connect(m_mainWindow, &KTextEditor::MainWindow::viewChanged, this, [this]() {
|
connect(m_mainWindow, &KTextEditor::MainWindow::viewChanged, this, [this]() {
|
||||||
QString newDir = projectBaseDir();
|
QString newDir = projectBaseDir();
|
||||||
|
|
@ -1045,6 +1051,17 @@ void GitPlusPlusView::runRemoteGit(const QStringList &args, const QString &opNam
|
||||||
// Git operations
|
// Git operations
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
void GitPlusPlusView::onProjectChanged()
|
||||||
|
{
|
||||||
|
QString newDir = projectBaseDir();
|
||||||
|
if (newDir != m_gitDir) {
|
||||||
|
m_gitDir = newDir;
|
||||||
|
detectWorkspace();
|
||||||
|
setupFileWatcher();
|
||||||
|
refreshAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GitPlusPlusView::updateStatus()
|
void GitPlusPlusView::updateStatus()
|
||||||
{
|
{
|
||||||
m_gitDir = projectBaseDir();
|
m_gitDir = projectBaseDir();
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ public:
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
// Status
|
// Status
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
|
void onProjectChanged();
|
||||||
void onStatusFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
void onStatusFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
|
|
||||||
// Stage/commit
|
// Stage/commit
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue