Skip to content

Commit

Permalink
Make default svg path configurable for third party apps
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13217 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 1, 2010
1 parent f012bab commit 3ddb021
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
3 changes: 3 additions & 0 deletions python/core/qgsapplication.sip
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)

//! Alters pkg data path - used by 3rd party apps
static void setPkgDataPath(const QString thePkgDataPath);

//! Alters default svg paths - used by 3rd party apps. Added in QGIS 1.5
static void setDefaultSvgPaths( const QStringList& pathList );

//! loads providers
static void initQgis();
Expand Down
7 changes: 6 additions & 1 deletion src/app/composer/qgscomposerpicturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,14 @@ void QgsComposerPictureWidget::addStandardDirectoriesToPreview()
QDir svgDirectory( svgPaths[i] );
if ( !svgDirectory.exists() || !svgDirectory.isReadable() )
{
return; //error
continue;
}

//add directory itself
mSearchDirectoriesComboBox->addItem( svgDirectory.absolutePath() );
addDirectoryToPreview( svgDirectory.absolutePath() );

//and also subdirectories
QFileInfoList directoryList = svgDirectory.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
QFileInfoList::const_iterator dirIt = directoryList.constBegin();
for ( ; dirIt != directoryList.constEnd(); ++dirIt )
Expand Down
16 changes: 11 additions & 5 deletions src/core/qgsapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ QString QgsApplication::mPrefixPath;
QString QgsApplication::mPluginPath;
QString QgsApplication::mPkgDataPath;
QString QgsApplication::mThemeName;
QStringList QgsApplication::mDefaultSvgPaths;

/*!
\class QgsApplication
Expand Down Expand Up @@ -73,6 +74,9 @@ QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled )
#if ! defined(Q_WS_WIN) && ! defined(Q_WS_MAC)
setWindowIcon( QPixmap( qgis_xpm ) ); // Linux
#endif

mDefaultSvgPaths << mPkgDataPath + QString( "/svg/" );
mDefaultSvgPaths << qgisSettingsDirPath() + QString( "svg/" );
}

QgsApplication::~QgsApplication()
Expand Down Expand Up @@ -129,6 +133,11 @@ void QgsApplication::setPkgDataPath( const QString thePkgDataPath )
mPkgDataPath = thePkgDataPath;
}

void QgsApplication::setDefaultSvgPaths( const QStringList& pathList )
{
mDefaultSvgPaths = pathList;
}

const QString QgsApplication::prefixPath()
{
return mPrefixPath;
Expand Down Expand Up @@ -313,12 +322,9 @@ const QStringList QgsApplication::svgPaths()
{
myPathList = myPaths.split( "|" );
}
//additional default paths
myPathList
<< mPkgDataPath + QString( "/svg/" )
<< qgisSettingsDirPath() + QString( "svg/" );
return myPathList;

myPathList << mDefaultSvgPaths;
return myPathList;
}

/*!
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ class CORE_EXPORT QgsApplication: public QApplication
//! Alters pkg data path - used by 3rd party apps
static void setPkgDataPath( const QString thePkgDataPath );

//! Alters default svg paths - used by 3rd party apps. Added in QGIS 1.5
static void setDefaultSvgPaths( const QStringList& pathList );

//! loads providers
static void initQgis();

Expand Down Expand Up @@ -184,6 +187,7 @@ class CORE_EXPORT QgsApplication: public QApplication
static QString mPluginPath;
static QString mPkgDataPath;
static QString mThemeName;
static QStringList mDefaultSvgPaths;
};

#endif

0 comments on commit 3ddb021

Please sign in to comment.