Skip to content

Commit

Permalink
Merge pull request #5372 from borysiasty/plugman
Browse files Browse the repository at this point in the history
[needs-docs] Move the install-plugin-from-ZIP menu action to the plug…
  • Loading branch information
borysiasty authored Oct 17, 2017
2 parents ba9e043 + ec57d25 commit db97e27
Show file tree
Hide file tree
Showing 10 changed files with 285 additions and 48 deletions.
3 changes: 2 additions & 1 deletion images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@
<file>themes/default/mActionShowHideLabels.svg</file>
<file>themes/default/mActionShowPinnedLabels.svg</file>
<file>themes/default/mActionShowPluginManager.svg</file>
<file>themes/default/mActionInstallPluginFromZip.svg</file>
<file>themes/default/mActionShowRasterCalculator.png</file>
<file>themes/default/mActionShowSelectedLayers.svg</file>
<file>themes/default/mActionSimplify.svg</file>
Expand Down Expand Up @@ -445,6 +444,7 @@
<file>themes/default/propertyicons/plugin-installed.svg</file>
<file>themes/default/propertyicons/plugin-new.svg</file>
<file>themes/default/propertyicons/plugin-upgrade.svg</file>
<file>themes/default/propertyicons/plugin-install_from_zip.svg</file>
<file>themes/default/propertyicons/plugins.svg</file>
<file>themes/default/propertyicons/pyramids.png</file>
<file>themes/default/propertyicons/rendering.svg</file>
Expand All @@ -454,6 +454,7 @@
<file>themes/default/propertyicons/symbology.svg</file>
<file>themes/default/propertyicons/system.svg</file>
<file>themes/default/propertyicons/transparency.png</file>
<file>themes/default/propertyicons/spacer.svg</file>
<file>themes/default/rendererCategorizedSymbol.svg</file>
<file>themes/default/rendererGraduatedSymbol.svg</file>
<file>themes/default/rendererNullSymbol.svg</file>
Expand Down
2 changes: 2 additions & 0 deletions images/themes/default/propertyicons/spacer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 5 additions & 10 deletions python/pyplugin_installer/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,17 +528,12 @@ def sendVote(self, plugin_id, vote):
QgsNetworkAccessManager.instance().post(req, params)
return True

def installFromZipFile(self):
settings = QgsSettings()
lastDirectory = settings.value('/Qgis/plugin-installer/lastZipDirectory', '.')
filePath, _ = QFileDialog.getOpenFileName(iface.mainWindow(),
self.tr('Open file'),
lastDirectory,
self.tr('Plugin packages (*.zip *.ZIP)'))
if filePath == '':
def installFromZipFile(self, filePath):
if not os.path.isfile(filePath):
return

settings.setValue('/Qgis/plugin-installer/lastZipDirectory',
settings = QgsSettings()
settings.setValue(settingsGroup + '/lastZipDirectory',
QFileInfo(filePath).absoluteDir().absolutePath())

error = False
Expand Down Expand Up @@ -591,4 +586,4 @@ def installFromZipFile(self):
if infoString[0]:
level = error and QgsMessageBar.CRITICAL or QgsMessageBar.INFO
msg = "<b>%s:</b>%s" % (infoString[0], infoString[1])
iface.messageBar().pushMessage(msg, level)
iface.pluginManagerInterface().pushMessage(msg, level)
33 changes: 30 additions & 3 deletions src/app/pluginmanager/qgspluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ QgsPluginManager::QgsPluginManager( QWidget *parent, bool pluginsAreEnabled, Qt:
buttonInstall->hide();
buttonUninstall->hide();
frameSettings->setHidden( true );
mOptionsListWidget->item( PLUGMAN_TAB_INSTALL_FROM_ZIP )->setHidden( true );

voteRating->hide();
voteLabel->hide();
Expand Down Expand Up @@ -167,6 +168,7 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils *pythonUtils )

// Now enable Python support:
// Show and preset widgets only suitable when Python support active
mOptionsListWidget->item( PLUGMAN_TAB_INSTALL_FROM_ZIP )->setHidden( false );
buttonUpgradeAll->show();
buttonInstall->show();
buttonUninstall->show();
Expand Down Expand Up @@ -204,12 +206,18 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils *pythonUtils )
// get the QgsSettings group from the installer
QString settingsGroup;
QgsPythonRunner::eval( QStringLiteral( "pyplugin_installer.instance().exportSettingsGroup()" ), settingsGroup );
QgsSettings settings;

// Initialize the "Install from ZIP" tab widgets
mZipFileWidget->setDefaultRoot( settings.value( settingsGroup + "/lastZipDirectory", "." ).toString() );
mZipFileWidget->setFilter( tr( "Plugin packages (*.zip *.ZIP)" ) );
connect( mZipFileWidget, &QgsFileWidget::fileChanged, this, &QgsPluginManager::mZipFileWidget_fileChanged );
connect( buttonInstallFromZip, &QPushButton::clicked, this, &QgsPluginManager::buttonInstallFromZip_clicked );

// Initialize list of allowed checking intervals
mCheckingOnStartIntervals << 0 << 1 << 3 << 7 << 14 << 30;

// Initialize the "Settings" tab widgets
QgsSettings settings;
if ( settings.value( settingsGroup + "/checkOnStart", false ).toBool() )
{
ckbCheckUpdates->setChecked( true );
Expand All @@ -225,7 +233,6 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils *pythonUtils )
ckbDeprecated->setChecked( true );
}


int interval = settings.value( settingsGroup + "/checkOnStartInterval", "" ).toInt();
int indx = mCheckingOnStartIntervals.indexOf( interval ); // if none found, just use -1 index.
comboInterval->setCurrentIndex( indx );
Expand Down Expand Up @@ -1101,9 +1108,14 @@ void QgsPluginManager::reject()

void QgsPluginManager::setCurrentTab( int idx )
{
if ( idx == ( mOptionsListWidget->count() - 1 ) )
if ( idx == PLUGMAN_TAB_SETTINGS )
{
QgsDebugMsg( "Switching current tab to Settings" );
mOptionsStackedWidget->setCurrentIndex( 2 );
}
else if ( idx == PLUGMAN_TAB_INSTALL_FROM_ZIP )
{
QgsDebugMsg( "Switching current tab to Install from ZIP" );
mOptionsStackedWidget->setCurrentIndex( 1 );
}
else
Expand Down Expand Up @@ -1313,6 +1325,21 @@ void QgsPluginManager::buttonUninstall_clicked()



void QgsPluginManager::mZipFileWidget_fileChanged( const QString &filePath )
{
buttonInstallFromZip->setEnabled( QFileInfo( filePath ).isFile() );
}



void QgsPluginManager::buttonInstallFromZip_clicked()
{
QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().installFromZipFile('%1')" ).arg( mZipFileWidget->filePath() ) );
mZipFileWidget->setFilePath( "" );
}



void QgsPluginManager::treeRepositories_itemSelectionChanged()
{
buttonEditRep->setEnabled( ! treeRepositories->selectedItems().isEmpty() );
Expand Down
14 changes: 14 additions & 0 deletions src/app/pluginmanager/qgspluginmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const int PLUGMAN_TAB_NOT_INSTALLED = 2;
const int PLUGMAN_TAB_UPGRADEABLE = 3;
const int PLUGMAN_TAB_NEW = 4;
const int PLUGMAN_TAB_INVALID = 5;
const int PLUGMAN_TAB_INSTALL_FROM_ZIP = 7;
const int PLUGMAN_TAB_SETTINGS = 8;

/**
* \brief Plugin manager for browsing, (un)installing and (un)loading plugins
Expand Down Expand Up @@ -130,6 +132,18 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag
//! Uninstall selected plugin
void buttonUninstall_clicked();

/**
* Enable the Install button if selected path is valid
* \since QGIS 3.0
*/
void mZipFileWidget_fileChanged( const QString &filePath );

/**
* Install plugin from ZIP file
* \since QGIS 3.0
*/
void buttonInstallFromZip_clicked();

//! Enable/disable buttons according to selected repository
void treeRepositories_itemSelectionChanged();

Expand Down
16 changes: 1 addition & 15 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,15 +1036,13 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mPluginManager->setPythonUtils( mPythonUtils );
endProfile();
}
else if ( mActionShowPythonDialog || mActionInstallFromZip )
else if ( mActionShowPythonDialog )
#endif
{
// python is disabled so get rid of the action for python console
// and installing plugin from ZUIP
delete mActionShowPythonDialog;
delete mActionInstallFromZip;
mActionShowPythonDialog = nullptr;
mActionInstallFromZip = nullptr;
}

// Set icon size of toolbars
Expand Down Expand Up @@ -1878,7 +1876,6 @@ void QgisApp::createActions()
// Plugin Menu Items

connect( mActionManagePlugins, &QAction::triggered, this, &QgisApp::showPluginManager );
connect( mActionInstallFromZip, &QAction::triggered, this, &QgisApp::installPluginFromZip );
connect( mActionShowPythonDialog, &QAction::triggered, this, &QgisApp::showPythonDialog );

// Settings Menu Items
Expand Down Expand Up @@ -2833,7 +2830,6 @@ void QgisApp::setTheme( const QString &themeName )
mActionToggleFullScreen->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionToggleFullScreen.png" ) ) );
mActionProjectProperties->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionProjectProperties.png" ) ) );
mActionManagePlugins->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowPluginManager.svg" ) ) );
mActionInstallFromZip->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionInstallPluginFromZip.svg" ) ) );
mActionShowPythonDialog->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "console/iconRunConsole.png" ) ) );
mActionCheckQgisVersion->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconSuccess.svg" ) ) );
mActionOptions->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionOptions.svg" ) ) );
Expand Down Expand Up @@ -9227,16 +9223,6 @@ void QgisApp::showPluginManager()
}
}

void QgisApp::installPluginFromZip()
{
#ifdef WITH_BINDINGS
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().installFromZipFile()" ) );
}
#endif
}


// implementation of the python runner
class QgsPythonRunnerImpl : public QgsPythonRunner
Expand Down
5 changes: 0 additions & 5 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1045,11 +1045,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! load Python support if possible
void loadPythonSupport();

/**
* Install plugin from ZIP file
* \since QGIS 3.0
*/
void installPluginFromZip();
//! Find the QMenu with the given name within plugin menu (ie the user visible text on the menu item)
QMenu *getPluginMenu( const QString &menuName );
//! Add the action to the submenu with the given name under the plugin menu
Expand Down
10 changes: 0 additions & 10 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@
<string>&amp;Plugins</string>
</property>
<addaction name="mActionManagePlugins"/>
<addaction name="mActionInstallFromZip"/>
<addaction name="separator"/>
<addaction name="mActionShowPythonDialog"/>
</widget>
Expand Down Expand Up @@ -2611,15 +2610,6 @@ Acts on currently active editable layer</string>
<string>Copy and Move Feature(s)</string>
</property>
</action>
<action name="mActionInstallFromZip">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionInstallPluginFromZip.svg</normaloff>:/images/themes/default/mActionInstallPluginFromZip.svg</iconset>
</property>
<property name="text">
<string>Install plugin from ZIP...</string>
</property>
</action>
<action name="mActionDecorationLayoutExtent">
<property name="icon">
<iconset resource="../../images/images.qrc">
Expand Down
Loading

0 comments on commit db97e27

Please sign in to comment.