Skip to content

Commit 4e854d2

Browse files
committedMay 12, 2020
[plugin manager] fix #36217
where install experimental button/message appearing when they shouldn't
1 parent 27b5dae commit 4e854d2

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed
 

‎src/app/pluginmanager/qgspluginmanager.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,17 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils *pythonUtils )
178178
{
179179
mPythonUtils = pythonUtils;
180180

181+
// get the QgsSettings group from the installer
182+
QString settingsGroup;
183+
QgsPythonRunner::eval( QStringLiteral( "pyplugin_installer.instance().exportSettingsGroup()" ), settingsGroup );
184+
QgsSettings settings;
185+
181186
// Now enable Python support:
182187
// Show and preset widgets only suitable when Python support active
183188
mOptionsListWidget->item( PLUGMAN_TAB_INSTALL_FROM_ZIP )->setHidden( false );
184189
buttonUpgradeAll->show();
185190
buttonInstall->show();
186-
buttonInstallExperimental->show();
191+
buttonInstallExperimental->setVisible( settings.value( settingsGroup + "/allowExperimental", false ).toBool() );
187192
buttonUninstall->show();
188193
frameSettings->setHidden( false );
189194
labelNoPython->setHidden( true );
@@ -227,11 +232,6 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils *pythonUtils )
227232
connect( actionSortByDateCreated, &QAction::triggered, mModelProxy, &QgsPluginSortFilterProxyModel::sortPluginsByDateCreated );
228233
connect( actionSortByDateUpdated, &QAction::triggered, mModelProxy, &QgsPluginSortFilterProxyModel::sortPluginsByDateUpdated );
229234

230-
// get the QgsSettings group from the installer
231-
QString settingsGroup;
232-
QgsPythonRunner::eval( QStringLiteral( "pyplugin_installer.instance().exportSettingsGroup()" ), settingsGroup );
233-
QgsSettings settings;
234-
235235
// Initialize the "Install from ZIP" tab widgets
236236
mZipFileWidget->setDefaultRoot( settings.value( settingsGroup + "/lastZipDirectory", "." ).toString() );
237237
mZipFileWidget->setFilter( tr( "Plugin packages (*.zip *.ZIP)" ) );
@@ -854,7 +854,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item )
854854
"</table>" ).arg( tr( "Installed version of this plugin is higher than any version found in repository" ) );
855855
}
856856

857-
if ( metadata->value( QStringLiteral( "experimental" ) ) == QLatin1String( "true" ) )
857+
if ( ! metadata->value( QStringLiteral( "version_available_experimental" ) ).isEmpty() )
858858
{
859859
html += QString( "<table bgcolor=\"#EEEEBB\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">"
860860
" <tr><td width=\"100%\" style=\"color:#660000\">"
@@ -1125,18 +1125,20 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item )
11251125
buttonInstallExperimental->setText( tr( "Reinstall Experimental Plugin" ) );
11261126
}
11271127

1128-
// DEBUG TODO REMOVE
1129-
// buttonInstall->setText( buttonInstall->text() + QStringLiteral(" | ") + metadata->value( QStringLiteral( "status" ) ) );
1130-
// buttonInstallExperimental->setText( buttonInstallExperimental->text() + QStringLiteral(" | ") + metadata->value( QStringLiteral( "status_exp" ) ) );
1131-
11321128
// Enable/disable buttons
11331129

1130+
QgsSettings settings;
1131+
QString settingsGroup;
1132+
QgsPythonRunner::eval( QStringLiteral( "pyplugin_installer.instance().exportSettingsGroup()" ), settingsGroup );
1133+
bool expAllowed = settings.value( settingsGroup + "/allowExperimental", false ).toBool();
1134+
11341135
bool installEnabled = metadata->value( QStringLiteral( "pythonic" ) ).toUpper() == QLatin1String( "TRUE" ) && metadata->value( QStringLiteral( "status" ) ) != QLatin1String( "orphan" ) && metadata->value( QStringLiteral( "status" ) ) != QLatin1String( "none available" );
11351136
bool installExpEnabled = metadata->value( QStringLiteral( "pythonic" ) ).toUpper() == QLatin1String( "TRUE" ) && metadata->value( QStringLiteral( "status_exp" ) ) != QLatin1String( "orphan" ) && metadata->value( QStringLiteral( "status_exp" ) ) != QLatin1String( "none available" );
1137+
11361138
buttonInstall->setEnabled( installEnabled );
11371139
buttonInstall->setVisible( installEnabled || !installExpEnabled );
1138-
buttonInstallExperimental->setEnabled( installExpEnabled );
1139-
buttonInstallExperimental->setVisible( installExpEnabled || !installEnabled );
1140+
buttonInstallExperimental->setEnabled( expAllowed && installExpEnabled );
1141+
buttonInstallExperimental->setVisible( expAllowed && installExpEnabled );
11401142

11411143
buttonUninstall->setEnabled( metadata->value( QStringLiteral( "pythonic" ) ).toUpper() == QLatin1String( "TRUE" ) && metadata->value( QStringLiteral( "readonly" ) ) != QLatin1String( "true" ) && ! metadata->value( QStringLiteral( "version_installed" ) ).isEmpty() );
11421144

0 commit comments

Comments
 (0)
Please sign in to comment.