Skip to content

Commit

Permalink
Added QgsApplication::iconPath utility function (and removed its decl…
Browse files Browse the repository at this point in the history
…aration from QgsSymbolLayerV2Utils)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13352 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 23, 2010
1 parent 54f6c94 commit 7cae5cc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 34 deletions.
12 changes: 12 additions & 0 deletions src/core/qgsapplication.cpp
Expand Up @@ -159,6 +159,18 @@ const QString QgsApplication::activeThemePath()
return ":/images/themes/" + mThemeName + "/";
}


QString QgsApplication::iconPath( QString iconFile )
{
// try active theme
QString path = activeThemePath();
if ( QFile::exists( path + iconFile ) )
return path + iconFile;

// use default theme
return defaultThemePath() + iconFile;
}

/*!
Set the theme path to the specified theme.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsapplication.h
Expand Up @@ -131,6 +131,11 @@ class CORE_EXPORT QgsApplication: public QApplication
//! Returns the path to the default theme directory.
static const QString defaultThemePath();

//! Returns path to the desired icon file.
//! First it tries to use the active theme path, then default theme path
//! @note Added in 1.5
static QString iconPath( QString iconFile );

//! Returns the path to user's style. Added in QGIS 1.4
static const QString userStyleV2Path();

Expand Down
2 changes: 0 additions & 2 deletions src/core/symbology-ng/qgssymbollayerv2utils.h
Expand Up @@ -79,8 +79,6 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
/**Creates a render context for a pixel based device*/
static QgsRenderContext createRenderContext( QPainter* p );

static QString iconPath( QString iconFile );

/**Multiplies opacity of image pixel values with a (global) transparency value*/
static void multiplyImageOpacity( QImage* image, qreal alpha );
};
Expand Down
18 changes: 3 additions & 15 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Expand Up @@ -19,18 +19,6 @@
#include "qgslogger.h"


static QString iconPath( QString iconFile )
{
// try active theme
QString path = QgsApplication::activeThemePath();
if ( QFile::exists( path + iconFile ) )
return path + iconFile;

// use default theme
return QgsApplication::defaultThemePath() + iconFile;
}

///////

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

// setup icons
btnAddItem->setIcon( QIcon( iconPath( "symbologyAdd.png" ) ) );
btnEditItem->setIcon( QIcon( iconPath( "symbologyEdit.png" ) ) );
btnRemoveItem->setIcon( QIcon( iconPath( "symbologyRemove.png" ) ) );
btnAddItem->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.png" ) ) );
btnEditItem->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.png" ) ) );
btnRemoveItem->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.png" ) ) );

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

Expand Down
22 changes: 5 additions & 17 deletions src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp
Expand Up @@ -57,18 +57,6 @@ class SymbolLayerItem : public QStandardItem

//////////

static QString iconPath( QString iconFile )
{
// try active theme
QString path = QgsApplication::activeThemePath();
if ( QFile::exists( path + iconFile ) )
return path + iconFile;

// use default theme
return QgsApplication::defaultThemePath() + iconFile;
}

//////////

static bool _initWidgetFunction( QString name, QgsSymbolLayerV2WidgetFunc f )
{
Expand Down Expand Up @@ -119,11 +107,11 @@ QgsSymbolV2PropertiesDialog::QgsSymbolV2PropertiesDialog( QgsSymbolV2* symbol, Q
setupUi( this );

// setup icons
btnAddLayer->setIcon( QIcon( iconPath( "symbologyAdd.png" ) ) );
btnRemoveLayer->setIcon( QIcon( iconPath( "symbologyRemove.png" ) ) );
btnLock->setIcon( QIcon( iconPath( "symbologyLock.png" ) ) );
btnUp->setIcon( QIcon( iconPath( "symbologyUp.png" ) ) );
btnDown->setIcon( QIcon( iconPath( "symbologyDown.png" ) ) );
btnAddLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.png" ) ) );
btnRemoveLayer->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.png" ) ) );
btnLock->setIcon( QIcon( QgsApplication::iconPath( "symbologyLock.png" ) ) );
btnUp->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.png" ) ) );
btnDown->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.png" ) ) );

// set widget functions
// (should be probably moved somewhere else)
Expand Down

0 comments on commit 7cae5cc

Please sign in to comment.