Skip to content
Permalink
Browse files

[FEATURE] Added option to load c++ plugins from user specified direct…

…ories. Requires application restart to activate.

git-svn-id: http://svn.osgeo.org/qgis/trunk@15250 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Feb 23, 2011
1 parent c41d2e6 commit 76a09b2546193d47d8db4cad9f70aa1e6290b15b
Showing with 159 additions and 29 deletions.
  1. +10 −1 src/app/qgisapp.cpp
  2. +55 −2 src/app/qgsoptions.cpp
  3. +12 −0 src/app/qgsoptions.h
  4. +9 −1 src/app/qgspluginregistry.cpp
  5. +3 −1 src/app/qgspluginregistry.h
  6. +70 −24 src/ui/qgsoptionsbase.ui
@@ -490,6 +490,16 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
QgsPluginRegistry::instance()->restoreSessionPlugins( QgsApplication::pluginPath() );
}

// Also restore plugins from user specified plugin directories - added for 1.7
QSettings settings;
QString myPaths = settings.value( "plugins/searchPathsForPlugins", "" ).toString();
if ( !myPaths.isEmpty() )
{
QStringList myPathList = myPaths.split( "|" );
QgsPluginRegistry::instance()->restoreSessionPlugins( myPathList );
QMessageBox::critical( this, tr( "Plugin paths" ), myPaths );
}

mSplash->showMessage( tr( "Initializing file filters" ), Qt::AlignHCenter | Qt::AlignBottom );
qApp->processEvents();
// now build vector file filter
@@ -541,7 +551,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mMapCanvas->mapRenderer()->setLabelingEngine( mLBL );

// Show a nice tip of the day
QSettings settings;
if ( settings.value( "/qgis/showTips", 1 ).toBool() )
{
mSplash->hide();
@@ -79,9 +79,23 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
spinBoxIdentifyValue->setMinimum( 0.01 );
spinBoxIdentifyValue->setValue( identifyValue );

//local directories to search when loading c++ plugins
QString myPaths = settings.value( "plugins/searchPathsForPlugins", "" ).toString();
if ( !myPaths.isEmpty() )
{
QStringList myPathList = myPaths.split( "|" );
QStringList::const_iterator pathIt = myPathList.constBegin();
for ( ; pathIt != myPathList.constEnd(); ++pathIt )
{
QListWidgetItem* newItem = new QListWidgetItem( mListPluginPaths );
newItem->setText( *pathIt );
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mListPluginPaths->addItem( newItem );
}
}

//local directories to search when looking for an SVG with a given basename
QString myPaths = settings.value( "svg/searchPathsForSVG", "" ).toString();
myPaths = settings.value( "svg/searchPathsForSVG", "" ).toString();
if ( !myPaths.isEmpty() )
{
QStringList myPathList = myPaths.split( "|" );
@@ -479,8 +493,20 @@ void QgsOptions::saveOptions()
{
QSettings settings;

//search directories for svgs
//search directories for user plugins
QString myPaths;
for ( int i = 0; i < mListPluginPaths->count(); ++i )
{
if ( i != 0 )
{
myPaths += "|";
}
myPaths += mListPluginPaths->item( i )->text();
}
settings.setValue( "plugins/searchPathsForPlugins", myPaths );

//search directories for svgs
myPaths;
for ( int i = 0; i < mListSVGPaths->count(); ++i )
{
if ( i != 0 )
@@ -881,6 +907,33 @@ QStringList QgsOptions::i18nList()
return myList;
}

void QgsOptions::on_mBtnAddPluginPath_clicked()
{
QString myDir = QFileDialog::getExistingDirectory(
this,
tr( "Choose a directory" ),
QDir::toNativeSeparators( QDir::homePath() ),
QFileDialog::ShowDirsOnly
);

if ( ! myDir.isEmpty() )
{
QListWidgetItem* newItem = new QListWidgetItem( mListPluginPaths );
newItem->setText( myDir );
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mListPluginPaths->addItem( newItem );
mListPluginPaths->setCurrentItem( newItem );
}
}

void QgsOptions::on_mBtnRemovePluginPath_clicked()
{
int currentRow = mListPluginPaths->currentRow();
QListWidgetItem* itemToRemove = mListPluginPaths->takeItem( currentRow );
delete itemToRemove;
}


void QgsOptions::on_mBtnAddSVGPath_clicked()
{
QString myDir = QFileDialog::getExistingDirectory(
@@ -90,6 +90,18 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
/**Remove an URL to exclude from Proxy*/
void on_mRemoveUrlPushButton_clicked();

/* Let the user add a path to the list of search paths
* used for finding user Plugin libs.
* @note added in QGIS 1.7
*/
void on_mBtnAddPluginPath_clicked();

/* Let the user remove a path to the list of search paths
* used for finding Plugin libs.
* @note added in QGIS 1.7
*/
void on_mBtnRemovePluginPath_clicked();

/* Let the user add a path to the list of search paths
* used for finding SVG files.
* @note added in QGIS 1.4
@@ -356,9 +356,17 @@ void QgsPluginRegistry::loadCppPlugin( QString theFullPathName )
QgsDebugMsg( "Plugin " + theFullPathName + " did not return a valid type and cannot be loaded" );
break;
}

}

//overloaded version of the next method that will load from multiple directories not just one
void QgsPluginRegistry::restoreSessionPlugins( QStringList thePluginDirList )
{
QStringListIterator myIterator( thePluginDirList );
while ( myIterator.hasNext() )
{
restoreSessionPlugins( myIterator.next() );
}
}

void QgsPluginRegistry::restoreSessionPlugins( QString thePluginDirString )
{
@@ -30,7 +30,7 @@ class QString;

/**
* \class QgsPluginRegistry
* \brief This class tracks plugins that are currently loaded an provides
* \brief This class tracks plugins that are currently loaded and provides
* a means to fetch a pointer to a plugin and unload it
*
* plugin key is:
@@ -78,6 +78,8 @@ class QgsPluginRegistry
//! Python plugin loader
void loadPythonPlugin( QString packageName );

//! Overloaded version of the next method that will load from multiple directories not just one
void restoreSessionPlugins( QStringList thePluginDirList );
//! Load any plugins used in the last qgis session
void restoreSessionPlugins( QString thePluginDirString );

0 comments on commit 76a09b2

Please sign in to comment.
You can’t perform that action at this time.