[QGIS Commit] r10431 - in trunk/qgis/src: app ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Mar 27 15:16:39 EDT 2009


Author: wonder
Date: 2009-03-27 15:16:39 -0400 (Fri, 27 Mar 2009)
New Revision: 10431

Modified:
   trunk/qgis/src/app/qgspluginmanager.cpp
   trunk/qgis/src/app/qgspluginmanager.h
   trunk/qgis/src/ui/qgspluginmanagerbase.ui
Log:
added button in plugin manager for opening plugin installer (if present).


Modified: trunk/qgis/src/app/qgspluginmanager.cpp
===================================================================
--- trunk/qgis/src/app/qgspluginmanager.cpp	2009-03-27 19:12:40 UTC (rev 10430)
+++ trunk/qgis/src/app/qgspluginmanager.cpp	2009-03-27 19:16:39 UTC (rev 10431)
@@ -93,6 +93,16 @@
   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 @@
   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");
+  }
+}

Modified: trunk/qgis/src/app/qgspluginmanager.h
===================================================================
--- trunk/qgis/src/app/qgspluginmanager.h	2009-03-27 19:12:40 UTC (rev 10430)
+++ trunk/qgis/src/app/qgspluginmanager.h	2009-03-27 19:16:39 UTC (rev 10431)
@@ -56,6 +56,8 @@
     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 @@
     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;

Modified: trunk/qgis/src/ui/qgspluginmanagerbase.ui
===================================================================
--- trunk/qgis/src/ui/qgspluginmanagerbase.ui	2009-03-27 19:12:40 UTC (rev 10430)
+++ trunk/qgis/src/ui/qgspluginmanagerbase.ui	2009-03-27 19:16:39 UTC (rev 10431)
@@ -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/>



More information about the QGIS-commit mailing list