comparison widgets/PluginReviewDialog.cpp @ 1292:41824255ddf2 plugin-path-config

Plugin review dialog
author Chris Cannam
date Fri, 25 May 2018 13:39:08 +0100
parents
children 6dd15b5c14f9
comparison
equal deleted inserted replaced
1291:b5c71304286e 1292:41824255ddf2
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
13 */
14
15 #include "PluginReviewDialog.h"
16
17 #include <QGridLayout>
18 #include <QTableWidget>
19 #include <QDialogButtonBox>
20 #include <QFileInfo>
21 #include <QHeaderView>
22 #include <QDesktopWidget>
23 #include <QApplication>
24
25 #include "plugin/FeatureExtractionPluginFactory.h"
26 #include "plugin/RealTimePluginFactory.h"
27
28 PluginReviewDialog::PluginReviewDialog(QWidget *parent) :
29 QDialog(parent)
30 {
31 setWindowTitle(tr("Plugins Loaded"));
32
33 QGridLayout *layout = new QGridLayout;
34 setLayout(layout);
35
36 m_table = new QTableWidget;
37 layout->addWidget(m_table, 0, 1);
38
39 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
40 layout->addWidget(bb, 1, 1);
41 connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
42 }
43
44 PluginReviewDialog::~PluginReviewDialog()
45 {
46 }
47
48 void
49 PluginReviewDialog::populate()
50 {
51 FeatureExtractionPluginFactory *feFactory =
52 FeatureExtractionPluginFactory::instance();
53 QString err;
54 std::vector<QString> feIds = feFactory->getPluginIdentifiers(err);
55
56 RealTimePluginFactory *dssiFactory =
57 RealTimePluginFactory::instance("dssi");
58 std::vector<QString> dssiIds = dssiFactory->getPluginIdentifiers();
59
60 RealTimePluginFactory *ladspaFactory =
61 RealTimePluginFactory::instance("ladspa");
62 std::vector<QString> ladspaIds = ladspaFactory->getPluginIdentifiers();
63
64 m_table->setRowCount(int(feIds.size() + dssiIds.size() + ladspaIds.size()));
65 m_table->setColumnCount(5);
66
67 QStringList headers;
68 int typeCol = 0, libCol = 1, nameCol = 2, idCol = 3, dirCol = 4;
69 headers << tr("Type") << tr("Library") << tr("Name")
70 << tr("Identifier") << tr("Location");
71 m_table->setHorizontalHeaderLabels(headers);
72
73 int row = 0;
74
75 for (QString id: feIds) {
76 auto staticData = feFactory->getPluginStaticData(id);
77 m_table->setItem(row, typeCol, new QTableWidgetItem
78 (tr("Vamp")));
79 m_table->setItem(row, idCol, new QTableWidgetItem
80 (QString::fromStdString(staticData.basic.identifier)));
81 m_table->setItem(row, nameCol, new QTableWidgetItem
82 (QString::fromStdString(staticData.basic.name)));
83 QString path = feFactory->getPluginLibraryPath(id);
84 m_table->setItem(row, libCol, new QTableWidgetItem
85 (QFileInfo(path).fileName()));
86 m_table->setItem(row, dirCol, new QTableWidgetItem
87 (QFileInfo(path).path()));
88 row++;
89 }
90
91 for (QString id: dssiIds) {
92 auto descriptor = dssiFactory->getPluginDescriptor(id);
93 if (!descriptor) continue;
94 m_table->setItem(row, typeCol, new QTableWidgetItem
95 (tr("DSSI")));
96 m_table->setItem(row, idCol, new QTableWidgetItem
97 (QString::fromStdString(descriptor->label)));
98 m_table->setItem(row, nameCol, new QTableWidgetItem
99 (QString::fromStdString(descriptor->name)));
100 QString path = dssiFactory->getPluginLibraryPath(id);
101 m_table->setItem(row, libCol, new QTableWidgetItem
102 (QFileInfo(path).fileName()));
103 m_table->setItem(row, dirCol, new QTableWidgetItem
104 (QFileInfo(path).path()));
105 row++;
106 }
107
108 for (QString id: ladspaIds) {
109 auto descriptor = ladspaFactory->getPluginDescriptor(id);
110 if (!descriptor) continue;
111 m_table->setItem(row, typeCol, new QTableWidgetItem
112 (tr("LADSPA")));
113 m_table->setItem(row, idCol, new QTableWidgetItem
114 (QString::fromStdString(descriptor->label)));
115 m_table->setItem(row, nameCol, new QTableWidgetItem
116 (QString::fromStdString(descriptor->name)));
117 QString path = ladspaFactory->getPluginLibraryPath(id);
118 m_table->setItem(row, libCol, new QTableWidgetItem
119 (QFileInfo(path).fileName()));
120 m_table->setItem(row, dirCol, new QTableWidgetItem
121 (QFileInfo(path).path()));
122 row++;
123 }
124
125 m_table->setSortingEnabled(true);
126 m_table->setSelectionMode(QAbstractItemView::NoSelection);
127 m_table->resizeColumnsToContents();
128
129 int twidth = m_table->horizontalHeader()->length();
130 int theight = m_table->verticalHeader()->length();
131
132 QDesktopWidget *desktop = QApplication::desktop();
133 QRect available = desktop->availableGeometry();
134
135 int width = std::min(twidth + 30, (available.width() * 3) / 4);
136 int height = std::min(theight + 30, (available.height() * 3) / 4);
137
138 resize(width, height);
139 }
140