[Qgis-developer] set plugin enabled by default

Borys Jurgiel borysiasty at aster.pl
Mon Mar 1 11:30:55 EST 2010


Dnia poniedziałek, 1 marca 2010 o 15:00:55 Stefan Kiefer napisał(a):
> Hi Borys,
> thanks for your answer.
> that might be a way I also had in mind. Otherwise in Windows
> environments the config is written to the registry. I would like to
> avoid interferring with the registry. Whereas that would be manageable
> with an installer, in Linux environments one needs to manipulate the
> config file as you mentioned. Manipulating this file with an installer
> would not be as easy. Otherwise, either the config file as well as the
> registry entries exist only when Qgis was run first. So I have to
> consider this as well.
> Also with Linux there could be an - unlikly - issue that somone has
> changed the QT-config path settings, Whereas this is not to expect.
> 
> Anyway, I believe I need a more sophisticated way, like setting a flag
> while Qgis loads all the plugins. Or a workaround, like activating my
> plugin with one of the default plugins. Manipulating the default plugins
> might be the ultimo ratio, because I would neither to change this
> plugins (in favor of avoiding instabilities) nor risk to overwrite
> possible changes or updates on the users machine!
> 
> Otherwise, does anyone know whether  there is a flag or a property or
> any way to enable/disable plugins programmatical, let's say from another
> plugin?

From another plugin you can start your plugin for the current session:

qgis.utils.loadPlugin('your_module_name')
qgis.utils.startPlugin('your_module_name')

and also enable it to be automatically loaded from the next time:

settings=QSettings()
settings.setValue('PythonPlugins/your_module_name', QVariant(True))

Yo can let your installer insert such instructions to the PluginInstaller 
(thought it's kinda virus... :) but remember it installs in the system 
location and only its updates go to the user directory, where mask the system 
one.

Many users won't have it installed in the user directory, and your installer 
would create a fake PluginInstaller what masks the true one. So your installer 
should determine if there is PluginInstaller in the user directory and if 
isn't, it can create the fake one, but has to tell to your plugin to remove it 
at the first run. So it's gonna be a little weird ;-)


More information about the Qgis-developer mailing list