Merge pull request #5372 from borysiasty/plugman

[needs-docs] Move the install-plugin-from-ZIP menu action to the plug…
This commit is contained in:
Borys Jurgiel 2017-10-17 09:26:22 +02:00 committed by GitHub
commit db97e2772f
10 changed files with 285 additions and 48 deletions

View File

@ -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>
@ -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>
@ -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>

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,2 @@
<svg height="12" width="24" xmlns="http://www.w3.org/2000/svg">
</svg>

After

Width:  |  Height:  |  Size: 71 B

View File

@ -528,17 +528,12 @@ class QgsPluginInstaller(QObject):
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
@ -591,4 +586,4 @@ class QgsPluginInstaller(QObject):
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)

View File

@ -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();
@ -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();
@ -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 );
@ -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 );
@ -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
@ -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() );

View File

@ -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
@ -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();

View File

@ -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
@ -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
@ -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" ) ) );
@ -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

View File

@ -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

View File

@ -193,7 +193,6 @@
<string>&amp;Plugins</string>
</property>
<addaction name="mActionManagePlugins"/>
<addaction name="mActionInstallFromZip"/>
<addaction name="separator"/>
<addaction name="mActionShowPythonDialog"/>
</widget>
@ -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">

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>796</width>
<height>594</height>
<width>791</width>
<height>471</height>
</rect>
</property>
<property name="minimumSize">
@ -188,6 +188,27 @@
<set>ItemIsSelectable|ItemIsEnabled</set>
</property>
</item>
<item>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/propertyicons/spacer.svg</normaloff>:/images/themes/default/propertyicons/spacer.svg</iconset>
</property>
<property name="flags">
<set>NoItemFlags</set>
</property>
</item>
<item>
<property name="text">
<string>Install from ZIP</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/propertyicons/plugin-install_from_zip.svg</normaloff>:/images/themes/default/propertyicons/plugin-install_from_zip.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Settings</string>
@ -511,6 +532,207 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="pageInstallFromZip">
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelInstallFromZip">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If you are provided with a zip package containing a plugin to install, please select the file below and click the &lt;span style=&quot; font-style:italic;&quot;&gt;Install plugin&lt;/span&gt; button.&lt;/p&gt;&lt;p&gt;Please note for most users this function is not applicable, as the preferable way is to install plugins from a repository.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>20</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>ZIP file:</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFileWidget" name="mZipFileWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonInstallFromZip">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Install plugin</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>78</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageSettings">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
@ -581,8 +803,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>626</height>
<width>589</width>
<height>638</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
@ -970,6 +1192,11 @@ p, li { white-space: pre-wrap; }
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsFileWidget</class>
<extends>QWidget</extends>
<header>qgsfilewidget.h</header>
</customwidget>
<customwidget>
<class>QgsFilterLineEdit</class>
<extends>QLineEdit</extends>