mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Plugin manager: Use QgsFileWidget for installing from zip files
This commit is contained in:
parent
91593257ff
commit
c33dbd96fe
@ -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)
|
||||
|
@ -74,7 +74,6 @@ QgsPluginManager::QgsPluginManager( QWidget *parent, bool pluginsAreEnabled, Qt:
|
||||
connect( buttonUpgradeAll, &QPushButton::clicked, this, &QgsPluginManager::buttonUpgradeAll_clicked );
|
||||
connect( buttonInstall, &QPushButton::clicked, this, &QgsPluginManager::buttonInstall_clicked );
|
||||
connect( buttonUninstall, &QPushButton::clicked, this, &QgsPluginManager::buttonUninstall_clicked );
|
||||
connect( buttonInstallFromZip, &QPushButton::clicked, this, &QgsPluginManager::buttonInstallFromZip_clicked );
|
||||
connect( treeRepositories, &QTreeWidget::itemSelectionChanged, this, &QgsPluginManager::treeRepositories_itemSelectionChanged );
|
||||
connect( treeRepositories, &QTreeWidget::doubleClicked, this, &QgsPluginManager::treeRepositories_doubleClicked );
|
||||
connect( buttonAddRep, &QPushButton::clicked, this, &QgsPluginManager::buttonAddRep_clicked );
|
||||
@ -207,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 );
|
||||
@ -228,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 );
|
||||
@ -1321,9 +1325,17 @@ 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()" ) );
|
||||
QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().installFromZipFile('%1')" ).arg( mZipFileWidget->filePath() ) );
|
||||
mZipFileWidget->setFilePath( "" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,6 +132,12 @@ 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
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>796</width>
|
||||
<height>551</height>
|
||||
<width>791</width>
|
||||
<height>471</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@ -559,7 +559,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>If you are provided with a zip package containing a plugin to install, please use the button below to choose the file and install the plugin.</p><p>Please note for most users this function is not applicable, as the preferable way is to install plugins from a repository.</p></body></html></string>
|
||||
<string><html><head/><body><p>If you are provided with a zip package containing a plugin to install, please select the file below and click the <span style=" font-style:italic;">Install plugin</span> button.</p><p>Please note for most users this function is not applicable, as the preferable way is to install plugins from a repository.</p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
@ -580,10 +580,13 @@
|
||||
<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>79</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
@ -595,18 +598,31 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonInstallFromZip">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Install plugin from a ZIP file</string>
|
||||
<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>
|
||||
@ -615,9 +631,86 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<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>
|
||||
@ -638,22 +731,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</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>160</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageSettings">
|
||||
@ -1115,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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user