[Qgis-developer] Re: themes in the Grass plugin (r9900)

Borys Jurgiel borys at wolf.most.org.pl
Sun Dec 28 05:28:07 EST 2008


Sunday 28 of December 2008 09:14:57 Tim Sutton napisał(a):
> Hi
>
> When I tested with your r9862 change below, it didnt pick up my grass
> 'gis' theme icons.
>
> If we are going to go the non qrc route we will need to change all the
> plugins to install their icons into
>
> <CMAKE_INSTALL_PREFIX>/share/qgis/themes/<foo theme>
>
> The qrc approach is kinda nice in that it makes the plugins self
> contained. Its also possible to combine the two approaches - look in the
> qrc file for the theme icon and if its not there look in the file based
> themes dir, and if its not there either fall back to the default icon.

My idea is to combine them too, but with different search odrer:
1. file-based current theme icon (in share/qgis/themes/[ACTIVE]/plugins/)
2. file-based default theme icon (in share/qgis/themes/default/plugins/)
3. qrc-based local plugin icon


QIcon QgsCopyrightLabelPlugin::getThemeIcon( const QString theName )
{
  QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/" + theName;
  QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/" + theName;
  QString myQrcPath = ":/" + theName;
  if ( QFile::exists( myCurThemePath ) )
  {
    return QIcon( myCurThemePath );
  }
  else if ( QFile::exists( myDefThemePath ) )
  {
    return QIcon( myDefThemePath );
  }
  else if ( QFile::exists( myQrcPath ) )
  {
    return QIcon( myQrcPath );
  }
  else
  {
    return QIcon();
  }
}


It should provide the most uniform look and still saves the plugin
independence. You've written:

// Note this code is duplicated from qgisapp.cpp because
// I didnt want to make plugins dependent on qgsapplication (...)

It's dependent on QgsApplication::activeThemePath() and ::defaultThemePath(), 
but it's very easy to liberate by commenting them out and leaving
only the last (qrc) path.

So if you agree, I'll aply this unified combined version to all plugins.


More information about the Qgis-developer mailing list