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 @@ ...@@ -31,6 +31,12 @@
#include "iversioncontrol.h" #include "iversioncontrol.h"
#include "icore.h" #include "icore.h"
#include "documentmanager.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 <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
...@@ -74,6 +80,9 @@ public: ...@@ -74,6 +80,9 @@ public:
QString topLevel; QString topLevel;
}; };
VcsManagerPrivate() : m_unconfiguredVcs(0)
{ }
~VcsManagerPrivate() ~VcsManagerPrivate()
{ {
qDeleteAll(m_vcsInfoList); qDeleteAll(m_vcsInfoList);
...@@ -165,6 +174,7 @@ public: ...@@ -165,6 +174,7 @@ public:
QMap<QString, VcsInfo *> m_cachedMatches; QMap<QString, VcsInfo *> m_cachedMatches;
QList<VcsInfo *> m_vcsInfoList; QList<VcsInfo *> m_vcsInfoList;
IVersionControl *m_unconfiguredVcs;
}; };
VcsManager::VcsManager(QObject *parent) : VcsManager::VcsManager(QObject *parent) :
...@@ -231,10 +241,8 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input ...@@ -231,10 +241,8 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
foreach (IVersionControl * versionControl, versionControls) { foreach (IVersionControl * versionControl, versionControls) {
QString topLevel; QString topLevel;
if (versionControl->isConfigured() if (versionControl->managesDirectory(directory, &topLevel))
&& versionControl->managesDirectory(directory, &topLevel)) {
allThatCanManage.push_back(StringVersionControlPair(topLevel, versionControl)); allThatCanManage.push_back(StringVersionControlPair(topLevel, versionControl));
}
} }
// To properly find a nested repository (say, git checkout inside SVN), // To properly find a nested repository (say, git checkout inside SVN),
...@@ -265,7 +273,26 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input ...@@ -265,7 +273,26 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
// return result // return result
if (topLevelDirectory) if (topLevelDirectory)
*topLevelDirectory = allThatCanManage.first().first; *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 QStringList VcsManager::repositories(const IVersionControl *vc) const
...@@ -399,4 +426,11 @@ void VcsManager::clearVersionControlCache() ...@@ -399,4 +426,11 @@ void VcsManager::clearVersionControlCache()
emit repositoryChanged(repo); 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 } // namespace Core
...@@ -100,6 +100,9 @@ signals: ...@@ -100,6 +100,9 @@ signals:
public slots: public slots:
void clearVersionControlCache(); void clearVersionControlCache();
private slots:
void configureVcs();
private: private:
VcsManagerPrivate *d; 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