Skip to content

Commit

Permalink
Making sure to notify when plugins have dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
francescmm committed Jun 25, 2022
1 parent f468e27 commit 6833616
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/aux_widgets/PluginsDownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/aux_widgets/PluginsDownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct PluginInfo
QString name;
QString version;
QString url;
QStringList dependencies;
};

class PluginsDownloader : public QObject
Expand Down
13 changes: 11 additions & 2 deletions src/big_widgets/ConfigWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,17 @@ void ConfigWidget::onPluginsInfoReceived(const QVector<PluginInfo> &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:<br><br>%1")
.arg(dependencies.join("<br>")));
}

mPluginsDownloader->downloadPlugin(url);
});
mDownloadButtons->addButton(pbDownload);

pbDownload->setDisabled(mPluginNames.contains(plugin.name) || ui->lePluginsDestination->text().isEmpty());
Expand Down

0 comments on commit 6833616

Please sign in to comment.