5

I've let my love of shiny new QGIS plugins get the better of me, and I'm finding it difficult to remember which menu / submenu / panel that a given plugin is in. I'm using well over 100 now, and going on a purge usually means I find another use for the plugin I just removed...

So I thought I'd try to write a plugin to get that info so I could search for it. Things that the Plugin manager knows, plus (most importantly) how to locate it in the GUI.

Processing is great for finding a lot of the built-in qgis functionality, but it doesn't find plugins which weren't written to make use of its framework.

Looking at the answer to listing installed plugins via pyqgis I was able to get a list of plugin names.

There seems to be a class, QgsPluginRegistry, which looks promising in the C++ code, but I can't find a SIP defintion file for that, so I don't think this class is exposed to python.

Using a bit of tracing through the QGIS source, I was able to write a short snippet to sniff the configuration files for the plugins

for x in qgis.utils.findPlugins("/home/steven/.qgis2/python/plugins"): 
    # gets a (name,ConfigParser) tuple
    print "_"*80
    print x[0] # plugin name
    for key in x[1].options('general'):
        print "\t%s = %s" % (key, x[1].get('general',key))

This gives me access to the same info as the qgis plugin manager... changelogs, authorship, category and so on.

qgsAffine
    name = Affine Transformations
    qgisminimumversion = 2.0
    description = Apply affine transformations to selected geometries.
    version = 1.0.2
    author = Mauricio de Paulo and Erik Timmers
    email = [redacted]
    changelog = [snipped]
    experimental = False
    deprecated = False
    tags = 
    homepage = [redacted]
    repository = [redacted]
    tracker = [redacted]
    icon = icon.svg
    category = Vector

What it doesn't tell me is where, exactly, is it in the menu structure? Can this be got from pyqgis in a clean way?

Or to find this, do I need to start sniffing round the Qt GUI classes or writing python parsers (doable, but seems a bit over the top?) The category value (vector, raster etc) helps narrow the search, but there are plenty of plugins (e.g. MMqgis) which create their own menus.

2

Only an uninformed guess, but since plugins are only added to menus/toolbars when loaded - ie part of their classFactory instantiation process, and removed in the same way, there is probably no need to have any record of which menus plugins are in. You'd have to look at lower-level querying of the full QGIS menu options, not just plugins. No idea if that is possible.

  • I'll give you that, as it's something that would require a low-level querying of QActions.. or tweaking the plugin loader itself. I got reasonably far with this, but got stuck identifying which plugin would receive which click event..it's trivial to connect(), but I couldn't work out how to query that connection once it's been made by the plugin. But that's a more generic Qt programming question so I'll throw myself at the mercy of SO :) – Steven Kay Nov 26 '15 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.