# HG changeset patch # User Chris Cannam # Date 1582895735 0 # Node ID de8552bfeadf01e20426f0bdf4b4d221d2cc9362 # Parent fb4ca43863b567a12c05ecab417ecf4721d128e9 Help page, licence URLs diff -r fb4ca43863b5 -r de8552bfeadf installer.cpp --- a/installer.cpp Fri Feb 28 11:34:19 2020 +0000 +++ b/installer.cpp Fri Feb 28 13:15:35 2020 +0000 @@ -149,6 +149,23 @@ QString licence; }; +struct Licence +{ + static QString gpl; + static QString gpl2; + static QString gpl3; + static QString agpl; + static QString apache; + static QString mit; +}; + +QString Licence::gpl = "GNU General Public License"; +QString Licence::gpl2 = "GNU General Public License, version 2"; +QString Licence::gpl3 = "GNU General Public License, version 3"; +QString Licence::agpl = "GNU Affero General Public License"; +QString Licence::apache = "Apache License"; +QString Licence::mit = "MIT License"; + QString identifyLicence(QString libraryBasename) { @@ -166,33 +183,28 @@ QString licenceText = QString::fromUtf8(content); - QString gpl = "GNU General Public License"; - QString agpl = "GNU Affero General Public License"; - QString apache = "Apache License"; - QString mit = "MIT License"; - // NB these are not expected to identify an arbitrary licence! We // know we have only a limited set here. But we do want to // determine this from the actual licence text included with the // plugin distribution, not just from e.g. RDF metadata - if (licenceText.contains(gpl.toUpper(), Qt::CaseSensitive)) { + if (licenceText.contains(Licence::gpl.toUpper(), Qt::CaseSensitive)) { if (licenceText.contains("Version 3, 29 June 2007")) { - return QString("%1, version 3").arg(gpl); + return Licence::gpl3; } else if (licenceText.contains("Version 2, June 1991")) { - return QString("%1, version 2").arg(gpl); + return Licence::gpl2; } else { - return gpl; + return Licence::gpl; } } - if (licenceText.contains(agpl.toUpper(), Qt::CaseSensitive)) { - return agpl; + if (licenceText.contains(Licence::agpl.toUpper(), Qt::CaseSensitive)) { + return Licence::agpl; } - if (licenceText.contains(apache)) { - return apache; + if (licenceText.contains(Licence::apache)) { + return Licence::apache; } if (licenceText.contains("Permission is hereby granted, free of charge, to any person")) { - return mit; + return Licence::mit; } SVCERR << "Didn't recognise licence for " << libraryBasename << endl; @@ -200,6 +212,25 @@ return {}; } +QString +getLicenceURL(QString licence) +{ + if (licence == Licence::gpl || + licence == Licence::gpl3) { + return "https://www.gnu.org/licenses/gpl-3.0.en.html"; + } else if (licence == Licence::gpl2) { + return "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"; + } else if (licence == Licence::agpl) { + return "https://www.gnu.org/licenses/agpl-3.0.html"; + } else if (licence == Licence::apache) { + return "https://www.apache.org/licenses/LICENSE-2.0"; + } else if (licence == Licence::mit) { + return "https://opensource.org/licenses/MIT"; + } + + return {}; +} + vector getLibraryInfo(const Store &store, QStringList libraries) { @@ -678,6 +709,35 @@ return {}; } +QString +getHelpText(vector libraries) +{ + set> + makers + ([](QString k1, QString k2) { + return k1.localeAwareCompare(k2) < 0; + }); + + for (auto info: libraries) { + makers.insert(info.maker); + } + + QString makerList; + for (QString maker: makers) { + makerList += QObject::tr("
  • %1
  • ").arg(maker); + } + + return QObject::tr + ("

    Vamp Plugin Pack collects together a number of Vamp audio analysis plugins into a single installer.

    " + "

    The libraries you select will be installed into the standard Vamp plugin directory, where hosts such as Sonic Visualiser can find them.

    " + "

    The plugin libraries included here were developed and published by various different authors and institutions:

      %1
    " + "

    All of the libraries are open source and are redistributable under open-source licences. Click the information icon to the right of each library in the main window for more details.

    " + "

    The entire pack may be redistributed under the GNU Affero General Public License v3.

    " + "

    The plugins were collected together, and the installer was written and published, at the Centre for Digital Music, Queen Mary University of London.

    ") + .arg(makerList) + .arg(getLicenceURL(Licence::agpl)); +} + vector getUserApprovedPluginLibraries(vector libraries, QString targetDir) @@ -834,7 +894,8 @@ } if (info.licence != "") { - moreInfoText += QObject::tr("Provided under the %1.
    ") + moreInfoText += QObject::tr("Provided under the %2.
    ") + .arg(getLicenceURL(info.licence)) .arg(info.licence); } @@ -874,7 +935,8 @@ auto bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | - QDialogButtonBox::Reset); + QDialogButtonBox::Reset | + QDialogButtonBox::Help); bb->button(QDialogButtonBox::Ok)->setText(QObject::tr("Install")); mainLayout->addWidget(bb, mainRow, 0); ++mainRow; @@ -929,8 +991,18 @@ } break; + case QDialogButtonBox::HelpRole: { + QMessageBox mbox; + mbox.setWindowTitle(QApplication::applicationName()); + mbox.setText(QObject::tr("Vamp Plugin Pack")); + mbox.setInformativeText(getHelpText(libraries)); + mbox.exec(); + break; + } + default: SVCERR << "WARNING: Unexpected role " << role << endl; + break; } }); @@ -1010,17 +1082,24 @@ vector toInstall = getUserApprovedPluginLibraries(info, target); - - if (toInstall.empty()) { // Cancelled, or nothing selected - SVCERR << "No libraries selected for installation, nothing to do" - << endl; - return 0; - } QProgressDialog progress(QObject::tr("Installing..."), QObject::tr("Stop"), 0, int(toInstall.size()) + 1); progress.setMinimumDuration(0); + + if (toInstall.empty()) { // Cancelled, or nothing selected + SVCERR << "No libraries selected for installation, nothing to do" + << endl; + progress.hide(); + QMessageBox::information + (&progress, + QObject::tr("Nothing to do"), + QObject::tr("No libraries selected for installation"), + QMessageBox::Ok, + QMessageBox::Ok); + return 0; + } int pval = 0; bool complete = true;