mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Make PluginMeta::authors a std::vector<QString>
This commit is contained in:
parent
6a183d3f33
commit
d1bcede492
3 changed files with 41 additions and 7 deletions
|
@ -14,8 +14,11 @@
|
|||
"description": "Plugin description shown to the user."
|
||||
},
|
||||
"authors": {
|
||||
"type": "string",
|
||||
"description": "A string describing authors of the Plugin. This could be a list of names, an organisation or something else, as long as it's clear who made the Plugin."
|
||||
"type": "array",
|
||||
"description": "An array of authors of this Plugin.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"homepage": {
|
||||
"type": "string",
|
||||
|
|
|
@ -22,7 +22,7 @@ struct PluginMeta {
|
|||
// required fields
|
||||
QString name;
|
||||
QString description;
|
||||
QString authors;
|
||||
std::vector<QString> authors;
|
||||
QString license;
|
||||
semver::version version;
|
||||
|
||||
|
@ -53,12 +53,31 @@ struct PluginMeta {
|
|||
this->description = descrObj.toString();
|
||||
|
||||
auto authorsObj = obj.value("authors");
|
||||
if (!authorsObj.isString())
|
||||
if (authorsObj.isArray())
|
||||
{
|
||||
this->invalidWhy.emplace_back("description is not a string");
|
||||
auto authorsArr = authorsObj.toArray();
|
||||
for (int i = 0; i < authorsArr.size(); i++)
|
||||
{
|
||||
const auto &t = authorsArr.at(i);
|
||||
if (!t.isString())
|
||||
{
|
||||
this->invalidWhy.push_back(
|
||||
QString(
|
||||
"authors element #%1 is not a string (it is a %2)")
|
||||
.arg(i)
|
||||
.arg(QString::fromStdString(
|
||||
std::string(magic_enum::enum_name(t.type())))));
|
||||
this->valid = false;
|
||||
return;
|
||||
}
|
||||
this->authors.push_back(t.toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->invalidWhy.emplace_back("authors is not an array");
|
||||
this->valid = false;
|
||||
}
|
||||
this->authors = authorsObj.toString();
|
||||
|
||||
auto licenseObj = obj.value("license");
|
||||
if (!licenseObj.isString())
|
||||
|
|
|
@ -91,7 +91,19 @@ void PluginsPage::rebuildContent()
|
|||
descrText->setWordWrap(true);
|
||||
descrText->setStyleSheet("color: #bbb");
|
||||
pl->addRow(descrText);
|
||||
pl->addRow("Authors", new QLabel(plugin->meta.authors));
|
||||
|
||||
QString authorsTxt;
|
||||
for (const auto &author : plugin->meta.authors)
|
||||
{
|
||||
if (!authorsTxt.isEmpty())
|
||||
{
|
||||
authorsTxt += ", ";
|
||||
}
|
||||
|
||||
authorsTxt += author;
|
||||
}
|
||||
pl->addRow("Authors", new QLabel(authorsTxt));
|
||||
|
||||
auto *homepage = new QLabel(formatRichLink(plugin->meta.homepage));
|
||||
homepage->setOpenExternalLinks(true);
|
||||
|
||||
|
|
Loading…
Reference in a new issue