Skip to content
Permalink
Browse files

Support for icon themes for the core plugins

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10403 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty
borysiasty committed Mar 22, 2009
1 parent 615e97d commit 86be11e4583c96ba48c7eda97eb26e698a24a55c
Showing with 516 additions and 1,399 deletions.
  1. +42 −11 src/plugins/coordinate_capture/coordinatecapture.cpp
  2. +12 −1 src/plugins/coordinate_capture/coordinatecapture.h
  3. +1 −1 src/plugins/coordinate_capture/coordinatecapture.qrc
  4. +30 −4 src/plugins/copyright_label/plugin.cpp
  5. +2 −0 src/plugins/copyright_label/plugin.h
  6. +31 −2 src/plugins/delimited_text/qgsdelimitedtextplugin.cpp
  7. +2 −0 src/plugins/delimited_text/qgsdelimitedtextplugin.h
  8. +33 −1 src/plugins/dxf2shp_converter/dxf2shpconverter.cpp
  9. +2 −0 src/plugins/dxf2shp_converter/dxf2shpconverter.h
  10. +1 −1 src/plugins/dxf2shp_converter/dxf2shpconverter.qrc
  11. +32 −1 src/plugins/georeferencer/plugin.cpp
  12. +2 −0 src/plugins/georeferencer/plugin.h
  13. +1 −1 src/plugins/georeferencer/qgsgeorefdescriptiondialogbase.ui
  14. +35 −4 src/plugins/gps_importer/qgsgpsplugin.cpp
  15. +2 −0 src/plugins/gps_importer/qgsgpsplugin.h
  16. +49 −19 src/plugins/grass/qgsgrassplugin.cpp
  17. +3 −1 src/plugins/grass/qgsgrassplugin.h
  18. +1 −1 src/plugins/interpolation/interpolator.qrc
  19. +1 −1 src/plugins/interpolation/qgsinterpolationdialogbase.ui
  20. +31 −1 src/plugins/interpolation/qgsinterpolationplugin.cpp
  21. +4 −0 src/plugins/interpolation/qgsinterpolationplugin.h
  22. +28 −4 src/plugins/north_arrow/plugin.cpp
  23. +2 −0 src/plugins/north_arrow/plugin.h
  24. +1 −1 src/plugins/ogr_converter/ogrconverter.qrc
  25. +33 −1 src/plugins/ogr_converter/plugin.cpp
  26. +3 −0 src/plugins/ogr_converter/plugin.h
  27. +1 −1 src/plugins/quick_print/quickprint.qrc
  28. +29 −1 src/plugins/quick_print/quickprintplugin.cpp
  29. +2 −0 src/plugins/quick_print/quickprintplugin.h
  30. +29 −1 src/plugins/scale_bar/plugin.cpp
  31. +2 −0 src/plugins/scale_bar/plugin.h
  32. +1 −1 src/plugins/spit/CMakeLists.txt
  33. +0 −739 src/plugins/spit/icon_spit.xpm
  34. +0 −4 src/plugins/spit/qgsspit.cpp
  35. +1 −1 src/plugins/spit/qgsspitbase.ui
  36. +30 −3 src/plugins/spit/qgsspitplugin.cpp
  37. +2 −0 src/plugins/spit/qgsspitplugin.h
  38. BIN src/plugins/spit/spit.png
  39. +2 −0 src/plugins/spit/spit.qrc
  40. BIN src/plugins/spit/spit_icon.png
  41. +0 −272 src/plugins/spit/spit_icons.h
  42. BIN src/plugins/spit/spit_image.png
  43. +0 −318 src/plugins/spit/spiticon.xpm
  44. +30 −1 src/plugins/wfs/qgswfsplugin.cpp
  45. +2 −0 src/plugins/wfs/qgswfsplugin.h
  46. BIN src/plugins/wfs/{mIconAddWfsLayer.png → wfs.png}
  47. +1 −1 src/plugins/wfs/wfsplugin.qrc
@@ -1,6 +1,6 @@
/***************************************************************************
coordinatecapture.cpp
Capture mouse coordinates in different CRS
// Capture mouse coordinates in different CRS
-------------------
begin : [PluginDate]
copyright : [(C) Your Name and Date]
@@ -22,6 +22,7 @@

#include <qgisinterface.h>
#include <qgisgui.h>
#include "qgsapplication.h"
#include <qgspoint.h>
#include <qgsmapcanvas.h>
#include <qgsmaprenderer.h>
@@ -45,6 +46,7 @@
#include <QClipboard>
#include <QPushButton>
#include <QToolButton>
#include <QFile>

static const char * const sIdent = "$Id: plugin.cpp 8053 2008-01-26 13:59:53Z timlinux $";
static const QString sName = QObject::tr( "Coordinate Capture" );
@@ -90,7 +92,7 @@ void CoordinateCapture::initGui()
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 3 : 5; // precision depends on CRS units

// Create the action for tool
mQActionPointer = new QAction( QIcon( ":/coordinatecapture/coordinate_capture.png" ), tr( "Coordinate Capture" ), this );
mQActionPointer = new QAction( QIcon(), tr( "Coordinate Capture" ), this );
// Set the what's this text
mQActionPointer->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) );
// Connect the action to the run
@@ -109,13 +111,11 @@ void CoordinateCapture::initGui()
mypLayout->setColumnMinimumWidth( 0, 36 );
mypWidget->setLayout( mypLayout );

QToolButton * mypUserCrsToolButton = new QToolButton( mypWidget );
mypUserCrsToolButton->setIcon( QIcon( ":/coordinatecapture/geographic.png" ) );
mypUserCrsToolButton = new QToolButton( mypWidget );
mypUserCrsToolButton->setToolTip( tr( "Click to select the CRS to use for coordinate display" ) );
connect( mypUserCrsToolButton, SIGNAL( clicked() ), this, SLOT( setCRS() ) );

QLabel * mypCRSLabel = new QLabel( mypWidget );
mypCRSLabel->setPixmap( QPixmap( ":/coordinatecapture/transformed.png" ) );
mypCRSLabel = new QLabel( mypWidget );
mypCRSLabel->setGeometry( mypUserCrsToolButton->geometry() );

mpUserCrsEdit = new QLineEdit( mypWidget );
@@ -134,16 +134,18 @@ void CoordinateCapture::initGui()
mpTrackMouseButton->setCheckable( true );
mpTrackMouseButton->setToolTip( tr( "Click to enable mouse tracking. Click the canvas to stop" ) );
mpTrackMouseButton->setChecked( false );
mpTrackMouseButton->setIcon( QIcon( ":/coordinatecapture/tracking.png" ) );

// Create the action for tool
mpCaptureButton = new QPushButton( mypWidget );
mpCaptureButton->setText( tr( "Start capture" ) );
mpCaptureButton->setToolTip( tr( "Click to enable coordinate capture" ) );
mpCaptureButton->setIcon( QIcon( ":/coordinatecapture/coordinatecapture/coordinate_capture.png" ));
mpCaptureButton->setIcon( QIcon( ":/coordinate_capture/coordinate_capture.png" ));
mpCaptureButton->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) );
connect( mpCaptureButton, SIGNAL( clicked() ), this, SLOT( run() ) );

// Set the icons
setCurrentTheme( "" );

mypLayout->addWidget( mypUserCrsToolButton, 0, 0 );
mypLayout->addWidget( mpUserCrsEdit, 0, 1 );
mypLayout->addWidget( mypCRSLabel, 1, 0 );
@@ -259,12 +261,41 @@ void CoordinateCapture::unload()
delete mQActionPointer;
}

void CoordinateCapture::setCurrentTheme ( QString theThemeName )
// Set icons to the current theme
void CoordinateCapture::setCurrentTheme( QString theThemeName )
{
mQActionPointer->setIcon( QIcon( getIconPath( "coordinate_capture.png" ) ) );
mpTrackMouseButton->setIcon( QIcon( getIconPath( "tracking.png" ) ) );
mpCaptureButton->setIcon( QIcon( getIconPath( "coordinate_capture.png" ) ) );
mypUserCrsToolButton->setIcon( QIcon( getIconPath( "geographic.png" ) ) );
mypCRSLabel->setPixmap( QPixmap( getIconPath( "transformed.png" ) ) );
}

// Get path to the best available icon file
QString CoordinateCapture::getIconPath( const QString theName )
{
qDebug (" Current theme changed \n\n\n\n\n" );
mQActionPointer->setIcon( QIcon());
QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/coordinate_capture/" + theName;
QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/coordinate_capture/" + theName;
QString myQrcPath = ":/coordinate_capture/" + theName;
if ( QFile::exists( myCurThemePath ) )
{
return myCurThemePath;
}
else if ( QFile::exists( myDefThemePath ) )
{
return myDefThemePath;
}
else if ( QFile::exists( myQrcPath ) )
{
return myQrcPath;
}
else
{
return "";
}
}


//////////////////////////////////////////////////////////////////////////
//
//
@@ -53,6 +53,8 @@ class QToolButton;
class QPushButton;
class QDockWidget;
class QLineEdit;
class QIcon;
class QLabel;

class QgisInterface;
class QgsPoint;
@@ -120,10 +122,16 @@ class CoordinateCapture: public QObject, public QgisPlugin
//!Our custom map tool to capture clicks
CoordinateCaptureMapTool * mpMapTool;

//!A toolbutton to keep track whether mouse tracking is enabled
//!A two buttons to track and capture coordinates
QToolButton * mpTrackMouseButton;
QPushButton * mpCaptureButton;

//! A toolbutton to select crs to display the coordinates
QToolButton * mypUserCrsToolButton;

//! A label for coordinates in the project crs
QLabel * mypCRSLabel;

//! transform object
QgsCoordinateTransform mTransform;

@@ -136,6 +144,9 @@ class CoordinateCapture: public QObject, public QgisPlugin
//! user coordinate display precision
int mUserCrsDisplayPrecision;

//! Get the path to the icon from the best available theme
QString getIconPath( const QString theName );

////////////////////////////////////////////////////////////////////
//
// MANDATORY PLUGIN PROPERTY DECLARATIONS .....
@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/coordinatecapture/" >
<qresource prefix="/coordinate_capture/" >
<file>coordinate_capture.png</file>
<file>geographic.png</file>
<file>transformed.png</file>
@@ -24,6 +24,7 @@ email : tim@linfiniti.com

#include "qgisinterface.h"
#include "qgisgui.h"
#include "qgsapplication.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayer.h"
#include "qgsproject.h"
@@ -35,6 +36,7 @@ email : tim@linfiniti.com
#include <QDate>
#include <QTextDocument>
#include <QMatrix>
#include <QFile>

//non qt includes
#include <cmath>
@@ -74,7 +76,8 @@ QgsCopyrightLabelPlugin::~QgsCopyrightLabelPlugin()
void QgsCopyrightLabelPlugin::initGui()
{
// Create the action for tool
myQActionPointer = new QAction( QIcon( ":/copyright_label.png" ), tr( "&Copyright Label" ), this );
myQActionPointer = new QAction( QIcon(), tr( "&Copyright Label" ), this );
setCurrentTheme( "" );
myQActionPointer->setWhatsThis( tr( "Creates a copyright label that is displayed on the map canvas." ) );
// Connect the action to the run
connect( myQActionPointer, SIGNAL( activated() ), this, SLOT( run() ) );
@@ -83,6 +86,9 @@ void QgsCopyrightLabelPlugin::initGui()
//this resets this plugin up if a project is loaded
connect( qGisInterface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( projectRead() ) );

// this is called when the icon theme is changed
connect( qGisInterface, SIGNAL( currentThemeChanged ( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );

// Add the icon to the toolbar
qGisInterface->addToolBarIcon( myQActionPointer );
qGisInterface->addPluginToMenu( tr( "&Decorations" ), myQActionPointer );
@@ -251,9 +257,29 @@ void QgsCopyrightLabelPlugin::setEnable( bool theBool )
refreshCanvas();
}




//! Set icons to the current theme
void QgsCopyrightLabelPlugin::setCurrentTheme( QString theThemeName )
{
QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/copyright_label.png";
QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/copyright_label.png";
QString myQrcPath = ":/copyright_label.png";
if ( QFile::exists( myCurThemePath ) )
{
myQActionPointer->setIcon( QIcon( myCurThemePath ) );
}
else if ( QFile::exists( myDefThemePath ) )
{
myQActionPointer->setIcon( QIcon( myDefThemePath ) );
}
else if ( QFile::exists( myQrcPath ) )
{
myQActionPointer->setIcon( QIcon( myQrcPath ) );
}
else
{
myQActionPointer->setIcon( QIcon() );
}
}

/**
* Required extern functions needed for every plugin
@@ -70,6 +70,8 @@ class QgsCopyrightLabelPlugin: public QObject, public QgisPlugin
void setPlacement( int );
//! set copyright label enabled
void setEnable( bool );
//! update the plugins theme when the app tells us its theme is changed
void setCurrentTheme ( QString theThemeName );



@@ -24,12 +24,14 @@

#include "qgisinterface.h"
#include "qgisgui.h"
#include "qgsapplication.h"
#include "qgsmaplayer.h"
#include "qgsdelimitedtextplugin.h"


#include <QMenu>
#include <QAction>
#include <QFile>

//non qt includes
#include <iostream>
@@ -96,8 +98,8 @@ void QgsDelimitedTextPlugin::help()
void QgsDelimitedTextPlugin::initGui()
{
// Create the action for tool
myQActionPointer = new QAction( QIcon( ":/delimited_text.png" ), tr( "&Add Delimited Text Layer" ), this );

myQActionPointer = new QAction( QIcon(), tr( "&Add Delimited Text Layer" ), this );
setCurrentTheme( "" );
myQActionPointer->setWhatsThis( tr( "Add a delimited text file as a map layer. "
"The file must have a header row containing the field names. "
"X and Y fields are required and must contain coordinates in decimal units." ) );
@@ -106,6 +108,8 @@ void QgsDelimitedTextPlugin::initGui()
// Add the icon to the toolbar
qGisInterface->addToolBarIcon( myQActionPointer );
qGisInterface->addPluginToMenu( tr( "&Delimited text" ), myQActionPointer );
// this is called when the icon theme is changed
connect( qGisInterface, SIGNAL( currentThemeChanged ( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );

}

@@ -141,6 +145,31 @@ void QgsDelimitedTextPlugin::unload()
qGisInterface->removeToolBarIcon( myQActionPointer );
delete myQActionPointer;
}

//! Set icons to the current theme
void QgsDelimitedTextPlugin::setCurrentTheme( QString theThemeName )
{
QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/delimited_text.png";
QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/delimited_text.png";
QString myQrcPath = ":/delimited_text.png";
if ( QFile::exists( myCurThemePath ) )
{
myQActionPointer->setIcon( QIcon( myCurThemePath ) );
}
else if ( QFile::exists( myDefThemePath ) )
{
myQActionPointer->setIcon( QIcon( myDefThemePath ) );
}
else if ( QFile::exists( myQrcPath ) )
{
myQActionPointer->setIcon( QIcon( myQrcPath ) );
}
else
{
myQActionPointer->setIcon( QIcon() );
}
}

/**
* Required extern functions needed for every plugin
* These functions can be called prior to creating an instance
@@ -68,6 +68,8 @@ class QgsDelimitedTextPlugin: public QObject, public QgisPlugin, private Ui::Qgs
void unload();
//! show the help document
void help();
//! update the plugins theme when the app tells us its theme is changed
void setCurrentTheme ( QString theThemeName );
private:


@@ -20,6 +20,7 @@

#include <qgisinterface.h>
#include <qgisgui.h>
#include <qgsapplication.h>
#include <qgsvectorlayer.h>

#include "dxf2shpconverter.h"
@@ -30,6 +31,7 @@
//

#include <QAction>
#include <QFile>
#include <QToolBar>

static const char *const sIdent =
@@ -66,7 +68,10 @@ dxf2shpConverter::~dxf2shpConverter()
void dxf2shpConverter::initGui()
{
// Create the action for tool
mQActionPointer = new QAction( QIcon( ":/dxf2shpconverter/dxf2shp_converter.png" ), "Dxf2Shp Converter", this );
mQActionPointer = new QAction( QIcon(), "Dxf2Shp Converter", this );

// Set the icon
setCurrentTheme( "" );

// Set the what's this text
mQActionPointer->setWhatsThis( tr( "Converts DXF files in Shapefile format" ) );
@@ -77,6 +82,9 @@ void dxf2shpConverter::initGui()
// Add the icon to the toolbar
mQGisIface->addToolBarIcon( mQActionPointer );
mQGisIface->addPluginToMenu( tr( "&Dxf2Shp" ), mQActionPointer );

// this is called when the icon theme is changed
connect( mQGisIface, SIGNAL( currentThemeChanged ( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );
}

//method defined in interface
@@ -115,6 +123,30 @@ void dxf2shpConverter::addMyLayer( QString myfname, QString mytitle )
mQGisIface->addVectorLayer( myfname, mytitle, "ogr" );
}

//! Set icons to the current theme
void dxf2shpConverter::setCurrentTheme( QString theThemeName )
{
QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/dxf2shp_converter.png";
QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/dxf2shp_converter.png";
QString myQrcPath = ":/dxf2shp_converter.png";
if ( QFile::exists( myCurThemePath ) )
{
mQActionPointer->setIcon( QIcon( myCurThemePath ) );
}
else if ( QFile::exists( myDefThemePath ) )
{
mQActionPointer->setIcon( QIcon( myDefThemePath ) );
}
else if ( QFile::exists( myQrcPath ) )
{
mQActionPointer->setIcon( QIcon( myQrcPath ) );
}
else
{
mQActionPointer->setIcon( QIcon() );
}
}

//////////////////////////////////////////////////////////////////////////
//
//
@@ -61,6 +61,8 @@ class dxf2shpConverter: public QObject, public QgisPlugin
void unload();
//! show the help document
void help();
//! update the plugins theme when the app tells us its theme is changed
void setCurrentTheme ( QString theThemeName );

void addMyLayer( QString, QString );

@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/dxf2shpconverter/" >
<qresource prefix="/" >
<file>dxf2shp_converter.png</file>
</qresource>
</RCC>

0 comments on commit 86be11e

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