18 #include "base/XmlExportable.h" 19 #include "transform/TransformFactory.h" 22 #include <QVBoxLayout> 23 #include <QGridLayout> 26 #include <QDialogButtonBox> 27 #include <QScrollArea> 28 #include <QApplication> 35 m_resultsFrame(nullptr),
36 m_resultsLayout(nullptr)
38 setWindowTitle(tr(
"Find a Transform"));
40 QGridLayout *mainGrid =
new QGridLayout;
41 mainGrid->setVerticalSpacing(0);
44 mainGrid->addWidget(
new QLabel(tr(
"Find:")), 0, 0);
46 QLineEdit *searchField =
new QLineEdit;
47 mainGrid->addWidget(searchField, 0, 1);
48 connect(searchField, SIGNAL(textChanged(
const QString &)),
57 mainGrid->setRowStretch(2, 10);
59 QDialogButtonBox *bb =
new QDialogButtonBox(QDialogButtonBox::Ok |
60 QDialogButtonBox::Cancel);
61 mainGrid->addWidget(bb, 3, 0, 1, 2);
62 connect(bb, SIGNAL(accepted()),
this, SLOT(accept()));
63 connect(bb, SIGNAL(rejected()),
this, SLOT(reject()));
67 palette.setColor(QPalette::Window, palette.color(QPalette::Base));
85 QAction *
up =
new QAction(tr(
"Up"),
this);
86 up->setShortcut(tr(
"Up"));
87 connect(up, SIGNAL(triggered()),
this, SLOT(
up()));
90 QAction *
down =
new QAction(tr(
"Down"),
this);
91 down->setShortcut(tr(
"Down"));
92 connect(down, SIGNAL(triggered()),
this, SLOT(
down()));
95 QScreen *screen = QApplication::primaryScreen();
96 QRect available = screen->availableGeometry();
98 int width = available.width() / 2;
99 int height = available.height() / 2;
101 if (available.height() > 500) height = 450;
104 if (available.width() > 650) width = 600;
107 resize(width, height);
126 TransformFactory::getInstance()->haveInstalledTransforms();
127 bool haveUninstalled =
128 TransformFactory::getInstance()->haveUninstalledTransforms();
137 tr(
"<p>Type some text into the search box to search the descriptions of:<ul><li>All currently installed <a href=\"http://www.vamp-plugins.org/\">Vamp</a> audio feature extraction plugins</li><li>All currently installed <a href=\"http://www.ladspa.org/\">LADSPA</a> audio effects plugins</li><li>Vamp plugins that are not currently installed but that have descriptions published via the semantic web</li></ul>");
140 tr(
"<b>Unable to retrieve published descriptions from network!</b>");
143 tr(
"<b>No plugins are currently installed!</b>");
146 if (haveUninstalled) {
151 tr(
"<p>%1<br>Perhaps the network connection is down, services are responding too slowly, or a processing problem has occurred.<br>Only the descriptions of installed plugins will be searched.").arg(nopull));
154 if (haveUninstalled) {
157 tr(
"<p>%1<br>Only the published descriptions of Vamp feature extraction plugins will be searched.").arg(noinst));
161 tr(
"<p>%1<br>%2<br>Perhaps the network connection is down, or services are responding too slowly.<br>No search results will be available.").arg(noinst).arg(nopull));
186 QStringList keywords = text.split(
' ', QString::SkipEmptyParts);
187 TransformFactory::SearchResults results =
188 TransformFactory::getInstance()->search(keywords);
192 std::set<TextMatcher::Match> sorted;
194 for (TransformFactory::SearchResults::const_iterator j = results.begin();
195 j != results.end(); ++j) {
196 sorted.insert(j->second);
200 for (std::set<TextMatcher::Match>::const_iterator j = sorted.end();
201 j != sorted.begin(); ) {
227 (tr(
"Found %n description(s) containing <b>%1</b>, showing the first %2 only",
231 (tr(
"Found %n description(s) containing <b>%1</b>",
232 nullptr,
int(sorted.size())).arg(text));
246 TransformDescription desc;
248 TransformFactory *factory = TransformFactory::getInstance();
249 TransformFactory::TransformInstallStatus status =
250 factory->getTransformInstallStatus(tid);
253 if (status == TransformFactory::TransformInstalled) {
254 desc = factory->getTransformDescription(tid);
256 desc = factory->getUninstalledTransformDescription(tid);
257 suffix = tr(
"<i> (not installed)</i>");
261 labelText += tr(
"%1%2<br><small>")
262 .arg(XmlExportable::encodeEntities(desc.name))
266 for (TextMatcher::Match::FragmentMap::const_iterator k =
269 labelText += k->second;
272 labelText += tr(
"</small>");
274 QString selectedText;
275 selectedText += tr(
"<b>%1</b>%2<br>")
276 .arg(XmlExportable::encodeEntities
277 (desc.name ==
"" ? desc.identifier : desc.name))
280 if (desc.longDescription !=
"") {
281 selectedText += tr(
"<small>%1</small>")
282 .arg(XmlExportable::encodeEntities(desc.longDescription));
283 }
else if (desc.description !=
"") {
284 selectedText += tr(
"<small>%1</small>")
285 .arg(XmlExportable::encodeEntities(desc.description));
288 QString indentation = tr(
" —");
290 selectedText += tr(
"<small>");
291 if (desc.type != TransformDescription::UnknownType) {
292 selectedText += tr(
"<br>%1 Plugin type: %2")
294 .arg(XmlExportable::encodeEntities
295 (factory->getTransformTypeName(desc.type)));
297 if (desc.category !=
"") {
298 selectedText += tr(
"<br>%1 Category: %2")
300 .arg(XmlExportable::encodeEntities(desc.category));
302 selectedText += tr(
"<br>%1 System identifier: %2")
304 .arg(XmlExportable::encodeEntities(desc.identifier));
305 if (desc.provider.infoUrl !=
"") {
306 selectedText += tr(
"<br>%1 More information: <a href=\"%2\">%2</a>")
308 .arg(desc.provider.infoUrl);
310 if (status != TransformFactory::TransformInstalled) {
311 bool haveSuitableDownloadLink =
312 (desc.provider.downloadUrl !=
"" &&
313 desc.provider.hasDownloadForThisPlatform());
314 if (haveSuitableDownloadLink) {
315 selectedText += tr(
"<br>%1 Download for %2: <a href=\"%3\">%3</a>")
317 .arg(desc.provider.thisPlatformName())
318 .arg(desc.provider.downloadUrl);
320 if (!desc.provider.foundInPacks.empty()) {
321 QStringList packsLinks;
322 for (
auto p: desc.provider.foundInPacks) {
324 tr(
"<a href=\"%1\">%2</a>").arg(p.second).arg(p.first);
327 (haveSuitableDownloadLink ?
328 tr(
"<br>%1 Also available in: %2") :
329 tr(
"<br>%1 Available in: %2"))
331 .arg(packsLinks.join(tr(
", ")));
335 selectedText += tr(
"</small>");
340 connect(label, SIGNAL(selectionChanged()),
this,
342 connect(label, SIGNAL(doubleClicked()),
this,
344 QPalette palette = label->palette();
345 label->setPalette(palette);
349 m_labels[i]->setObjectName(desc.identifier);
350 m_labels[i]->setFixedWidth(this->width() - 40);
351 m_labels[i]->setUnselectedText(labelText);
354 m_labels[i]->setSelectedText(selectedText);
371 QObject *s = sender();
373 for (
int i = 0; i < (int)
m_labels.size(); ++i) {
374 if (!
m_labels[i]->isVisible())
continue;
385 cerr <<
"selectedLabelChanged: selected transform is now \"" 393 if (TransformFactory::getInstance()->getTransformInstallStatus
395 TransformFactory::TransformInstalled) {
409 for (
int i = 0; i < (int)
m_labels.size(); ++i) {
410 if (!
m_labels[i]->isVisible())
continue;
425 for (
int i = 0; i < (int)
m_labels.size(); ++i) {
426 if (!
m_labels[i]->isVisible())
continue;