Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #36368 from olivierdalang/fix_36217
[plugin manager] only show install/experimental button when needed
  • Loading branch information
m-kuhn committed May 14, 2020
2 parents 7cdfef9 + 4e854d2 commit d090236
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/app/pluginmanager/qgspluginmanager.cpp
Expand Up @@ -178,12 +178,17 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils *pythonUtils )
{
mPythonUtils = pythonUtils;

// get the QgsSettings group from the installer
QString settingsGroup;
QgsPythonRunner::eval( QStringLiteral( "pyplugin_installer.instance().exportSettingsGroup()" ), settingsGroup );
QgsSettings settings;

// 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();
buttonInstallExperimental->show();
buttonInstallExperimental->setVisible( settings.value( settingsGroup + "/allowExperimental", false ).toBool() );
buttonUninstall->show();
frameSettings->setHidden( false );
labelNoPython->setHidden( true );
Expand Down Expand Up @@ -227,11 +232,6 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils *pythonUtils )
connect( actionSortByDateCreated, &QAction::triggered, mModelProxy, &QgsPluginSortFilterProxyModel::sortPluginsByDateCreated );
connect( actionSortByDateUpdated, &QAction::triggered, mModelProxy, &QgsPluginSortFilterProxyModel::sortPluginsByDateUpdated );

// 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)" ) );
Expand Down Expand Up @@ -854,7 +854,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item )
"</table>" ).arg( tr( "Installed version of this plugin is higher than any version found in repository" ) );
}

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

// DEBUG TODO REMOVE
// buttonInstall->setText( buttonInstall->text() + QStringLiteral(" | ") + metadata->value( QStringLiteral( "status" ) ) );
// buttonInstallExperimental->setText( buttonInstallExperimental->text() + QStringLiteral(" | ") + metadata->value( QStringLiteral( "status_exp" ) ) );

// Enable/disable buttons

QgsSettings settings;
QString settingsGroup;
QgsPythonRunner::eval( QStringLiteral( "pyplugin_installer.instance().exportSettingsGroup()" ), settingsGroup );
bool expAllowed = settings.value( settingsGroup + "/allowExperimental", false ).toBool();

bool installEnabled = metadata->value( QStringLiteral( "pythonic" ) ).toUpper() == QLatin1String( "TRUE" ) && metadata->value( QStringLiteral( "status" ) ) != QLatin1String( "orphan" ) && metadata->value( QStringLiteral( "status" ) ) != QLatin1String( "none available" );
bool installExpEnabled = metadata->value( QStringLiteral( "pythonic" ) ).toUpper() == QLatin1String( "TRUE" ) && metadata->value( QStringLiteral( "status_exp" ) ) != QLatin1String( "orphan" ) && metadata->value( QStringLiteral( "status_exp" ) ) != QLatin1String( "none available" );

buttonInstall->setEnabled( installEnabled );
buttonInstall->setVisible( installEnabled || !installExpEnabled );
buttonInstallExperimental->setEnabled( installExpEnabled );
buttonInstallExperimental->setVisible( installExpEnabled || !installEnabled );
buttonInstallExperimental->setEnabled( expAllowed && installExpEnabled );
buttonInstallExperimental->setVisible( expAllowed && installExpEnabled );

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

Expand Down

0 comments on commit d090236

Please sign in to comment.