Commit 17106e69 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Suggest configuring VCS if it is unconfigured

Change-Id: I6ef3c615070f055e688c94d6901d8c9a861b9928
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 0f2a0d93
......@@ -31,6 +31,12 @@
#include "iversioncontrol.h"
#include "icore.h"
#include "documentmanager.h"
#include "editormanager.h"
#include "ieditor.h"
#include "idocument.h"
#include "infobar.h"
#include <vcsbase/vcsbaseconstants.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
......@@ -74,6 +80,9 @@ public:
QString topLevel;
};
VcsManagerPrivate() : m_unconfiguredVcs(0)
{ }
~VcsManagerPrivate()
{
qDeleteAll(m_vcsInfoList);
......@@ -165,6 +174,7 @@ public:
QMap<QString, VcsInfo *> m_cachedMatches;
QList<VcsInfo *> m_vcsInfoList;
IVersionControl *m_unconfiguredVcs;
};
VcsManager::VcsManager(QObject *parent) :
......@@ -231,11 +241,9 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
foreach (IVersionControl * versionControl, versionControls) {
QString topLevel;
if (versionControl->isConfigured()
&& versionControl->managesDirectory(directory, &topLevel)) {
if (versionControl->managesDirectory(directory, &topLevel))
allThatCanManage.push_back(StringVersionControlPair(topLevel, versionControl));
}
}
// To properly find a nested repository (say, git checkout inside SVN),
// we need to select the version control with the longest toplevel pathname.
......@@ -265,7 +273,26 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
// return result
if (topLevelDirectory)
*topLevelDirectory = allThatCanManage.first().first;
return allThatCanManage.first().second;
IVersionControl *versionControl = allThatCanManage.first().second;
if (!versionControl->isConfigured()) {
if (IEditor *curEditor = EditorManager::currentEditor()) {
if (IDocument *curDocument = curEditor->document()) {
Id vcsWarning("VcsNotConfiguredWarning");
InfoBar *infoBar = curDocument->infoBar();
if (infoBar->canInfoBeAdded(vcsWarning)) {
InfoBarEntry info(vcsWarning,
tr("%1 repository was detected but %1 is not configured.")
.arg(versionControl->displayName()),
InfoBarEntry::GlobalSuppressionEnabled);
d->m_unconfiguredVcs = versionControl;
info.setCustomButtonInfo(tr("Configure"), this, SLOT(configureVcs()));
infoBar->addInfo(info);
}
}
}
versionControl = 0;
}
return versionControl;
}
QStringList VcsManager::repositories(const IVersionControl *vc) const
......@@ -399,4 +426,11 @@ void VcsManager::clearVersionControlCache()
emit repositoryChanged(repo);
}
void VcsManager::configureVcs()
{
QTC_ASSERT(d->m_unconfiguredVcs, return);
ICore::showOptionsDialog(Id(VcsBase::Constants::VCS_SETTINGS_CATEGORY),
d->m_unconfiguredVcs->id());
}
} // namespace Core
......@@ -100,6 +100,9 @@ signals:
public slots:
void clearVersionControlCache();
private slots:
void configureVcs();
private:
VcsManagerPrivate *d;
};
......
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