Skip to content
Permalink
Browse files

Add API to determine if a plugin is enabled

  • Loading branch information
nyalldawson committed Feb 28, 2019
1 parent 86517c8 commit 388d6055243779215578b85afce3ebc2957869ca
Showing with 16 additions and 0 deletions.
  1. +9 −0 src/python/qgspythonutils.h
  2. +6 −0 src/python/qgspythonutilsimpl.cpp
  3. +1 −0 src/python/qgspythonutilsimpl.h
@@ -120,11 +120,19 @@ class PYTHON_EXPORT QgsPythonUtils
/**
* Returns TRUE if the plugin with matching name is loaded (active).
*
* \see isPluginEnabled()
* \see listActivePlugins()
* \see loadPlugin()
*/
virtual bool isPluginLoaded( const QString &packageName ) = 0;

/**
* Returns TRUE if the plugin is user enabled (i.e. installed and checked in the user's plugin configuration)
*
* \see isPluginLoaded()
*/
virtual bool isPluginEnabled( const QString &packageName ) const = 0;

/**
* Returns a list of active (loaded) plugins.
*
@@ -173,6 +181,7 @@ class PYTHON_EXPORT QgsPythonUtils
* Returns TRUE if the plugin was successfully unloaded.
*/
virtual bool unloadPlugin( const QString &packageName ) = 0;

};

#endif
@@ -28,6 +28,7 @@
#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgsmessageoutput.h"
#include "qgssettings.h"

#include <QStringList>
#include <QDir>
@@ -635,6 +636,11 @@ bool QgsPythonUtilsImpl::unloadPlugin( const QString &packageName )
return ( output == QLatin1String( "True" ) );
}

bool QgsPythonUtilsImpl::isPluginEnabled( const QString &packageName ) const
{
return QgsSettings().value( "/PythonPlugins/" + packageName, QVariant( false ) ).toBool();
}

bool QgsPythonUtilsImpl::isPluginLoaded( const QString &packageName )
{
QString output;
@@ -88,6 +88,7 @@ class QgsPythonUtilsImpl : public QgsPythonUtils
QString getPluginMetadata( const QString &pluginName, const QString &function ) override;
bool canUninstallPlugin( const QString &packageName ) override;
bool unloadPlugin( const QString &packageName ) override;
bool isPluginEnabled( const QString &packageName ) const override;

protected:

0 comments on commit 388d605

Please sign in to comment.
You can’t perform that action at this time.