forked from qt-creator/qt-creator
VcsBase: Add Js Extension for querying VCS configuration state
This enables JSON wizards to check for that. Change-Id: If6bfc580b37f712168b707ac51412df8f1cbbf25 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@ include(../../qtcreatorplugin.pri)
|
|||||||
HEADERS += vcsbase_global.h \
|
HEADERS += vcsbase_global.h \
|
||||||
vcsbaseconstants.h \
|
vcsbaseconstants.h \
|
||||||
wizard/vcsconfigurationpage.h \
|
wizard/vcsconfigurationpage.h \
|
||||||
|
wizard/vcsjsextension.h \
|
||||||
vcsplugin.h \
|
vcsplugin.h \
|
||||||
corelistener.h \
|
corelistener.h \
|
||||||
vcsbaseplugin.h \
|
vcsbaseplugin.h \
|
||||||
@@ -34,6 +35,7 @@ HEADERS += vcsbase_global.h \
|
|||||||
SOURCES += vcsplugin.cpp \
|
SOURCES += vcsplugin.cpp \
|
||||||
vcsbaseplugin.cpp \
|
vcsbaseplugin.cpp \
|
||||||
wizard/vcsconfigurationpage.cpp \
|
wizard/vcsconfigurationpage.cpp \
|
||||||
|
wizard/vcsjsextension.cpp \
|
||||||
corelistener.cpp \
|
corelistener.cpp \
|
||||||
baseannotationhighlighter.cpp \
|
baseannotationhighlighter.cpp \
|
||||||
diffhighlighter.cpp \
|
diffhighlighter.cpp \
|
||||||
|
@@ -81,5 +81,7 @@ QtcPlugin {
|
|||||||
"images/submit.png",
|
"images/submit.png",
|
||||||
"wizard/vcsconfigurationpage.cpp",
|
"wizard/vcsconfigurationpage.cpp",
|
||||||
"wizard/vcsconfigurationpage.h",
|
"wizard/vcsconfigurationpage.h",
|
||||||
|
"wizard/vcsjsextension.cpp",
|
||||||
|
"wizard/vcsjsextension.h",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -37,8 +37,10 @@
|
|||||||
#include "vcsoutputwindow.h"
|
#include "vcsoutputwindow.h"
|
||||||
#include "corelistener.h"
|
#include "corelistener.h"
|
||||||
#include "wizard/vcsconfigurationpage.h"
|
#include "wizard/vcsconfigurationpage.h"
|
||||||
|
#include "wizard/vcsjsextension.h"
|
||||||
|
|
||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
|
#include <coreplugin/jsexpander.h>
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
|
||||||
@@ -93,6 +95,8 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
|
|
||||||
JsonWizardFactory::registerPageFactory(new Internal::VcsConfigurationPageFactory);
|
JsonWizardFactory::registerPageFactory(new Internal::VcsConfigurationPageFactory);
|
||||||
|
|
||||||
|
JsExpander::registerQObjectForJs(QLatin1String("Vcs"), new VcsJsExtension);
|
||||||
|
|
||||||
Utils::MacroExpander *expander = Utils::globalMacroExpander();
|
Utils::MacroExpander *expander = Utils::globalMacroExpander();
|
||||||
expander->registerVariable(Constants::VAR_VCS_NAME,
|
expander->registerVariable(Constants::VAR_VCS_NAME,
|
||||||
tr("Name of the version control system in use by the current project."),
|
tr("Name of the version control system in use by the current project."),
|
||||||
|
54
src/plugins/vcsbase/wizard/vcsjsextension.cpp
Normal file
54
src/plugins/vcsbase/wizard/vcsjsextension.cpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "vcsjsextension.h"
|
||||||
|
|
||||||
|
#include <coreplugin/iversioncontrol.h>
|
||||||
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
|
namespace VcsBase {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
bool VcsJsExtension::isConfigured(const QString &vcsId) const
|
||||||
|
{
|
||||||
|
IVersionControl *vc = VcsManager::versionControl(Id::fromString(vcsId));
|
||||||
|
return vc && vc->isConfigured();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString VcsJsExtension::displayName(const QString &vcsId) const
|
||||||
|
{
|
||||||
|
IVersionControl *vc = VcsManager::versionControl(Id::fromString(vcsId));
|
||||||
|
return vc ? vc->displayName() : QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace VcsBase
|
51
src/plugins/vcsbase/wizard/vcsjsextension.h
Normal file
51
src/plugins/vcsbase/wizard/vcsjsextension.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef VCSJSEXTENSION_H
|
||||||
|
#define VCSJSEXTENSION_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace VcsBase {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class VcsJsExtension : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Q_INVOKABLE bool isConfigured(const QString &vcsId) const;
|
||||||
|
Q_INVOKABLE QString displayName(const QString &vcsId) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace VcsBase
|
||||||
|
|
||||||
|
#endif // VCSJSEXTENSION_H
|
Reference in New Issue
Block a user