Skip to content

Commit 3ddb021

Browse files
author
mhugent
committed
Make default svg path configurable for third party apps
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13217 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f012bab commit 3ddb021

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

python/core/qgsapplication.sip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
185185

186186
//! Alters pkg data path - used by 3rd party apps
187187
static void setPkgDataPath(const QString thePkgDataPath);
188+
189+
//! Alters default svg paths - used by 3rd party apps. Added in QGIS 1.5
190+
static void setDefaultSvgPaths( const QStringList& pathList );
188191

189192
//! loads providers
190193
static void initQgis();

src/app/composer/qgscomposerpicturewidget.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,14 @@ void QgsComposerPictureWidget::addStandardDirectoriesToPreview()
445445
QDir svgDirectory( svgPaths[i] );
446446
if ( !svgDirectory.exists() || !svgDirectory.isReadable() )
447447
{
448-
return; //error
448+
continue;
449449
}
450+
451+
//add directory itself
452+
mSearchDirectoriesComboBox->addItem( svgDirectory.absolutePath() );
453+
addDirectoryToPreview( svgDirectory.absolutePath() );
450454

455+
//and also subdirectories
451456
QFileInfoList directoryList = svgDirectory.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
452457
QFileInfoList::const_iterator dirIt = directoryList.constBegin();
453458
for ( ; dirIt != directoryList.constEnd(); ++dirIt )

src/core/qgsapplication.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ QString QgsApplication::mPrefixPath;
4343
QString QgsApplication::mPluginPath;
4444
QString QgsApplication::mPkgDataPath;
4545
QString QgsApplication::mThemeName;
46+
QStringList QgsApplication::mDefaultSvgPaths;
4647

4748
/*!
4849
\class QgsApplication
@@ -73,6 +74,9 @@ QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled )
7374
#if ! defined(Q_WS_WIN) && ! defined(Q_WS_MAC)
7475
setWindowIcon( QPixmap( qgis_xpm ) ); // Linux
7576
#endif
77+
78+
mDefaultSvgPaths << mPkgDataPath + QString( "/svg/" );
79+
mDefaultSvgPaths << qgisSettingsDirPath() + QString( "svg/" );
7680
}
7781

7882
QgsApplication::~QgsApplication()
@@ -129,6 +133,11 @@ void QgsApplication::setPkgDataPath( const QString thePkgDataPath )
129133
mPkgDataPath = thePkgDataPath;
130134
}
131135

136+
void QgsApplication::setDefaultSvgPaths( const QStringList& pathList )
137+
{
138+
mDefaultSvgPaths = pathList;
139+
}
140+
132141
const QString QgsApplication::prefixPath()
133142
{
134143
return mPrefixPath;
@@ -313,12 +322,9 @@ const QStringList QgsApplication::svgPaths()
313322
{
314323
myPathList = myPaths.split( "|" );
315324
}
316-
//additional default paths
317-
myPathList
318-
<< mPkgDataPath + QString( "/svg/" )
319-
<< qgisSettingsDirPath() + QString( "svg/" );
320-
return myPathList;
321325

326+
myPathList << mDefaultSvgPaths;
327+
return myPathList;
322328
}
323329

324330
/*!

src/core/qgsapplication.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ class CORE_EXPORT QgsApplication: public QApplication
142142
//! Alters pkg data path - used by 3rd party apps
143143
static void setPkgDataPath( const QString thePkgDataPath );
144144

145+
//! Alters default svg paths - used by 3rd party apps. Added in QGIS 1.5
146+
static void setDefaultSvgPaths( const QStringList& pathList );
147+
145148
//! loads providers
146149
static void initQgis();
147150

@@ -184,6 +187,7 @@ class CORE_EXPORT QgsApplication: public QApplication
184187
static QString mPluginPath;
185188
static QString mPkgDataPath;
186189
static QString mThemeName;
190+
static QStringList mDefaultSvgPaths;
187191
};
188192

189193
#endif

0 commit comments

Comments
 (0)