Rename variables in PluginsPage

This commit is contained in:
Mm2PL 2023-02-14 12:16:25 +01:00
parent 805e8578ba
commit f5731bb9c5

View file

@ -70,23 +70,23 @@ void PluginsPage::rebuildContent()
auto layout = frame.setLayoutType<QVBoxLayout>(); auto layout = frame.setLayoutType<QVBoxLayout>();
for (const auto &[id, plugin] : getApp()->plugins->plugins()) for (const auto &[id, plugin] : getApp()->plugins->plugins())
{ {
QString headerText; QString groupHeaderText;
if (plugin->isDupeName) if (plugin->isDupeName)
{ {
headerText = QString("%1 (%2, from %3)") groupHeaderText = QString("%1 (%2, from %3)")
.arg(plugin->meta.name, .arg(plugin->meta.name,
QString::fromStdString( QString::fromStdString(
plugin->meta.version.to_string()), plugin->meta.version.to_string()),
id); id);
} }
else else
{ {
headerText = QString("%1 (%2)").arg( groupHeaderText = QString("%1 (%2)").arg(
plugin->meta.name, plugin->meta.name,
QString::fromStdString(plugin->meta.version.to_string())); QString::fromStdString(plugin->meta.version.to_string()));
} }
auto plgroup = layout.emplace<QGroupBox>(headerText); auto pluginEntry = layout.emplace<QGroupBox>(groupHeaderText)
auto pl = plgroup.setLayoutType<QFormLayout>(); .setLayoutType<QFormLayout>();
if (!plugin->meta.isValid()) if (!plugin->meta.isValid())
{ {
@ -103,13 +103,13 @@ void PluginsPage::rebuildContent()
warningLabel->setTextFormat(Qt::RichText); warningLabel->setTextFormat(Qt::RichText);
warningLabel->setParent(this->dataFrame_); warningLabel->setParent(this->dataFrame_);
warningLabel->setStyleSheet("color: #f00"); warningLabel->setStyleSheet("color: #f00");
pl->addRow(warningLabel); pluginEntry->addRow(warningLabel);
} }
auto *descrText = new QLabel(plugin->meta.description); auto *description = new QLabel(plugin->meta.description);
descrText->setWordWrap(true); description->setWordWrap(true);
descrText->setStyleSheet("color: #bbb"); description->setStyleSheet("color: #bbb");
pl->addRow(descrText); pluginEntry->addRow(description);
QString authorsTxt; QString authorsTxt;
for (const auto &author : plugin->meta.authors) for (const auto &author : plugin->meta.authors)
@ -121,39 +121,39 @@ void PluginsPage::rebuildContent()
authorsTxt += author; authorsTxt += author;
} }
pl->addRow("Authors", new QLabel(authorsTxt)); pluginEntry->addRow("Authors", new QLabel(authorsTxt));
if (!plugin->meta.homepage.isEmpty()) if (!plugin->meta.homepage.isEmpty())
{ {
auto *homepage = new QLabel(formatRichLink(plugin->meta.homepage)); auto *homepage = new QLabel(formatRichLink(plugin->meta.homepage));
homepage->setOpenExternalLinks(true); homepage->setOpenExternalLinks(true);
pl->addRow("Homepage", homepage); pluginEntry->addRow("Homepage", homepage);
} }
pl->addRow("License", new QLabel(plugin->meta.license)); pluginEntry->addRow("License", new QLabel(plugin->meta.license));
QString cmds; QString commandsTxt;
for (const auto &cmdName : plugin->listRegisteredCommands()) for (const auto &cmdName : plugin->listRegisteredCommands())
{ {
if (!cmds.isEmpty()) if (!commandsTxt.isEmpty())
{ {
cmds += ", "; commandsTxt += ", ";
} }
cmds += cmdName; commandsTxt += cmdName;
} }
pl->addRow("Commands", new QLabel(cmds)); pluginEntry->addRow("Commands", new QLabel(commandsTxt));
if (plugin->meta.isValid()) if (plugin->meta.isValid())
{ {
QString enableOrDisableStr = "Enable"; QString toggleTxt = "Enable";
if (PluginController::isEnabled(id)) if (PluginController::isEnabled(id))
{ {
enableOrDisableStr = "Disable"; toggleTxt = "Disable";
} }
auto *enableDisable = new QPushButton(enableOrDisableStr); auto *toggleButton = new QPushButton(toggleTxt);
QObject::connect( QObject::connect(
enableDisable, &QPushButton::pressed, [name = id, this]() { toggleButton, &QPushButton::pressed, [name = id, this]() {
std::vector<QString> val = std::vector<QString> val =
getSettings()->enabledPlugins.getValue(); getSettings()->enabledPlugins.getValue();
if (PluginController::isEnabled(name)) if (PluginController::isEnabled(name))
@ -169,15 +169,16 @@ void PluginsPage::rebuildContent()
getApp()->plugins->reload(name); getApp()->plugins->reload(name);
this->rebuildContent(); this->rebuildContent();
}); });
pl->addRow(enableDisable); pluginEntry->addRow(toggleButton);
} }
auto *reload = new QPushButton("Reload"); auto *reloadButton = new QPushButton("Reload");
QObject::connect(reload, &QPushButton::pressed, [name = id, this]() { QObject::connect(reloadButton, &QPushButton::pressed,
getApp()->plugins->reload(name); [name = id, this]() {
this->rebuildContent(); getApp()->plugins->reload(name);
}); this->rebuildContent();
pl->addRow(reload); });
pluginEntry->addRow(reloadButton);
} }
} }