Skip to content

Commit

Permalink
added button in plugin manager for opening plugin installer (if prese…
Browse files Browse the repository at this point in the history
…nt).

git-svn-id: http://svn.osgeo.org/qgis/trunk@10431 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Mar 27, 2009
1 parent 60b6bd6 commit 58605dc
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
50 changes: 50 additions & 0 deletions src/app/qgspluginmanager.cpp
Expand Up @@ -93,6 +93,16 @@ QgsPluginManager::QgsPluginManager( QgsPythonUtils* pythonUtils, QWidget * paren
connect( btnClearAll, SIGNAL( clicked() ), this, SLOT( clearAll() ) );

qRegisterMetaType<QgsDetailedItemData>();

// check for plugin installer
if (checkForPluginInstaller())
{
connect( btnPluginInstaller, SIGNAL( clicked() ), this, SLOT( showPluginInstaller() ));
}
else
{
btnPluginInstaller->setEnabled(false);
}
}


Expand Down Expand Up @@ -500,3 +510,43 @@ void QgsPluginManager::on_leFilter_textChanged( QString theText )
QRegExp myRegExp( theText, myCaseSensitivity, mySyntax );
mModelProxy->setFilterRegExp( myRegExp );
}

bool QgsPluginManager::checkForPluginInstaller()
{
// check whether python's enabled
if (!mPythonUtils)
return false;

// check whether python installer is present
if (!mPythonUtils->pluginList().contains("plugin_installer"))
return false;

QString res;
// check it's loaded and started
bool retval = mPythonUtils->evalString("plugins.has_key('plugin_installer')", res);
if (!retval || res != "True")
{
// TODO: try to load the plugin installer!
return false;
}

return true;
}

void QgsPluginManager::showPluginInstaller()
{
bool res;
QString cls, msg;
res = mPythonUtils->runStringUnsafe("_qgis_plugin_manager = wrapinstance( " + QString::number((unsigned long)this) + ", QtGui.QWidget )");
if (!res)
{
QgsDebugMsg("wrapinstance error: " + cls + " :: " + msg);
}
res = mPythonUtils->runStringUnsafe("plugins['plugin_installer'].run( _qgis_plugin_manager )");
if (!res)
{
mPythonUtils->getError(cls, msg);
QMessageBox::warning(this, tr("Error"), tr("Failed to open plugin installer!"));
mPythonUtils->runStringUnsafe("del _qgis_plugin_manager");
}
}
4 changes: 4 additions & 0 deletions src/app/qgspluginmanager.h
Expand Up @@ -56,6 +56,8 @@ class QgsPluginManager : public QDialog, private Ui::QgsPluginManagerBase
void resizeColumnsToContents();
//! Sort model by column ascending
void sortModel( int );
//! Check whether plugin installer is available (and tries to load it if it's disabled)
bool checkForPluginInstaller();
public slots:
//! Enable disable checkbox
void on_vwPlugins_clicked( const QModelIndex & );
Expand All @@ -67,6 +69,8 @@ class QgsPluginManager : public QDialog, private Ui::QgsPluginManagerBase
void clearAll();
//! Update the filter when user changes the filter expression
void on_leFilter_textChanged( QString theText );
//! Show the plugin installer
void showPluginInstaller();
private:
QStandardItemModel *mModelPlugins;
QSortFilterProxyModel * mModelProxy;
Expand Down
10 changes: 9 additions & 1 deletion src/ui/qgspluginmanagerbase.ui
Expand Up @@ -78,7 +78,14 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="3" >
<item row="4" column="0" colspan="2" >
<widget class="QPushButton" name="btnPluginInstaller" >
<property name="text" >
<string>Plugin Installer</string>
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
Expand All @@ -91,6 +98,7 @@
<tabstops>
<tabstop>vwPlugins</tabstop>
<tabstop>leFilter</tabstop>
<tabstop>btnPluginInstaller</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
Expand Down

0 comments on commit 58605dc

Please sign in to comment.