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