Skip to content

Commit 86be11e

Browse files
author
borysiasty
committedMar 22, 2009
Support for icon themes for the core plugins
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10403 c8812cc2-4d05-0410-92ff-de0c093fc19c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+516
-1399
lines changed
 

‎src/plugins/coordinate_capture/coordinatecapture.cpp

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/***************************************************************************
22
coordinatecapture.cpp
3-
Capture mouse coordinates in different CRS
3+
// Capture mouse coordinates in different CRS
44
-------------------
55
begin : [PluginDate]
66
copyright : [(C) Your Name and Date]
@@ -22,6 +22,7 @@
2222

2323
#include <qgisinterface.h>
2424
#include <qgisgui.h>
25+
#include "qgsapplication.h"
2526
#include <qgspoint.h>
2627
#include <qgsmapcanvas.h>
2728
#include <qgsmaprenderer.h>
@@ -45,6 +46,7 @@
4546
#include <QClipboard>
4647
#include <QPushButton>
4748
#include <QToolButton>
49+
#include <QFile>
4850

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

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

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

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

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

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

146+
// Set the icons
147+
setCurrentTheme( "" );
148+
147149
mypLayout->addWidget( mypUserCrsToolButton, 0, 0 );
148150
mypLayout->addWidget( mpUserCrsEdit, 0, 1 );
149151
mypLayout->addWidget( mypCRSLabel, 1, 0 );
@@ -259,12 +261,41 @@ void CoordinateCapture::unload()
259261
delete mQActionPointer;
260262
}
261263

262-
void CoordinateCapture::setCurrentTheme ( QString theThemeName )
264+
// Set icons to the current theme
265+
void CoordinateCapture::setCurrentTheme( QString theThemeName )
266+
{
267+
mQActionPointer->setIcon( QIcon( getIconPath( "coordinate_capture.png" ) ) );
268+
mpTrackMouseButton->setIcon( QIcon( getIconPath( "tracking.png" ) ) );
269+
mpCaptureButton->setIcon( QIcon( getIconPath( "coordinate_capture.png" ) ) );
270+
mypUserCrsToolButton->setIcon( QIcon( getIconPath( "geographic.png" ) ) );
271+
mypCRSLabel->setPixmap( QPixmap( getIconPath( "transformed.png" ) ) );
272+
}
273+
274+
// Get path to the best available icon file
275+
QString CoordinateCapture::getIconPath( const QString theName )
263276
{
264-
qDebug (" Current theme changed \n\n\n\n\n" );
265-
mQActionPointer->setIcon( QIcon());
277+
QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/coordinate_capture/" + theName;
278+
QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/coordinate_capture/" + theName;
279+
QString myQrcPath = ":/coordinate_capture/" + theName;
280+
if ( QFile::exists( myCurThemePath ) )
281+
{
282+
return myCurThemePath;
283+
}
284+
else if ( QFile::exists( myDefThemePath ) )
285+
{
286+
return myDefThemePath;
287+
}
288+
else if ( QFile::exists( myQrcPath ) )
289+
{
290+
return myQrcPath;
291+
}
292+
else
293+
{
294+
return "";
295+
}
266296
}
267297

298+
268299
//////////////////////////////////////////////////////////////////////////
269300
//
270301
//

‎src/plugins/coordinate_capture/coordinatecapture.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class QToolButton;
5353
class QPushButton;
5454
class QDockWidget;
5555
class QLineEdit;
56+
class QIcon;
57+
class QLabel;
5658

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

123-
//!A toolbutton to keep track whether mouse tracking is enabled
125+
//!A two buttons to track and capture coordinates
124126
QToolButton * mpTrackMouseButton;
125127
QPushButton * mpCaptureButton;
126128

129+
//! A toolbutton to select crs to display the coordinates
130+
QToolButton * mypUserCrsToolButton;
131+
132+
//! A label for coordinates in the project crs
133+
QLabel * mypCRSLabel;
134+
127135
//! transform object
128136
QgsCoordinateTransform mTransform;
129137

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

147+
//! Get the path to the icon from the best available theme
148+
QString getIconPath( const QString theName );
149+
139150
////////////////////////////////////////////////////////////////////
140151
//
141152
// MANDATORY PLUGIN PROPERTY DECLARATIONS .....

0 commit comments

Comments
 (0)
Please sign in to comment.