MCPcopy Create free account
hub / github.com/IChooseYou/Reclass / showPluginsDialog

Method showPluginsDialog

src/main.cpp:1470–1568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1468}
1469
1470void MainWindow::showPluginsDialog() {
1471 QDialog dialog(this);
1472 dialog.setWindowTitle("Plugins");
1473 dialog.resize(600, 400);
1474
1475 auto* layout = new QVBoxLayout(&dialog);
1476
1477 auto* list = new QListWidget();
1478 layout->addWidget(list);
1479
1480 auto refreshList = [&]() {
1481 list->clear();
1482
1483 // Populate plugin list
1484 for (IPlugin* plugin : m_pluginManager.plugins()) {
1485 QString typeStr;
1486 switch (plugin->Type())
1487 {
1488 case IPlugin::ProviderPlugin: typeStr = "Provider"; break;
1489 default: typeStr = "Unknown"; break;
1490 }
1491
1492 QString text = QString("%1 v%2\n %3\n Type: %4\n Author: %5")
1493 .arg(QString::fromStdString(plugin->Name()))
1494 .arg(QString::fromStdString(plugin->Version()))
1495 .arg(QString::fromStdString(plugin->Description()))
1496 .arg(typeStr)
1497 .arg(QString::fromStdString(plugin->Author()));
1498
1499 auto* item = new QListWidgetItem(plugin->Icon(), text);
1500 item->setData(Qt::UserRole, QString::fromStdString(plugin->Name()));
1501 list->addItem(item);
1502 }
1503
1504 if (m_pluginManager.plugins().isEmpty()) {
1505 list->addItem("No plugins loaded");
1506 }
1507 };
1508
1509 refreshList();
1510
1511 // Button row
1512 auto* btnLayout = new QHBoxLayout();
1513
1514 auto* btnLoad = new QPushButton("Load Plugin...");
1515 connect(btnLoad, &QPushButton::clicked, [&, refreshList]() {
1516 QString path = QFileDialog::getOpenFileName(&dialog, "Load Plugin",
1517 QCoreApplication::applicationDirPath() + "/Plugins",
1518 "Plugins (*.dll *.so *.dylib);;All Files (*)");
1519
1520 if (!path.isEmpty()) {
1521 if (m_pluginManager.LoadPluginFromPath(path)) {
1522 refreshList();
1523 m_statusLabel->setText("Plugin loaded successfully");
1524 } else {
1525 QMessageBox::warning(&dialog, "Failed to Load Plugin",
1526 "Could not load the selected plugin.\nCheck the console for details.");
1527 }

Callers

nothing calls this directly

Calls 9

clearMethod · 0.80
TypeMethod · 0.80
LoadPluginFromPathMethod · 0.80
UnloadPluginMethod · 0.80
NameMethod · 0.45
VersionMethod · 0.45
DescriptionMethod · 0.45
AuthorMethod · 0.45
IconMethod · 0.45

Tested by

no test coverage detected