From 2cc47c2039c4b78c2f14b268ef156afd90255843 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Thu, 18 Dec 2014 17:35:25 +0100 Subject: move license check to a function Change-Id: Idcb2c328f3313dac38997765c2569d6861d34a20 Reviewed-by: Christian Stenger --- plugins/autotest/autotestplugin.cpp | 21 ++++++++++++++------- plugins/autotest/autotestplugin.h | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/plugins/autotest/autotestplugin.cpp b/plugins/autotest/autotestplugin.cpp index 2abcebbb80..7823fdef2c 100644 --- a/plugins/autotest/autotestplugin.cpp +++ b/plugins/autotest/autotestplugin.cpp @@ -70,6 +70,19 @@ AutotestPlugin *AutotestPlugin::instance() return m_instance; } +bool AutotestPlugin::checkLicense() +{ + LicenseChecker::LicenseCheckerPlugin *licenseChecker + = ExtensionSystem::PluginManager::getObject(); + + if (!licenseChecker || !licenseChecker->hasValidLicense()) { + qWarning() << "Invalid license, disabling Qt Creator Enterprise Auto Test Add-on."; + return false; + } else if (!licenseChecker->enterpriseFeatures()) + return false; + return true; +} + bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorString) { // Register objects in the plugin manager's object pool @@ -82,13 +95,7 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri Q_UNUSED(arguments) Q_UNUSED(errorString) - LicenseChecker::LicenseCheckerPlugin *licenseChecker - = ExtensionSystem::PluginManager::getObject(); - - if (!licenseChecker || !licenseChecker->hasValidLicense()) { - qWarning() << "Invalid license, disabling Qt Creator Enterprise Auto Test Add-on."; - return true; - } else if (!licenseChecker->enterpriseFeatures()) + if (!checkLicense()) return true; QAction *action = new QAction(tr("Autotest action"), this); diff --git a/plugins/autotest/autotestplugin.h b/plugins/autotest/autotestplugin.h index 6d5365ddee..5f761264a2 100644 --- a/plugins/autotest/autotestplugin.h +++ b/plugins/autotest/autotestplugin.h @@ -49,6 +49,7 @@ private slots: void triggerAction(); private: + bool checkLicense(); const QSharedPointer m_settings; }; -- cgit v1.2.1