forked from qt-creator/qt-creator
Suggest configuring VCS if it is unconfigured
Change-Id: I6ef3c615070f055e688c94d6901d8c9a861b9928 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
0f2a0d9358
commit
17106e69c4
@@ -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,10 +241,8 @@ 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),
|
||||
@@ -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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user