now that we have more cover providers, we're bringing the cover manager and the cover searcher goodness to our last.fm-less users

This commit is contained in:
Paweł Bara 2011-04-27 19:10:37 +00:00
parent b15156a7a3
commit fdda938c53
10 changed files with 24 additions and 57 deletions

View File

@ -228,6 +228,9 @@ set(SOURCES
ui/about.cpp ui/about.cpp
ui/addstreamdialog.cpp ui/addstreamdialog.cpp
ui/albumcoverchoicecontroller.cpp ui/albumcoverchoicecontroller.cpp
ui/albumcovermanager.cpp
ui/albumcovermanagerlist.cpp
ui/albumcoversearcher.cpp
ui/coverfromurldialog.cpp ui/coverfromurldialog.cpp
ui/edittagdialog.cpp ui/edittagdialog.cpp
ui/equalizer.cpp ui/equalizer.cpp
@ -422,6 +425,9 @@ set(HEADERS
ui/about.h ui/about.h
ui/addstreamdialog.h ui/addstreamdialog.h
ui/albumcoverchoicecontroller.h ui/albumcoverchoicecontroller.h
ui/albumcovermanager.h
ui/albumcovermanagerlist.h
ui/albumcoversearcher.h
ui/coverfromurldialog.h ui/coverfromurldialog.h
ui/edittagdialog.h ui/edittagdialog.h
ui/equalizer.h ui/equalizer.h
@ -510,6 +516,8 @@ set(UI
ui/about.ui ui/about.ui
ui/addstreamdialog.ui ui/addstreamdialog.ui
ui/albumcovermanager.ui
ui/albumcoversearcher.ui
ui/coverfromurldialog.ui ui/coverfromurldialog.ui
ui/edittagdialog.ui ui/edittagdialog.ui
ui/equalizer.ui ui/equalizer.ui
@ -588,9 +596,6 @@ if(HAVE_LIBLASTFM)
songinfo/echonesttags.cpp songinfo/echonesttags.cpp
songinfo/lastfmtrackinfoprovider.cpp songinfo/lastfmtrackinfoprovider.cpp
songinfo/tagwidget.cpp songinfo/tagwidget.cpp
ui/albumcovermanager.cpp
ui/albumcovermanagerlist.cpp
ui/albumcoversearcher.cpp
) )
list(APPEND HEADERS list(APPEND HEADERS
covers/lastfmcoverprovider.h covers/lastfmcoverprovider.h
@ -601,15 +606,10 @@ if(HAVE_LIBLASTFM)
songinfo/echonesttags.h songinfo/echonesttags.h
songinfo/lastfmtrackinfoprovider.h songinfo/lastfmtrackinfoprovider.h
songinfo/tagwidget.h songinfo/tagwidget.h
ui/albumcovermanager.h
ui/albumcovermanagerlist.h
ui/albumcoversearcher.h
) )
list(APPEND UI list(APPEND UI
radio/lastfmconfig.ui radio/lastfmconfig.ui
radio/lastfmstationdialog.ui radio/lastfmstationdialog.ui
ui/albumcovermanager.ui
ui/albumcoversearcher.ui
) )
endif(HAVE_LIBLASTFM) endif(HAVE_LIBLASTFM)

View File

@ -39,8 +39,11 @@ public:
// Let's a cover provider to register itself in the repository. // Let's a cover provider to register itself in the repository.
void AddCoverProvider(CoverProvider* provider); void AddCoverProvider(CoverProvider* provider);
// Returns a list of the currently registered cover providers. // Returns a list of the currently registered cover providers.
const QList<CoverProvider*> List(); const QList<CoverProvider*> List();
// Returns true if this repository has at least one registered provider.
bool HasAnyProviders() { return !List().isEmpty(); }
~CoverProviders() {} ~CoverProviders() {}

View File

@ -21,13 +21,10 @@
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "ui/albumcoverchoicecontroller.h" #include "ui/albumcoverchoicecontroller.h"
#include "ui/albumcovermanager.h" #include "ui/albumcovermanager.h"
#include "ui/albumcoversearcher.h"
#include "ui/coverfromurldialog.h" #include "ui/coverfromurldialog.h"
#include "ui/iconloader.h" #include "ui/iconloader.h"
#ifdef HAVE_LIBLASTFM
# include "ui/albumcoversearcher.h"
#endif
#include <QAction> #include <QAction>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QDialog> #include <QDialog>
@ -50,17 +47,13 @@ QSet<QString>* AlbumCoverChoiceController::sImageExtensions = NULL;
AlbumCoverChoiceController::AlbumCoverChoiceController(QWidget* parent) AlbumCoverChoiceController::AlbumCoverChoiceController(QWidget* parent)
: QWidget(parent), : QWidget(parent),
#ifdef HAVE_LIBLASTFM
cover_searcher_(new AlbumCoverSearcher(QIcon(":/nocover.png"), this)), cover_searcher_(new AlbumCoverSearcher(QIcon(":/nocover.png"), this)),
#endif
cover_fetcher_(new AlbumCoverFetcher(this)), cover_fetcher_(new AlbumCoverFetcher(this)),
save_file_dialog_(NULL), save_file_dialog_(NULL),
cover_from_url_dialog_(NULL), cover_from_url_dialog_(NULL),
library_(NULL) library_(NULL)
{ {
#ifdef HAVE_LIBLASTFM
cover_searcher_->Init(cover_fetcher_); cover_searcher_->Init(cover_fetcher_);
#endif
cover_from_file_ = new QAction(IconLoader::Load("document-open"), tr("Load cover from disk..."), this); cover_from_file_ = new QAction(IconLoader::Load("document-open"), tr("Load cover from disk..."), this);
cover_to_file_ = new QAction(IconLoader::Load("document-save"), tr("Save cover to disk..."), this); cover_to_file_ = new QAction(IconLoader::Load("document-save"), tr("Save cover to disk..."), this);
@ -164,7 +157,6 @@ QString AlbumCoverChoiceController::LoadCoverFromURL(Song* song) {
} }
QString AlbumCoverChoiceController::SearchForCover(Song* song) { QString AlbumCoverChoiceController::SearchForCover(Song* song) {
#ifdef HAVE_LIBLASTFM
// Get something sensible to stick in the search box // Get something sensible to stick in the search box
QString query = song->artist(); QString query = song->artist();
if (!query.isEmpty()) if (!query.isEmpty())
@ -181,9 +173,6 @@ QString AlbumCoverChoiceController::SearchForCover(Song* song) {
} else { } else {
return QString(); return QString();
} }
#else
return QString();
#endif
} }
QString AlbumCoverChoiceController::UnsetCover(Song* song) { QString AlbumCoverChoiceController::UnsetCover(Song* song) {

View File

@ -23,11 +23,8 @@
#include <QMenu> #include <QMenu>
#include <QWidget> #include <QWidget>
#ifdef HAVE_LIBLASTFM
class AlbumCoverSearcher;
#endif
class AlbumCoverFetcher; class AlbumCoverFetcher;
class AlbumCoverSearcher;
class CoverFromURLDialog; class CoverFromURLDialog;
class LibraryBackend; class LibraryBackend;
class QFileDialog; class QFileDialog;
@ -115,9 +112,7 @@ private:
static bool IsKnownImageExtension(const QString& suffix); static bool IsKnownImageExtension(const QString& suffix);
static QSet<QString>* sImageExtensions; static QSet<QString>* sImageExtensions;
#ifdef HAVE_LIBLASTFM
AlbumCoverSearcher* cover_searcher_; AlbumCoverSearcher* cover_searcher_;
#endif
AlbumCoverFetcher* cover_fetcher_; AlbumCoverFetcher* cover_fetcher_;
QFileDialog* save_file_dialog_; QFileDialog* save_file_dialog_;

View File

@ -20,6 +20,7 @@
#include "iconloader.h" #include "iconloader.h"
#include "ui_albumcovermanager.h" #include "ui_albumcovermanager.h"
#include "covers/albumcoverfetcher.h" #include "covers/albumcoverfetcher.h"
#include "covers/coverproviders.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "library/libraryquery.h" #include "library/libraryquery.h"
#include "library/sqlrow.h" #include "library/sqlrow.h"
@ -444,6 +445,7 @@ bool AlbumCoverManager::eventFilter(QObject *obj, QEvent *event) {
album_cover_choice_controller_->cover_from_url_action()->setEnabled(context_menu_items_.size() == 1); album_cover_choice_controller_->cover_from_url_action()->setEnabled(context_menu_items_.size() == 1);
album_cover_choice_controller_->show_cover_action()->setEnabled(some_with_covers && context_menu_items_.size() == 1); album_cover_choice_controller_->show_cover_action()->setEnabled(some_with_covers && context_menu_items_.size() == 1);
album_cover_choice_controller_->unset_cover_action()->setEnabled(some_with_covers); album_cover_choice_controller_->unset_cover_action()->setEnabled(some_with_covers);
album_cover_choice_controller_->search_for_cover_action()->setEnabled(CoverProviders::instance().HasAnyProviders());
QContextMenuEvent* e = static_cast<QContextMenuEvent*>(event); QContextMenuEvent* e = static_cast<QContextMenuEvent*>(event);
context_menu_->popup(e->globalPos()); context_menu_->popup(e->globalPos());

View File

@ -22,6 +22,7 @@
#include "core/logging.h" #include "core/logging.h"
#include "core/utilities.h" #include "core/utilities.h"
#include "covers/albumcoverloader.h" #include "covers/albumcoverloader.h"
#include "covers/coverproviders.h"
#include "library/library.h" #include "library/library.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "musicbrainz/fingerprinter.h" #include "musicbrainz/fingerprinter.h"
@ -409,11 +410,6 @@ void EditTagDialog::UpdateSummaryTab(const Song& song) {
ui_->summary->setText(summary); ui_->summary->setText(summary);
#ifndef HAVE_LIBLASTFM
album_cover_choice_controller_->cover_from_file_action()->setEnabled(false);
album_cover_choice_controller_->search_for_cover_action()->setEnabled(false);
#endif
album_cover_choice_controller_->unset_cover_action()->setEnabled(art_is_set); album_cover_choice_controller_->unset_cover_action()->setEnabled(art_is_set);
album_cover_choice_controller_->show_cover_action()->setEnabled(art_is_set); album_cover_choice_controller_->show_cover_action()->setEnabled(art_is_set);
ui_->summary_art_button->setEnabled(song.id() != -1); ui_->summary_art_button->setEnabled(song.id() != -1);
@ -429,6 +425,8 @@ void EditTagDialog::UpdateSummaryTab(const Song& song) {
ui_->filesize->setText(Utilities::PrettySize(song.filesize())); ui_->filesize->setText(Utilities::PrettySize(song.filesize()));
ui_->filetype->setText(song.TextForFiletype()); ui_->filetype->setText(song.TextForFiletype());
ui_->filename->setText(QDir::toNativeSeparators(song.filename())); ui_->filename->setText(QDir::toNativeSeparators(song.filename()));
album_cover_choice_controller_->search_for_cover_action()->setEnabled(CoverProviders::instance().HasAnyProviders());
} }
void EditTagDialog::UpdateStatisticsTab(const Song& song) { void EditTagDialog::UpdateStatisticsTab(const Song& song) {

View File

@ -73,6 +73,7 @@
#include "transcoder/transcodedialog.h" #include "transcoder/transcodedialog.h"
#include "ui/about.h" #include "ui/about.h"
#include "ui/addstreamdialog.h" #include "ui/addstreamdialog.h"
#include "ui/albumcovermanager.h"
#include "ui/edittagdialog.h" #include "ui/edittagdialog.h"
#include "ui/equalizer.h" #include "ui/equalizer.h"
#include "ui/iconloader.h" #include "ui/iconloader.h"
@ -97,7 +98,6 @@
#ifdef HAVE_LIBLASTFM #ifdef HAVE_LIBLASTFM
# include "radio/lastfmservice.h" # include "radio/lastfmservice.h"
# include "ui/albumcovermanager.h"
#endif #endif
#ifdef HAVE_WIIMOTEDEV #ifdef HAVE_WIIMOTEDEV
@ -181,9 +181,7 @@ MainWindow::MainWindow(
song_info_view_(new SongInfoView(this)), song_info_view_(new SongInfoView(this)),
artist_info_view_(new ArtistInfoView(this)), artist_info_view_(new ArtistInfoView(this)),
settings_dialog_(NULL), settings_dialog_(NULL),
#ifdef HAVE_LIBLASTFM
cover_manager_(NULL), cover_manager_(NULL),
#endif
equalizer_(new Equalizer), equalizer_(new Equalizer),
error_dialog_(NULL), error_dialog_(NULL),
organise_dialog_(new OrganiseDialog(task_manager_)), organise_dialog_(new OrganiseDialog(task_manager_)),
@ -341,11 +339,7 @@ MainWindow::MainWindow(
connect(ui_->action_add_file, SIGNAL(triggered()), SLOT(AddFile())); connect(ui_->action_add_file, SIGNAL(triggered()), SLOT(AddFile()));
connect(ui_->action_add_folder, SIGNAL(triggered()), SLOT(AddFolder())); connect(ui_->action_add_folder, SIGNAL(triggered()), SLOT(AddFolder()));
connect(ui_->action_add_stream, SIGNAL(triggered()), SLOT(AddStream())); connect(ui_->action_add_stream, SIGNAL(triggered()), SLOT(AddStream()));
#ifdef HAVE_LIBLASTFM
connect(ui_->action_cover_manager, SIGNAL(triggered()), SLOT(ShowCoverManager())); connect(ui_->action_cover_manager, SIGNAL(triggered()), SLOT(ShowCoverManager()));
#else
ui_->action_cover_manager->setEnabled(false);
#endif
connect(ui_->action_equalizer, SIGNAL(triggered()), equalizer_.get(), SLOT(show())); connect(ui_->action_equalizer, SIGNAL(triggered()), equalizer_.get(), SLOT(show()));
connect(ui_->action_transcode, SIGNAL(triggered()), SLOT(ShowTranscodeDialog())); connect(ui_->action_transcode, SIGNAL(triggered()), SLOT(ShowTranscodeDialog()));
connect(ui_->action_jump, SIGNAL(triggered()), ui_->playlist->view(), SLOT(JumpToCurrentlyPlayingTrack())); connect(ui_->action_jump, SIGNAL(triggered()), ui_->playlist->view(), SLOT(JumpToCurrentlyPlayingTrack()));
@ -1871,7 +1865,6 @@ void MainWindow::ChangeLibraryQueryMode(QAction* action) {
} }
} }
#ifdef HAVE_LIBLASTFM
void MainWindow::ShowCoverManager() { void MainWindow::ShowCoverManager() {
if (!cover_manager_) { if (!cover_manager_) {
cover_manager_.reset(new AlbumCoverManager(library_->backend())); cover_manager_.reset(new AlbumCoverManager(library_->backend()));
@ -1883,7 +1876,6 @@ void MainWindow::ShowCoverManager() {
cover_manager_->show(); cover_manager_->show();
} }
#endif
void MainWindow::EnsureSettingsDialogCreated() { void MainWindow::EnsureSettingsDialogCreated() {
if (settings_dialog_) if (settings_dialog_)

View File

@ -33,6 +33,7 @@
class About; class About;
class AddStreamDialog; class AddStreamDialog;
class AlbumCoverManager;
class ArtistInfoView; class ArtistInfoView;
class ArtLoader; class ArtLoader;
class BackgroundStreams; class BackgroundStreams;
@ -77,10 +78,6 @@ class Ui_MainWindow;
class QSortFilterProxyModel; class QSortFilterProxyModel;
#ifdef HAVE_LIBLASTFM
class AlbumCoverManager;
#endif
class MainWindow : public QMainWindow, public PlatformInterface { class MainWindow : public QMainWindow, public PlatformInterface {
Q_OBJECT Q_OBJECT
@ -221,8 +218,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {
void SongSaveComplete(); void SongSaveComplete();
#ifdef HAVE_LIBLASTFM
void ShowCoverManager(); void ShowCoverManager();
#ifdef HAVE_LIBLASTFM
void ScrobblerStatus(int value); void ScrobblerStatus(int value);
#endif #endif
void ShowAboutDialog(); void ShowAboutDialog();
@ -288,9 +285,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
boost::scoped_ptr<SettingsDialog> settings_dialog_; boost::scoped_ptr<SettingsDialog> settings_dialog_;
boost::scoped_ptr<AddStreamDialog> add_stream_dialog_; boost::scoped_ptr<AddStreamDialog> add_stream_dialog_;
#ifdef HAVE_LIBLASTFM
boost::scoped_ptr<AlbumCoverManager> cover_manager_; boost::scoped_ptr<AlbumCoverManager> cover_manager_;
#endif
boost::scoped_ptr<Equalizer> equalizer_; boost::scoped_ptr<Equalizer> equalizer_;
boost::scoped_ptr<TranscodeDialog> transcode_dialog_; boost::scoped_ptr<TranscodeDialog> transcode_dialog_;
boost::scoped_ptr<ErrorDialog> error_dialog_; boost::scoped_ptr<ErrorDialog> error_dialog_;

View File

@ -18,6 +18,7 @@
#include "fullscreenhypnotoad.h" #include "fullscreenhypnotoad.h"
#include "nowplayingwidget.h" #include "nowplayingwidget.h"
#include "covers/albumcoverloader.h" #include "covers/albumcoverloader.h"
#include "covers/coverproviders.h"
#include "covers/kittenloader.h" #include "covers/kittenloader.h"
#include "library/librarybackend.h" #include "library/librarybackend.h"
#include "ui/albumcoverchoicecontroller.h" #include "ui/albumcoverchoicecontroller.h"
@ -379,17 +380,12 @@ void NowPlayingWidget::contextMenuEvent(QContextMenuEvent* e) {
album_cover_choice_controller_->cover_from_file_action()->setEnabled(!aww_); album_cover_choice_controller_->cover_from_file_action()->setEnabled(!aww_);
album_cover_choice_controller_->cover_to_file_action()->setEnabled(aww_); album_cover_choice_controller_->cover_to_file_action()->setEnabled(aww_);
album_cover_choice_controller_->cover_from_url_action()->setEnabled(!aww_); album_cover_choice_controller_->cover_from_url_action()->setEnabled(!aww_);
album_cover_choice_controller_->search_for_cover_action()->setEnabled(!aww_); album_cover_choice_controller_->search_for_cover_action()->setEnabled(!aww_ && CoverProviders::instance().HasAnyProviders());
album_cover_choice_controller_->unset_cover_action()->setEnabled(!aww_); album_cover_choice_controller_->unset_cover_action()->setEnabled(!aww_);
album_cover_choice_controller_->show_cover_action()->setEnabled(!aww_); album_cover_choice_controller_->show_cover_action()->setEnabled(!aww_);
// some special cases // some special cases
if (!aww_) { if (!aww_) {
#ifndef HAVE_LIBLASTFM
album_cover_choice_controller_->cover_from_file_action()->setEnabled(false);
album_cover_choice_controller_->search_for_cover_action()->setEnabled(false);
#endif
const bool art_is_not_set = metadata_.has_manually_unset_cover() const bool art_is_not_set = metadata_.has_manually_unset_cover()
|| (metadata_.art_automatic().isEmpty() && metadata_.art_manual().isEmpty()); || (metadata_.art_automatic().isEmpty() && metadata_.art_manual().isEmpty());

View File

@ -109,6 +109,7 @@ endmacro (add_test_file)
#add_test_file(albumcoverfetcher_test.cpp false) #add_test_file(albumcoverfetcher_test.cpp false)
add_test_file(albumcovermanager_test.cpp true)
add_test_file(asxparser_test.cpp false) add_test_file(asxparser_test.cpp false)
add_test_file(asxiniparser_test.cpp false) add_test_file(asxiniparser_test.cpp false)
add_test_file(cueparser_test.cpp false) add_test_file(cueparser_test.cpp false)
@ -129,10 +130,6 @@ add_test_file(song_test.cpp false)
add_test_file(translations_test.cpp false) add_test_file(translations_test.cpp false)
add_test_file(xspfparser_test.cpp false) add_test_file(xspfparser_test.cpp false)
if(HAVE_LIBLASTFM)
add_test_file(albumcovermanager_test.cpp true)
endif(HAVE_LIBLASTFM)
if(LINUX AND HAVE_DBUS) if(LINUX AND HAVE_DBUS)
add_test_file(mpris1_test.cpp true) add_test_file(mpris1_test.cpp true)
endif(LINUX AND HAVE_DBUS) endif(LINUX AND HAVE_DBUS)