Mercurial > hg > svgui
changeset 1292:41824255ddf2 plugin-path-config
Plugin review dialog
author | Chris Cannam |
---|---|
date | Fri, 25 May 2018 13:39:08 +0100 |
parents | b5c71304286e |
children | 6dd15b5c14f9 |
files | files.pri widgets/PluginPathConfigurator.cpp widgets/PluginPathConfigurator.h widgets/PluginReviewDialog.cpp widgets/PluginReviewDialog.h |
diffstat | 5 files changed, 219 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/files.pri Wed May 23 16:24:35 2018 +0100 +++ b/files.pri Fri May 25 13:39:08 2018 +0100 @@ -75,6 +75,7 @@ widgets/PluginParameterBox.h \ widgets/PluginParameterDialog.h \ widgets/PluginPathConfigurator.h \ + widgets/PluginReviewDialog.h \ widgets/ProgressDialog.h \ widgets/PropertyBox.h \ widgets/PropertyStack.h \ @@ -158,6 +159,7 @@ widgets/PluginParameterBox.cpp \ widgets/PluginParameterDialog.cpp \ widgets/PluginPathConfigurator.cpp \ + widgets/PluginReviewDialog.cpp \ widgets/ProgressDialog.cpp \ widgets/PropertyBox.cpp \ widgets/PropertyStack.cpp \
--- a/widgets/PluginPathConfigurator.cpp Wed May 23 16:24:35 2018 +0100 +++ b/widgets/PluginPathConfigurator.cpp Fri May 25 13:39:08 2018 +0100 @@ -13,6 +13,7 @@ */ #include "PluginPathConfigurator.h" +#include "PluginReviewDialog.h" #include <QPushButton> #include <QListWidget> @@ -30,7 +31,7 @@ { m_layout = new QGridLayout; setLayout(m_layout); - + QHBoxLayout *buttons = new QHBoxLayout; m_down = new QPushButton; @@ -84,7 +85,13 @@ this, SLOT(currentLocationChanged(int))); ++row; - m_layout->addLayout(buttons, row, 2); + m_layout->addLayout(buttons, row, 0, Qt::AlignLeft); + + m_seePlugins = new QPushButton; + m_seePlugins->setText(tr("Review plugins...")); + connect(m_seePlugins, SIGNAL(clicked()), this, SLOT(seePluginsClicked())); + m_layout->addWidget(m_seePlugins, row, 2); + ++row; m_envOverride = new QCheckBox; @@ -172,9 +179,17 @@ } void -PluginPathConfigurator::envOverrideChanged(int ) +PluginPathConfigurator::envOverrideChanged(int state) { - //!!! + bool useEnvVariable = (state == Qt::Checked); + + QString type = m_pluginTypeSelector->currentText(); + + auto newEntry = m_paths.at(type); + newEntry.useEnvVariable = useEnvVariable; + m_paths[type] = newEntry; + + emit pathsChanged(m_paths); } void @@ -202,6 +217,8 @@ m_paths[type] = newEntry; populateFor(type, current - 1); + + emit pathsChanged(m_paths); } void @@ -229,6 +246,8 @@ m_paths[type] = newEntry; populateFor(type, current + 1); + + emit pathsChanged(m_paths); } void @@ -246,6 +265,8 @@ m_paths[type] = newEntry; populateFor(type, newEntry.directories.size() - 1); + + emit pathsChanged(m_paths); } void @@ -269,6 +290,8 @@ m_paths[type] = newEntry; populateFor(type, current < newPath.size() ? current : current-1); + + emit pathsChanged(m_paths); } void @@ -277,4 +300,15 @@ QString type = m_pluginTypeSelector->currentText(); m_paths[type] = m_originalPaths[type]; populateFor(type, -1); + + emit pathsChanged(m_paths); } + +void +PluginPathConfigurator::seePluginsClicked() +{ + PluginReviewDialog dialog(this); + dialog.populate(); + dialog.exec(); +} +
--- a/widgets/PluginPathConfigurator.h Wed May 23 16:24:35 2018 +0100 +++ b/widgets/PluginPathConfigurator.h Fri May 25 13:39:08 2018 +0100 @@ -61,12 +61,14 @@ void currentTypeChanged(QString); void currentLocationChanged(int); void envOverrideChanged(int); + void seePluginsClicked(); private: QGridLayout *m_layout; QLabel *m_header; QComboBox *m_pluginTypeSelector; QListWidget *m_list; + QPushButton *m_seePlugins; QPushButton *m_up; QPushButton *m_down; QPushButton *m_add;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/PluginReviewDialog.cpp Fri May 25 13:39:08 2018 +0100 @@ -0,0 +1,140 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#include "PluginReviewDialog.h" + +#include <QGridLayout> +#include <QTableWidget> +#include <QDialogButtonBox> +#include <QFileInfo> +#include <QHeaderView> +#include <QDesktopWidget> +#include <QApplication> + +#include "plugin/FeatureExtractionPluginFactory.h" +#include "plugin/RealTimePluginFactory.h" + +PluginReviewDialog::PluginReviewDialog(QWidget *parent) : + QDialog(parent) +{ + setWindowTitle(tr("Plugins Loaded")); + + QGridLayout *layout = new QGridLayout; + setLayout(layout); + + m_table = new QTableWidget; + layout->addWidget(m_table, 0, 1); + + QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok); + layout->addWidget(bb, 1, 1); + connect(bb, SIGNAL(accepted()), this, SLOT(accept())); +} + +PluginReviewDialog::~PluginReviewDialog() +{ +} + +void +PluginReviewDialog::populate() +{ + FeatureExtractionPluginFactory *feFactory = + FeatureExtractionPluginFactory::instance(); + QString err; + std::vector<QString> feIds = feFactory->getPluginIdentifiers(err); + + RealTimePluginFactory *dssiFactory = + RealTimePluginFactory::instance("dssi"); + std::vector<QString> dssiIds = dssiFactory->getPluginIdentifiers(); + + RealTimePluginFactory *ladspaFactory = + RealTimePluginFactory::instance("ladspa"); + std::vector<QString> ladspaIds = ladspaFactory->getPluginIdentifiers(); + + m_table->setRowCount(int(feIds.size() + dssiIds.size() + ladspaIds.size())); + m_table->setColumnCount(5); + + QStringList headers; + int typeCol = 0, libCol = 1, nameCol = 2, idCol = 3, dirCol = 4; + headers << tr("Type") << tr("Library") << tr("Name") + << tr("Identifier") << tr("Location"); + m_table->setHorizontalHeaderLabels(headers); + + int row = 0; + + for (QString id: feIds) { + auto staticData = feFactory->getPluginStaticData(id); + m_table->setItem(row, typeCol, new QTableWidgetItem + (tr("Vamp"))); + m_table->setItem(row, idCol, new QTableWidgetItem + (QString::fromStdString(staticData.basic.identifier))); + m_table->setItem(row, nameCol, new QTableWidgetItem + (QString::fromStdString(staticData.basic.name))); + QString path = feFactory->getPluginLibraryPath(id); + m_table->setItem(row, libCol, new QTableWidgetItem + (QFileInfo(path).fileName())); + m_table->setItem(row, dirCol, new QTableWidgetItem + (QFileInfo(path).path())); + row++; + } + + for (QString id: dssiIds) { + auto descriptor = dssiFactory->getPluginDescriptor(id); + if (!descriptor) continue; + m_table->setItem(row, typeCol, new QTableWidgetItem + (tr("DSSI"))); + m_table->setItem(row, idCol, new QTableWidgetItem + (QString::fromStdString(descriptor->label))); + m_table->setItem(row, nameCol, new QTableWidgetItem + (QString::fromStdString(descriptor->name))); + QString path = dssiFactory->getPluginLibraryPath(id); + m_table->setItem(row, libCol, new QTableWidgetItem + (QFileInfo(path).fileName())); + m_table->setItem(row, dirCol, new QTableWidgetItem + (QFileInfo(path).path())); + row++; + } + + for (QString id: ladspaIds) { + auto descriptor = ladspaFactory->getPluginDescriptor(id); + if (!descriptor) continue; + m_table->setItem(row, typeCol, new QTableWidgetItem + (tr("LADSPA"))); + m_table->setItem(row, idCol, new QTableWidgetItem + (QString::fromStdString(descriptor->label))); + m_table->setItem(row, nameCol, new QTableWidgetItem + (QString::fromStdString(descriptor->name))); + QString path = ladspaFactory->getPluginLibraryPath(id); + m_table->setItem(row, libCol, new QTableWidgetItem + (QFileInfo(path).fileName())); + m_table->setItem(row, dirCol, new QTableWidgetItem + (QFileInfo(path).path())); + row++; + } + + m_table->setSortingEnabled(true); + m_table->setSelectionMode(QAbstractItemView::NoSelection); + m_table->resizeColumnsToContents(); + + int twidth = m_table->horizontalHeader()->length(); + int theight = m_table->verticalHeader()->length(); + + QDesktopWidget *desktop = QApplication::desktop(); + QRect available = desktop->availableGeometry(); + + int width = std::min(twidth + 30, (available.width() * 3) / 4); + int height = std::min(theight + 30, (available.height() * 3) / 4); + + resize(width, height); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/PluginReviewDialog.h Fri May 25 13:39:08 2018 +0100 @@ -0,0 +1,37 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef SV_PLUGIN_REVIEW_DIALOG_H +#define SV_PLUGIN_REVIEW_DIALOG_H + +#include <QDialog> +#include <QTableWidget> + +class QEvent; + +class PluginReviewDialog : public QDialog +{ + Q_OBJECT + +public: + PluginReviewDialog(QWidget *parent = 0); + ~PluginReviewDialog(); + + void populate(); + +private: + QTableWidget *m_table; +}; + +#endif