From 6833616d37dce01ab26cc4d1463d8a685d00f4ba Mon Sep 17 00:00:00 2001 From: Francesc Martinez Date: Sat, 25 Jun 2022 10:38:34 +0200 Subject: [PATCH] Making sure to notify when plugins have dependencies --- src/aux_widgets/PluginsDownloader.cpp | 13 +++++++++++-- src/aux_widgets/PluginsDownloader.h | 1 + src/big_widgets/ConfigWidget.cpp | 13 +++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/aux_widgets/PluginsDownloader.cpp b/src/aux_widgets/PluginsDownloader.cpp index a7214c1a..3d525c7d 100644 --- a/src/aux_widgets/PluginsDownloader.cpp +++ b/src/aux_widgets/PluginsDownloader.cpp @@ -62,8 +62,17 @@ void PluginsDownloader::processPluginsFile() #endif if (const auto jsonUrl = QStringLiteral("%1-url").arg(platform); jsonObject.contains(jsonUrl)) { - pluginsInfo.append(PluginInfo { jsonObject["name"].toString(), jsonObject["version"].toString(), - jsonObject[jsonUrl].toString() }); + PluginInfo pluginInfo { + jsonObject["name"].toString(), jsonObject["version"].toString(), jsonObject[jsonUrl].toString(), {} + }; + + if (const auto dependencies = QStringLiteral("dependencies"); jsonObject.contains(dependencies)) + { + for (auto dependency : jsonObject[dependencies].toArray()) + pluginInfo.dependencies.append(std::move(dependency.toString())); + } + + pluginsInfo.append(std::move(pluginInfo)); } } diff --git a/src/aux_widgets/PluginsDownloader.h b/src/aux_widgets/PluginsDownloader.h index f99f9438..c11e6476 100644 --- a/src/aux_widgets/PluginsDownloader.h +++ b/src/aux_widgets/PluginsDownloader.h @@ -38,6 +38,7 @@ struct PluginInfo QString name; QString version; QString url; + QStringList dependencies; }; class PluginsDownloader : public QObject diff --git a/src/big_widgets/ConfigWidget.cpp b/src/big_widgets/ConfigWidget.cpp index fa64eb32..784fb14c 100644 --- a/src/big_widgets/ConfigWidget.cpp +++ b/src/big_widgets/ConfigWidget.cpp @@ -268,8 +268,17 @@ void ConfigWidget::onPluginsInfoReceived(const QVector &pluginsInfo) ui->availablePluginsLayout->addWidget(new QLabel(plugin.version), row, 1); const auto pbDownload = new QPushButton("Download"); - connect(pbDownload, &QPushButton::clicked, this, - [url = plugin.url, this]() { mPluginsDownloader->downloadPlugin(url); }); + connect(pbDownload, &QPushButton::clicked, this, [url = plugin.url, dependencies = plugin.dependencies, this]() { + if (!dependencies.empty()) + { + QMessageBox::information( + this, tr("Dependencies needed!"), + tr("This plugin needs some dependencies to work. Please make sure you have them instsalled:

%1") + .arg(dependencies.join("
"))); + } + + mPluginsDownloader->downloadPlugin(url); + }); mDownloadButtons->addButton(pbDownload); pbDownload->setDisabled(mPluginNames.contains(plugin.name) || ui->lePluginsDestination->text().isEmpty());