Skip to content
Permalink
Browse files

added button in plugin manager for opening plugin installer (if prese…

…nt).

git-svn-id: http://svn.osgeo.org/qgis/trunk@10431 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Mar 27, 2009
1 parent 60b6bd6 commit 58605dc27f2c958da0f603e4ebfcc6f73516cf74
Showing with 63 additions and 1 deletion.
  1. +50 −0 src/app/qgspluginmanager.cpp
  2. +4 −0 src/app/qgspluginmanager.h
  3. +9 −1 src/ui/qgspluginmanagerbase.ui
@@ -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);
}
}


@@ -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");
}
}
@@ -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 & );
@@ -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;
@@ -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>
@@ -91,6 +98,7 @@
<tabstops>
<tabstop>vwPlugins</tabstop>
<tabstop>leFilter</tabstop>
<tabstop>btnPluginInstaller</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>

0 comments on commit 58605dc

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