Add license validation with LicenseChecker plugin

This commit is contained in:
Christian Stenger
2014-10-28 13:02:34 +01:00
committed by Christian Stenger
parent eba497d921
commit eca8e2faba
2 changed files with 15 additions and 1 deletions

View File

@@ -3,7 +3,8 @@ QTC_PLUGIN_NAME = AutoTest
QTC_PLUGIN_DEPENDS += \
coreplugin \
projectexplorer \
cpptools
cpptools \
licensechecker
QTC_LIB_DEPENDS += \
cplusplus \

View File

@@ -30,6 +30,10 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/coreconstants.h>
#include <extensionsystem/pluginmanager.h>
#include <licensechecker/licensecheckerplugin.h>
#include <QAction>
#include <QMessageBox>
#include <QMainWindow>
@@ -66,6 +70,15 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
Q_UNUSED(arguments)
Q_UNUSED(errorString)
LicenseChecker::LicenseCheckerPlugin *licenseChecker
= ExtensionSystem::PluginManager::getObject<LicenseChecker::LicenseCheckerPlugin>();
if (!licenseChecker || !licenseChecker->hasValidLicense()) {
qWarning() << "Invalid license, disabling Qt Creator Enterprise Auto Test Add-on.";
return true;
} else if (!licenseChecker->enterpriseFeatures())
return true;
QAction *action = new QAction(tr("Autotest action"), this);
Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID,
Core::Context(Core::Constants::C_GLOBAL));