Show a helpful error if the gstofa plugin isn't available

This commit is contained in:
David Sansome 2011-03-12 22:29:13 +00:00
parent b74576cbd5
commit 1fb7dae446
4 changed files with 26 additions and 2 deletions

View File

@ -32,6 +32,16 @@ Fingerprinter::~Fingerprinter() {
delete event_loop_;
}
bool Fingerprinter::GstreamerHasOfa() {
GstElementFactory* factory = gst_element_factory_find("ofa");
if (!factory) {
return false;
}
gst_object_unref(factory);
return true;
}
GstElement* Fingerprinter::CreateElement(const QString &factory_name,
GstElement *bin) {
GstElement* ret = gst_element_factory_make(

View File

@ -37,6 +37,9 @@ public:
Fingerprinter(const QString& filename);
~Fingerprinter();
// Checks if this gstreamer installation has the required ofa plugin.
static bool GstreamerHasOfa();
// Creates a fingerprint from the song. This method is blocking, so you want
// to call it in another thread. Returns an empty string if no fingerprint
// could be created.

View File

@ -23,6 +23,7 @@
#include "core/utilities.h"
#include "library/library.h"
#include "library/librarybackend.h"
#include "musicbrainz/fingerprinter.h"
#include "playlist/playlistdelegates.h"
#include "ui/albumcoverchoicecontroller.h"
#include "ui/coverfromurldialog.h"
@ -59,7 +60,7 @@ EditTagDialog::EditTagDialog(QWidget* parent)
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage,QImage)),
SLOT(ArtLoaded(quint64,QImage,QImage)));
connect(tag_fetcher_, SIGNAL(ResultAvailable(Song, SongList)),
results_dialog_, SLOT(FetchTagFinished(Songa, SongList)),
results_dialog_, SLOT(FetchTagFinished(Song, SongList)),
Qt::QueuedConnection);
connect(tag_fetcher_, SIGNAL(Progress(Song,QString)),
results_dialog_, SLOT(FetchTagProgress(Song,QString)));
@ -69,7 +70,6 @@ EditTagDialog::EditTagDialog(QWidget* parent)
ui_->setupUi(this);
ui_->splitter->setSizes(QList<int>() << 200 << width() - 200);
ui_->loading_container->hide();
ui_->fetch_tag->setVisible(false);
// An editable field is one that has a label as a buddy. The label is
// important because it gets turned bold when the field is changed.
@ -679,6 +679,11 @@ void EditTagDialog::ResetPlayCounts() {
}
void EditTagDialog::FetchTag() {
if (!Fingerprinter::GstreamerHasOfa()) {
QMessageBox::warning(this, tr("Error"), tr("Your gstreamer installation is missing the 'ofa' plugin. This is required for automatic tag fetching. Try installing the 'gstreamer-plugins-bad' package."));
return;
}
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
SongList songs;

View File

@ -45,6 +45,7 @@
#include "library/librarydirectorymodel.h"
#include "library/libraryfilterwidget.h"
#include "library/libraryviewcontainer.h"
#include "musicbrainz/fingerprinter.h"
#include "musicbrainz/tagfetcher.h"
#include "playlist/playlistbackend.h"
#include "playlist/playlist.h"
@ -1887,6 +1888,11 @@ void MainWindow::Exit() {
}
void MainWindow::AutoCompleteTags() {
if (!Fingerprinter::GstreamerHasOfa()) {
QMessageBox::warning(this, tr("Error"), tr("Your gstreamer installation is missing the 'ofa' plugin. This is required for automatic tag fetching. Try installing the 'gstreamer-plugins-bad' package."));
return;
}
// Create the tag fetching stuff if it hasn't been already
if (!tag_fetcher_) {
tag_fetcher_.reset(new TagFetcher);