[Qgis-developer] Better Menus for QGIS 1.0

Tim Sutton tim at linfiniti.com
Fri Aug 15 14:53:01 EDT 2008


Hi

Tom Wrote:
>
> I'm in favor of allowing plugin menus and items to be placed anywhere.
>

Great. I guess the rider to this is that if we allow a plugin to e.g.
put an action into the edit menu, the action should also be placed in
the edit toolbar (if the plugin writer wishes it to appear in the
toolbar at all).


> The WFS plugin has one command which probably belongs on the Layer menu
> after the WMS item. Since menu insertion uses a 'before' argument, the code
> would look like:
>
> qgisApp->layerMenu()->insert(
>  qgisApp->actionLayerSeparator1(), actionAddWfsLayer);
>


Right - I made a dirty kludge in src/app/qgisappinterface.h

 74         QToolBar* addToolBar(QString name);
 75         /** Get the file toolbar - intended for use with plugins which
 76          *   add a new file type handler.
 77          */
 78         QToolBar * fileToolBar(); <--- **kludge**

Which I made to try to allow the plugins like wms, wfs, gps to more
naturally be put into the toolbar for layers. My feeling is that we
should modify the plugin api to do something like:

//access to QGISAPP toolbars
QStringList toolBarList();
QToolBar * toolBar(QString name);
QToolBar * addToolBar(QString name);
//access to QGISAPP menus
QStringList menuList();
QMenu * menu(QString name);
QMenu * addMenu(QString name);

This should give plugin writers leave to put their actions pretty much
anywhere needed and even e.g. remove one action if they are replacing
it with a new and better one. Of course they would need to implement
their plugins to respect the HIG guidelines as you have described
which is something we could not always rely on but should document
somewhere on the coders manual or similar.

> GRASS provides a large set of commands and perhaps should have its own
> top-level menu. It would look like:
>
> qgisApp->menuBar()->insertMenu( qgisApp->lastMenu()->menuAction(),
> menuGrass);
>
> If a plugin has one command, the item should be directly in some menu or the
> Plugin menu by default. If it has a few commands, they should be in a Plugin
> menu submenu if not inserted elsewhere individually. If it has many
> commands, they should probably be a top-level menu.
>
> One issue created by menu insertion, however, is that it depends upon the
> order in which plugins are loaded. For example, if two plugins are loaded
> which insert an "Add xyz Layer" item in the same place and then the first
> plugin is unloaded and later reloaded, the order of the two menu items will
> be reversed.
>
> Perhaps this will be rare or perhaps not. In the future, the demand may
> arise for the ability to order the loading of plugins or even for users to
> customization where plugin items go. These issues can be addressed after
> QGIS 1.0.

Perhaps menu ordering and plugin ordering are things that can to some
extent be addressed by giving plugin writers full access to the menus
as I described above - though I suspect it wont go far enough....

Regards

Tim



-- 
Tim Sutton
QGIS Project Steering Committee Member - Release Manager
Visit http://qgis.org for a great open source GIS
Blog: http://tim.linfiniti.com
Skype: timlinux
Irc: timlinux on #qgis at freenode.net


More information about the Qgis-developer mailing list