Skip to content

Commit 7cae5cc

Browse files
author
wonder
committed
Added QgsApplication::iconPath utility function (and removed its declaration from QgsSymbolLayerV2Utils)
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13352 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 54f6c94 commit 7cae5cc

File tree

5 files changed

+25
-34
lines changed

5 files changed

+25
-34
lines changed

src/core/qgsapplication.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ const QString QgsApplication::activeThemePath()
159159
return ":/images/themes/" + mThemeName + "/";
160160
}
161161

162+
163+
QString QgsApplication::iconPath( QString iconFile )
164+
{
165+
// try active theme
166+
QString path = activeThemePath();
167+
if ( QFile::exists( path + iconFile ) )
168+
return path + iconFile;
169+
170+
// use default theme
171+
return defaultThemePath() + iconFile;
172+
}
173+
162174
/*!
163175
Set the theme path to the specified theme.
164176
*/

src/core/qgsapplication.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ class CORE_EXPORT QgsApplication: public QApplication
131131
//! Returns the path to the default theme directory.
132132
static const QString defaultThemePath();
133133

134+
//! Returns path to the desired icon file.
135+
//! First it tries to use the active theme path, then default theme path
136+
//! @note Added in 1.5
137+
static QString iconPath( QString iconFile );
138+
134139
//! Returns the path to user's style. Added in QGIS 1.4
135140
static const QString userStyleV2Path();
136141

src/core/symbology-ng/qgssymbollayerv2utils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
7979
/**Creates a render context for a pixel based device*/
8080
static QgsRenderContext createRenderContext( QPainter* p );
8181

82-
static QString iconPath( QString iconFile );
83-
8482
/**Multiplies opacity of image pixel values with a (global) transparency value*/
8583
static void multiplyImageOpacity( QImage* image, qreal alpha );
8684
};

src/gui/symbology-ng/qgsstylev2managerdialog.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@
1919
#include "qgslogger.h"
2020

2121

22-
static QString iconPath( QString iconFile )
23-
{
24-
// try active theme
25-
QString path = QgsApplication::activeThemePath();
26-
if ( QFile::exists( path + iconFile ) )
27-
return path + iconFile;
28-
29-
// use default theme
30-
return QgsApplication::defaultThemePath() + iconFile;
31-
}
32-
33-
///////
3422

3523
QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* parent )
3624
: QDialog( parent ), mStyle( style ), mModified( false )
@@ -39,9 +27,9 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
3927
setupUi( this );
4028

4129
// setup icons
42-
btnAddItem->setIcon( QIcon( iconPath( "symbologyAdd.png" ) ) );
43-
btnEditItem->setIcon( QIcon( iconPath( "symbologyEdit.png" ) ) );
44-
btnRemoveItem->setIcon( QIcon( iconPath( "symbologyRemove.png" ) ) );
30+
btnAddItem->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.png" ) ) );
31+
btnEditItem->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.png" ) ) );
32+
btnRemoveItem->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.png" ) ) );
4533

4634
connect( this, SIGNAL( finished( int ) ), this, SLOT( onFinished() ) );
4735

src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,6 @@ class SymbolLayerItem : public QStandardItem
5757

5858
//////////
5959

60-
static QString iconPath( QString iconFile )
61-
{
62-
// try active theme
63-
QString path = QgsApplication::activeThemePath();
64-
if ( QFile::exists( path + iconFile ) )
65-
return path + iconFile;
66-
67-
// use default theme
68-
return QgsApplication::defaultThemePath() + iconFile;
69-
}
70-
71-
//////////
7260

7361
static bool _initWidgetFunction( QString name, QgsSymbolLayerV2WidgetFunc f )
7462
{
@@ -119,11 +107,11 @@ QgsSymbolV2PropertiesDialog::QgsSymbolV2PropertiesDialog( QgsSymbolV2* symbol, Q
119107
setupUi( this );
120108

121109
// setup icons
122-
btnAddLayer->setIcon( QIcon( iconPath( "symbologyAdd.png" ) ) );
123-
btnRemoveLayer->setIcon( QIcon( iconPath( "symbologyRemove.png" ) ) );
124-
btnLock->setIcon( QIcon( iconPath( "symbologyLock.png" ) ) );
125-
btnUp->setIcon( QIcon( iconPath( "symbologyUp.png" ) ) );
126-
btnDown->setIcon( QIcon( iconPath( "symbologyDown.png" ) ) );
110+
btnAddLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.png" ) ) );
111+
btnRemoveLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.png" ) ) );
112+
btnLock->setIcon( QIcon( QgsApplication::iconPath( "symbologyLock.png" ) ) );
113+
btnUp->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.png" ) ) );
114+
btnDown->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.png" ) ) );
127115

128116
// set widget functions
129117
// (should be probably moved somewhere else)

0 commit comments

Comments
 (0)