Support default= in .kateworkspace to set initial subrepo
This commit is contained in:
parent
ac5af7b6d6
commit
b758859c3c
|
|
@ -2444,13 +2444,45 @@ void GitPlusPlusView::detectWorkspace()
|
||||||
QString name = QFileInfo(repoPath).fileName();
|
QString name = QFileInfo(repoPath).fileName();
|
||||||
m_repoCombo->addItem(name, repoPath);
|
m_repoCombo->addItem(name, repoPath);
|
||||||
}
|
}
|
||||||
// Select current m_gitDir in combo
|
// Select workspace default repo, or fall back to current m_gitDir
|
||||||
|
int selectedIdx = -1;
|
||||||
|
QString wsFilePath = m_workspaceDir + QStringLiteral("/.kateworkspace");
|
||||||
|
if (QFileInfo::exists(wsFilePath)) {
|
||||||
|
QSettings ws(wsFilePath, QSettings::IniFormat);
|
||||||
|
ws.beginGroup(QStringLiteral("workspace"));
|
||||||
|
QString defaultRepo = ws.value(QStringLiteral("default")).toString();
|
||||||
|
ws.endGroup();
|
||||||
|
if (!defaultRepo.isEmpty()) {
|
||||||
|
for (int i = 0; i < m_repoCombo->count(); ++i) {
|
||||||
|
if (m_repoCombo->itemText(i) == defaultRepo) {
|
||||||
|
selectedIdx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selectedIdx < 0) {
|
||||||
|
// No default configured — use current m_gitDir
|
||||||
for (int i = 0; i < m_repoCombo->count(); ++i) {
|
for (int i = 0; i < m_repoCombo->count(); ++i) {
|
||||||
if (m_repoCombo->itemData(i).toString() == m_gitDir) {
|
if (m_repoCombo->itemData(i).toString() == m_gitDir) {
|
||||||
m_repoCombo->setCurrentIndex(i);
|
selectedIdx = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (selectedIdx >= 0) {
|
||||||
|
m_repoCombo->setCurrentIndex(selectedIdx);
|
||||||
|
QString newGitDir = m_repoCombo->itemData(selectedIdx).toString();
|
||||||
|
if (newGitDir != m_gitDir) {
|
||||||
|
m_gitDir = newGitDir;
|
||||||
|
// Open .kateproject to trigger Kate's project switch
|
||||||
|
QString kateProjectFile = m_gitDir + QStringLiteral("/.kateproject");
|
||||||
|
if (QFileInfo::exists(kateProjectFile))
|
||||||
|
m_mainWindow->openUrl(QUrl::fromLocalFile(kateProjectFile));
|
||||||
|
} else {
|
||||||
|
m_gitDir = newGitDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
m_repoCombo->blockSignals(false);
|
m_repoCombo->blockSignals(false);
|
||||||
m_repoCombo->show();
|
m_repoCombo->show();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue