cutter/src/dialogs/preferences/PluginsOptionsWidget.cpp

56 lines
1.8 KiB
C++
Raw Normal View History

2019-03-16 12:41:45 +00:00
#include "PluginsOptionsWidget.h"
#include "PreferencesDialog.h"
#include "common/Helpers.h"
#include "common/Configuration.h"
#include "plugins/PluginManager.h"
#include "dialogs/RizinPluginsDialog.h"
2019-03-16 12:41:45 +00:00
#include <QLabel>
#include <QPushButton>
#include <QTreeWidget>
#include <QVBoxLayout>
#include <QUrl>
2019-03-16 12:41:45 +00:00
2021-01-24 14:50:13 +00:00
PluginsOptionsWidget::PluginsOptionsWidget(PreferencesDialog *dialog) : QDialog(dialog)
2019-03-16 12:41:45 +00:00
{
auto layout = new QVBoxLayout(this);
setLayout(layout);
auto dirLabel = new QLabel(this);
dirLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
dirLabel->setOpenExternalLinks(true);
2019-03-16 12:41:45 +00:00
layout->addWidget(dirLabel);
auto pluginPath = Plugins()->getUserPluginsDirectory();
2021-01-24 14:50:13 +00:00
dirLabel->setText(
tr("Plugins are loaded from <a href=\"%1\">%2</a>")
.arg(QUrl::fromLocalFile(pluginPath).toString(), pluginPath.toHtmlEscaped()));
2019-03-16 12:41:45 +00:00
auto treeWidget = new QTreeWidget(this);
layout->addWidget(treeWidget);
treeWidget->setRootIsDecorated(false);
2021-01-24 14:50:13 +00:00
treeWidget->setHeaderLabels({ tr("Name"), tr("Description"), tr("Version"), tr("Author") });
2019-03-16 12:41:45 +00:00
for (auto &plugin : Plugins()->getPlugins()) {
2019-03-16 12:41:45 +00:00
auto item = new QTreeWidgetItem();
item->setText(0, plugin->getName());
item->setText(1, plugin->getDescription());
item->setText(2, plugin->getVersion());
item->setText(3, plugin->getAuthor());
treeWidget->addTopLevelItem(item);
}
qhelpers::adjustColumns(treeWidget, 0);
auto rzPluginsButton = new QPushButton(this);
layout->addWidget(rzPluginsButton);
rzPluginsButton->setText(tr("Show Rizin plugin information"));
connect(rzPluginsButton, &QPushButton::clicked, this, [this]() {
RizinPluginsDialog dialog(this);
2019-03-16 12:41:45 +00:00
dialog.exec();
});
}
PluginsOptionsWidget::~PluginsOptionsWidget() {}