Make last.fm optional. Thanks volkov0aa. Fixes issue #49
This commit is contained in:
parent
623ab527ee
commit
28fdb147d8
@ -56,6 +56,10 @@ endif (WIN32)
|
||||
find_library(LASTFM_LIBRARIES lastfm)
|
||||
find_path(LASTFM_INCLUDE_DIRS lastfm/ws.h)
|
||||
|
||||
if (LASTFM_LIBRARIES AND LASTFM_INCLUDE_DIRS)
|
||||
set(HAVE_LIBLASTFM ON)
|
||||
endif (LASTFM_LIBRARIES AND LASTFM_INCLUDE_DIRS)
|
||||
|
||||
if (APPLE)
|
||||
find_library(GROWL Growl)
|
||||
option(ENABLE_SPARKLE "Sparkle updating" ON)
|
||||
@ -102,7 +106,9 @@ include_directories(${GSTREAMER_INCLUDE_DIRS})
|
||||
include_directories(${GLIB_INCLUDE_DIRS})
|
||||
include_directories(${GLIBCONFIG_INCLUDE_DIRS})
|
||||
include_directories(${LIBXML_INCLUDE_DIRS})
|
||||
include_directories(${LASTFM_INCLUDE_DIRS})
|
||||
if (HAVE_LIBLASTFM)
|
||||
include_directories(${LASTFM_INCLUDE_DIRS})
|
||||
endif (HAVE_LIBLASTFM)
|
||||
include_directories("3rdparty/qsqlite")
|
||||
include_directories("3rdparty/universalchardet")
|
||||
|
||||
@ -263,4 +269,5 @@ summary_add("Gnome sound menu integration" HAVE_LIBINDICATE)
|
||||
summary_add("Wiimote support" ENABLE_WIIMOTEDEV)
|
||||
summary_add("Visualisations" ENABLE_VISUALISATIONS)
|
||||
summary_add("Sparkle integration" HAVE_SPARKLE)
|
||||
summary_add("Last.fm support" HAVE_LIBLASTFM)
|
||||
summary_show()
|
||||
|
@ -37,7 +37,6 @@ set(SOURCES
|
||||
analyzers/sonogram.cpp
|
||||
analyzers/turbine.cpp
|
||||
|
||||
core/albumcoverfetcher.cpp
|
||||
core/albumcoverloader.cpp
|
||||
core/backgroundstreams.cpp
|
||||
core/backgroundthread.cpp
|
||||
@ -120,7 +119,6 @@ set(SOURCES
|
||||
playlistparsers/xmlparser.cpp
|
||||
playlistparsers/xspfparser.cpp
|
||||
|
||||
radio/fixlastfm.cpp
|
||||
radio/icecastbackend.cpp
|
||||
radio/icecastfilterwidget.cpp
|
||||
radio/icecastmodel.cpp
|
||||
@ -128,9 +126,6 @@ set(SOURCES
|
||||
radio/jamendodynamicplaylist.cpp
|
||||
radio/jamendoplaylistitem.cpp
|
||||
radio/jamendoservice.cpp
|
||||
radio/lastfmconfig.cpp
|
||||
radio/lastfmservice.cpp
|
||||
radio/lastfmstationdialog.cpp
|
||||
radio/magnatuneconfig.cpp
|
||||
radio/magnatunedownloaddialog.cpp
|
||||
radio/magnatuneplaylistitem.cpp
|
||||
@ -160,9 +155,6 @@ set(SOURCES
|
||||
songinfo/collapsibleinfopane.cpp
|
||||
songinfo/echonestbiographies.cpp
|
||||
songinfo/echonestimages.cpp
|
||||
songinfo/echonestsimilarartists.cpp
|
||||
songinfo/echonesttags.cpp
|
||||
songinfo/lastfmtrackinfoprovider.cpp
|
||||
songinfo/lyricsettings.cpp
|
||||
songinfo/songinfobase.cpp
|
||||
songinfo/songinfofetcher.cpp
|
||||
@ -170,15 +162,11 @@ set(SOURCES
|
||||
songinfo/songinfotextview.cpp
|
||||
songinfo/songinfoview.cpp
|
||||
songinfo/songplaystats.cpp
|
||||
songinfo/tagwidget.cpp
|
||||
songinfo/ultimatelyricsprovider.cpp
|
||||
songinfo/ultimatelyricsreader.cpp
|
||||
|
||||
ui/about.cpp
|
||||
ui/addstreamdialog.cpp
|
||||
ui/albumcovermanager.cpp
|
||||
ui/albumcovermanagerlist.cpp
|
||||
ui/albumcoversearcher.cpp
|
||||
ui/edittagdialog.cpp
|
||||
ui/equalizer.cpp
|
||||
ui/flowlayout.cpp
|
||||
@ -231,7 +219,6 @@ set(HEADERS
|
||||
analyzers/sonogram.h
|
||||
analyzers/turbine.h
|
||||
|
||||
core/albumcoverfetcher.h
|
||||
core/albumcoverloader.h
|
||||
core/backgroundstreams.h
|
||||
core/backgroundthread.h
|
||||
@ -300,9 +287,6 @@ set(HEADERS
|
||||
radio/icecastservice.h
|
||||
radio/jamendodynamicplaylist.h
|
||||
radio/jamendoservice.h
|
||||
radio/lastfmconfig.h
|
||||
radio/lastfmservice.h
|
||||
radio/lastfmstationdialog.h
|
||||
radio/magnatuneconfig.h
|
||||
radio/magnatunedownloaddialog.h
|
||||
radio/magnatuneservice.h
|
||||
@ -328,9 +312,6 @@ set(HEADERS
|
||||
songinfo/collapsibleinfopane.h
|
||||
songinfo/echonestbiographies.h
|
||||
songinfo/echonestimages.h
|
||||
songinfo/echonestsimilarartists.h
|
||||
songinfo/echonesttags.h
|
||||
songinfo/lastfmtrackinfoprovider.h
|
||||
songinfo/lyricsettings.h
|
||||
songinfo/songinfobase.h
|
||||
songinfo/songinfofetcher.h
|
||||
@ -338,15 +319,11 @@ set(HEADERS
|
||||
songinfo/songinfotextview.h
|
||||
songinfo/songinfoview.h
|
||||
songinfo/songplaystats.h
|
||||
songinfo/tagwidget.h
|
||||
songinfo/ultimatelyricsprovider.h
|
||||
songinfo/ultimatelyricsreader.h
|
||||
|
||||
ui/about.h
|
||||
ui/addstreamdialog.h
|
||||
ui/albumcovermanager.h
|
||||
ui/albumcovermanagerlist.h
|
||||
ui/albumcoversearcher.h
|
||||
ui/edittagdialog.h
|
||||
ui/equalizer.h
|
||||
ui/globalshortcutgrabber.h
|
||||
@ -399,8 +376,6 @@ set(UI
|
||||
playlist/queuemanager.ui
|
||||
|
||||
radio/icecastfilterwidget.ui
|
||||
radio/lastfmconfig.ui
|
||||
radio/lastfmstationdialog.ui
|
||||
radio/magnatuneconfig.ui
|
||||
radio/magnatunedownloaddialog.ui
|
||||
radio/radioviewcontainer.ui
|
||||
@ -415,8 +390,6 @@ set(UI
|
||||
|
||||
ui/about.ui
|
||||
ui/addstreamdialog.ui
|
||||
ui/albumcovermanager.ui
|
||||
ui/albumcoversearcher.ui
|
||||
ui/edittagdialog.ui
|
||||
ui/equalizer.ui
|
||||
ui/globalshortcutgrabber.ui
|
||||
@ -501,6 +474,43 @@ if(ENABLE_VISUALISATIONS)
|
||||
)
|
||||
endif(ENABLE_VISUALISATIONS)
|
||||
|
||||
# Lastfm
|
||||
if(HAVE_LIBLASTFM)
|
||||
list(APPEND SOURCES
|
||||
core/albumcoverfetcher.cpp
|
||||
radio/fixlastfm.cpp
|
||||
radio/lastfmconfig.cpp
|
||||
radio/lastfmservice.cpp
|
||||
radio/lastfmstationdialog.cpp
|
||||
songinfo/echonestsimilarartists.cpp
|
||||
songinfo/echonesttags.cpp
|
||||
songinfo/lastfmtrackinfoprovider.cpp
|
||||
songinfo/tagwidget.cpp
|
||||
ui/albumcovermanager.cpp
|
||||
ui/albumcovermanagerlist.cpp
|
||||
ui/albumcoversearcher.cpp
|
||||
)
|
||||
list(APPEND HEADERS
|
||||
core/albumcoverfetcher.h
|
||||
radio/lastfmconfig.h
|
||||
radio/lastfmservice.h
|
||||
radio/lastfmstationdialog.h
|
||||
songinfo/echonestsimilarartists.h
|
||||
songinfo/echonesttags.h
|
||||
songinfo/lastfmtrackinfoprovider.h
|
||||
songinfo/tagwidget.h
|
||||
ui/albumcovermanager.h
|
||||
ui/albumcovermanagerlist.h
|
||||
ui/albumcoversearcher.h
|
||||
)
|
||||
list(APPEND UI
|
||||
radio/lastfmconfig.ui
|
||||
radio/lastfmstationdialog.ui
|
||||
ui/albumcovermanager.ui
|
||||
ui/albumcoversearcher.ui
|
||||
)
|
||||
endif(HAVE_LIBLASTFM)
|
||||
|
||||
# Transcoder
|
||||
if(HAVE_GSTREAMER)
|
||||
list(APPEND SOURCES
|
||||
@ -766,7 +776,6 @@ target_link_libraries(clementine_lib
|
||||
${TAGLIB_LIBRARIES}
|
||||
${QT_LIBRARIES}
|
||||
${ENGINE_LIBRARIES}
|
||||
${LASTFM_LIBRARIES}
|
||||
${QTSINGLEAPPLICATION_LIBRARIES}
|
||||
${QTSINGLECOREAPPLICATION_LIBRARIES}
|
||||
${QTIOCOMPRESSOR_LIBRARIES}
|
||||
@ -779,6 +788,10 @@ if(ENABLE_VISUALISATIONS)
|
||||
target_link_libraries(clementine_lib ${LIBPROJECTM_LIBRARIES})
|
||||
endif(ENABLE_VISUALISATIONS)
|
||||
|
||||
if(HAVE_LIBLASTFM)
|
||||
target_link_libraries(clementine_lib ${LASTFM_LIBRARIES})
|
||||
endif(HAVE_LIBLASTFM)
|
||||
|
||||
if(HAVE_LIBGPOD)
|
||||
target_link_libraries(clementine_lib ${LIBGPOD_LIBRARIES})
|
||||
endif(HAVE_LIBGPOD)
|
||||
|
@ -48,4 +48,6 @@
|
||||
|
||||
#cmakedefine HAVE_LIBINDICATE
|
||||
|
||||
#cmakedefine HAVE_LIBLASTFM
|
||||
|
||||
#endif // CONFIG_H_IN
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "playlist/playlist.h"
|
||||
#include "playlist/playlistitem.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "radio/lastfmservice.h"
|
||||
#include "mpris_common.h"
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
@ -36,6 +35,9 @@
|
||||
#ifdef HAVE_QT_PHONON
|
||||
# include "engines/phononengine.h"
|
||||
#endif
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
# include "radio/lastfmservice.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
# include "mpris.h"
|
||||
@ -53,13 +55,18 @@ using boost::shared_ptr;
|
||||
|
||||
|
||||
Player::Player(MainWindow* main_window, PlaylistManager* playlists,
|
||||
LastFMService* lastfm, Engine::Type engine, QObject* parent)
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
LastFMService* lastfm,
|
||||
#endif
|
||||
Engine::Type engine, QObject* parent)
|
||||
: QObject(parent),
|
||||
art_loader_(new mpris::ArtLoader(this)),
|
||||
mpris1_(NULL),
|
||||
mpris2_(NULL),
|
||||
playlists_(playlists),
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
lastfm_(lastfm),
|
||||
#endif
|
||||
engine_(CreateEngine(engine)),
|
||||
stream_change_type_(Engine::First),
|
||||
last_state_(Engine::Empty),
|
||||
@ -322,13 +329,17 @@ void Player::PlayAt(int index, Engine::TrackChangeType change, bool reshuffle) {
|
||||
loading_async_ = QUrl();
|
||||
engine_->Play(current_item_->Url(), change);
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
if (lastfm_->IsScrobblingEnabled())
|
||||
lastfm_->NowPlaying(current_item_->Metadata());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void Player::CurrentMetadataChanged(const Song& metadata) {
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
lastfm_->NowPlaying(metadata);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::Seek(int seconds) {
|
||||
|
@ -30,9 +30,12 @@
|
||||
|
||||
class PlaylistManager;
|
||||
class Settings;
|
||||
class LastFMService;
|
||||
class MainWindow;
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
class LastFMService;
|
||||
#endif
|
||||
|
||||
namespace mpris {
|
||||
class Mpris1;
|
||||
class Mpris2;
|
||||
@ -50,7 +53,10 @@ class Player : public QObject {
|
||||
|
||||
public:
|
||||
Player(MainWindow* main_window, PlaylistManager* playlists,
|
||||
LastFMService* lastfm, Engine::Type engine, QObject* parent = 0);
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
LastFMService* lastfm,
|
||||
#endif
|
||||
Engine::Type engine, QObject* parent = 0);
|
||||
~Player();
|
||||
|
||||
EngineBase* CreateEngine(Engine::Type engine);
|
||||
@ -124,7 +130,9 @@ class Player : public QObject {
|
||||
mpris::Mpris2* mpris2_;
|
||||
|
||||
PlaylistManager* playlists_;
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
LastFMService* lastfm_;
|
||||
#endif
|
||||
QSettings settings_;
|
||||
|
||||
PlaylistItemPtr current_item_;
|
||||
|
@ -42,8 +42,10 @@
|
||||
#include <taglib/vorbisfile.h>
|
||||
#include <taglib/wavfile.h>
|
||||
|
||||
#include "radio/fixlastfm.h"
|
||||
#include <lastfm/Track>
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
#include "radio/fixlastfm.h"
|
||||
#include <lastfm/Track>
|
||||
#endif
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
@ -485,6 +487,7 @@ void Song::InitFromQuery(const SqlRow& q, int col) {
|
||||
#undef tofloat
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void Song::InitFromLastFM(const lastfm::Track& track) {
|
||||
d->valid_ = true;
|
||||
d->filetype_ = Type_Stream;
|
||||
@ -495,6 +498,7 @@ void Song::InitFromLastFM(const lastfm::Track& track) {
|
||||
d->track_ = track.trackNumber();
|
||||
d->length_ = track.duration();
|
||||
}
|
||||
#endif // HAVE_LIBLASTFM
|
||||
|
||||
#ifdef HAVE_LIBGPOD
|
||||
void Song::InitFromItdb(const Itdb_Track* track) {
|
||||
@ -948,6 +952,7 @@ void Song::BindToFtsQuery(QSqlQuery *query) const {
|
||||
query->bindValue(":ftscomment", d->comment_);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void Song::ToLastFM(lastfm::Track* track) const {
|
||||
lastfm::MutableTrack mtrack(*track);
|
||||
|
||||
@ -958,6 +963,7 @@ void Song::ToLastFM(lastfm::Track* track) const {
|
||||
mtrack.setTrackNumber(d->track_);
|
||||
mtrack.setSource(lastfm::Track::Player);
|
||||
}
|
||||
#endif // HAVE_LIBLASTFM
|
||||
|
||||
QString Song::PrettyTitle() const {
|
||||
QString title(d->title_);
|
||||
|
@ -46,9 +46,11 @@
|
||||
|
||||
class SqlRow;
|
||||
|
||||
namespace lastfm {
|
||||
class Track;
|
||||
}
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
namespace lastfm {
|
||||
class Track;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace TagLib {
|
||||
class FileRef;
|
||||
@ -112,7 +114,9 @@ class Song {
|
||||
void Init(const QString& title, const QString& artist, const QString& album, int length);
|
||||
void InitFromFile(const QString& filename, int directory_id);
|
||||
void InitFromQuery(const SqlRow& query, int col = 0);
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void InitFromLastFM(const lastfm::Track& track);
|
||||
#endif
|
||||
|
||||
void MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle& bundle);
|
||||
|
||||
@ -137,7 +141,9 @@ class Song {
|
||||
// Save
|
||||
void BindToQuery(QSqlQuery* query) const;
|
||||
void BindToFtsQuery(QSqlQuery* query) const;
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void ToLastFM(lastfm::Track* track) const;
|
||||
#endif
|
||||
|
||||
// Simple accessors
|
||||
bool is_valid() const { return d->valid_; }
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "core/utilities.h"
|
||||
#include "engines/enginebase.h"
|
||||
#include "library/directory.h"
|
||||
#include "radio/lastfmservice.h"
|
||||
#include "smartplaylists/generator.h"
|
||||
#include "ui/equalizer.h"
|
||||
#include "ui/iconloader.h"
|
||||
@ -55,6 +54,9 @@
|
||||
#include <echonest/Config.h>
|
||||
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
#include "radio/lastfmservice.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
# include <gst/gst.h>
|
||||
@ -151,8 +153,10 @@ int main(int argc, char *argv[]) {
|
||||
qRegisterMetaType<GstEnginePipeline*>("GstEnginePipeline*");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
lastfm::ws::ApiKey = LastFMService::kApiKey;
|
||||
lastfm::ws::SharedSecret = LastFMService::kSecret;
|
||||
#endif
|
||||
|
||||
// Parse commandline options - need to do this before starting the
|
||||
// QApplication so it works without an X server
|
||||
|
@ -52,8 +52,6 @@
|
||||
#include <boost/bind.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include <lastfm/ScrobblePoint>
|
||||
|
||||
using smart_playlists::Generator;
|
||||
using smart_playlists::GeneratorInserter;
|
||||
using smart_playlists::GeneratorPtr;
|
||||
@ -1194,10 +1192,9 @@ Song Playlist::current_item_metadata() const {
|
||||
}
|
||||
|
||||
void Playlist::UpdateScrobblePoint() {
|
||||
int length = qMin(current_item_metadata().length(), 240);
|
||||
const int length = current_item_metadata().length();
|
||||
|
||||
ScrobblePoint point(length / 2);
|
||||
scrobble_point_ = point;
|
||||
scrobble_point_ = length == 0 ? 240 : qBound(31, length/2, 240);
|
||||
has_scrobbled_ = false;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "core/mergedproxymodel.h"
|
||||
#include "icecastservice.h"
|
||||
#include "jamendoservice.h"
|
||||
#include "lastfmservice.h"
|
||||
#include "magnatuneservice.h"
|
||||
#include "radiomimedata.h"
|
||||
#include "radiomodel.h"
|
||||
@ -26,6 +25,10 @@
|
||||
#include "savedradio.h"
|
||||
#include "somafmservice.h"
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
#include "lastfmservice.h"
|
||||
#endif
|
||||
|
||||
#include <QMimeData>
|
||||
#include <QtDebug>
|
||||
|
||||
@ -43,7 +46,9 @@ RadioModel::RadioModel(BackgroundThread<Database>* db_thread,
|
||||
root_->lazy_loaded = true;
|
||||
merged_model_->setSourceModel(this);
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
AddService(new LastFMService(this));
|
||||
#endif
|
||||
AddService(new SomaFMService(this));
|
||||
AddService(new MagnatuneService(this));
|
||||
AddService(new JamendoService(this));
|
||||
@ -139,11 +144,13 @@ QMimeData* RadioModel::mimeData(const QModelIndexList& indexes) const {
|
||||
return data;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
LastFMService* RadioModel::GetLastFMService() const {
|
||||
if (sServices.contains(LastFMService::kServiceName))
|
||||
return static_cast<LastFMService*>(sServices[LastFMService::kServiceName]);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RadioModel::ShowContextMenu(RadioItem* item, const QModelIndex& index,
|
||||
const QPoint& global_pos) {
|
||||
|
@ -27,12 +27,15 @@
|
||||
#include "widgets/multiloadingindicator.h"
|
||||
|
||||
class Database;
|
||||
class LastFMService;
|
||||
class MergedProxyModel;
|
||||
class RadioService;
|
||||
class SettingsDialog;
|
||||
class TaskManager;
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
class LastFMService;
|
||||
#endif
|
||||
|
||||
class RadioModel : public SimpleTreeModel<RadioItem> {
|
||||
Q_OBJECT
|
||||
|
||||
@ -58,7 +61,9 @@ class RadioModel : public SimpleTreeModel<RadioItem> {
|
||||
}
|
||||
|
||||
// This is special because Player needs it for scrobbling
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
LastFMService* GetLastFMService() const;
|
||||
#endif
|
||||
|
||||
// QAbstractItemModel
|
||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||
|
@ -18,18 +18,23 @@
|
||||
#include "artistinfoview.h"
|
||||
#include "echonestbiographies.h"
|
||||
#include "echonestimages.h"
|
||||
#include "echonestsimilarartists.h"
|
||||
#include "echonesttags.h"
|
||||
#include "songinfofetcher.h"
|
||||
#include "widgets/prettyimageview.h"
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
#include "echonestsimilarartists.h"
|
||||
#include "echonesttags.h"
|
||||
#endif
|
||||
|
||||
ArtistInfoView::ArtistInfoView(QWidget *parent)
|
||||
: SongInfoBase(parent)
|
||||
{
|
||||
fetcher_->AddProvider(new EchoNestBiographies);
|
||||
fetcher_->AddProvider(new EchoNestImages);
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
fetcher_->AddProvider(new EchoNestSimilarArtists);
|
||||
fetcher_->AddProvider(new EchoNestTags);
|
||||
#endif
|
||||
}
|
||||
|
||||
ArtistInfoView::~ArtistInfoView() {
|
||||
|
@ -15,12 +15,16 @@
|
||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "lastfmtrackinfoprovider.h"
|
||||
#include "config.h"
|
||||
#include "songinfoprovider.h"
|
||||
#include "songinfoview.h"
|
||||
#include "ultimatelyricsprovider.h"
|
||||
#include "ultimatelyricsreader.h"
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
#include "lastfmtrackinfoprovider.h"
|
||||
#endif
|
||||
|
||||
#include <QFuture>
|
||||
#include <QFutureWatcher>
|
||||
#include <QSettings>
|
||||
@ -42,7 +46,9 @@ SongInfoView::SongInfoView(QWidget* parent)
|
||||
watcher->setFuture(future);
|
||||
connect(watcher, SIGNAL(finished()), SLOT(UltimateLyricsParsed()));
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
fetcher_->AddProvider(new LastfmTrackInfoProvider);
|
||||
#endif
|
||||
}
|
||||
|
||||
SongInfoView::~SongInfoView() {
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "playlist/songloaderinserter.h"
|
||||
#include "playlist/songplaylistitem.h"
|
||||
#include "playlistparsers/playlistparser.h"
|
||||
#include "radio/lastfmservice.h"
|
||||
#include "radio/magnatuneservice.h"
|
||||
#include "radio/radiomodel.h"
|
||||
#include "radio/radioview.h"
|
||||
@ -63,13 +62,9 @@
|
||||
#include "transcoder/transcodedialog.h"
|
||||
#include "ui/about.h"
|
||||
#include "ui/addstreamdialog.h"
|
||||
#include "ui/albumcovermanager.h"
|
||||
#include "ui/edittagdialog.h"
|
||||
#include "ui/equalizer.h"
|
||||
#include "ui/iconloader.h"
|
||||
#ifdef Q_OS_DARWIN
|
||||
#include "ui/macsystemtrayicon.h"
|
||||
#endif
|
||||
#include "ui/organisedialog.h"
|
||||
#include "ui/organiseerrordialog.h"
|
||||
#include "ui/qtsystemtrayicon.h"
|
||||
@ -82,6 +77,15 @@
|
||||
#include "widgets/stylehelper.h"
|
||||
#include "widgets/trackslider.h"
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
# include "ui/macsystemtrayicon.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
# include "radio/lastfmservice.h"
|
||||
# include "ui/albumcovermanager.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WIIMOTEDEV
|
||||
# include "wiimotedev/shortcuts.h"
|
||||
#endif
|
||||
@ -148,7 +152,9 @@ MainWindow::MainWindow(Engine::Type engine, QWidget *parent)
|
||||
song_info_view_(new SongInfoView(this)),
|
||||
artist_info_view_(new ArtistInfoView(this)),
|
||||
settings_dialog_(NULL),
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
cover_manager_(NULL),
|
||||
#endif
|
||||
equalizer_(new Equalizer),
|
||||
error_dialog_(NULL),
|
||||
organise_dialog_(new OrganiseDialog(task_manager_)),
|
||||
@ -174,7 +180,11 @@ MainWindow::MainWindow(Engine::Type engine, QWidget *parent)
|
||||
|
||||
// Create stuff that needs the database
|
||||
radio_model_ = new RadioModel(database_, task_manager_, this);
|
||||
player_ = new Player(this, playlists_, radio_model_->GetLastFMService(), engine, this);
|
||||
player_ = new Player(this, playlists_,
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
radio_model_->GetLastFMService(),
|
||||
#endif
|
||||
engine, this);
|
||||
library_ = new Library(database_, task_manager_, this);
|
||||
devices_ = new DeviceManager(database_, task_manager_, this);
|
||||
|
||||
@ -286,8 +296,10 @@ MainWindow::MainWindow(Engine::Type engine, QWidget *parent)
|
||||
connect(ui_->action_quit, SIGNAL(triggered()), qApp, SLOT(quit()));
|
||||
connect(ui_->action_stop_after_this_track, SIGNAL(triggered()), SLOT(StopAfterCurrent()));
|
||||
connect(ui_->action_mute, SIGNAL(triggered()), player_, SLOT(Mute()));
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
connect(ui_->action_ban, SIGNAL(triggered()), radio_model_->GetLastFMService(), SLOT(Ban()));
|
||||
connect(ui_->action_love, SIGNAL(triggered()), SLOT(Love()));
|
||||
#endif
|
||||
connect(ui_->action_clear_playlist, SIGNAL(triggered()), playlists_, SLOT(ClearCurrent()));
|
||||
connect(ui_->action_remove_from_playlist, SIGNAL(triggered()), SLOT(PlaylistRemoveCurrent()));
|
||||
connect(ui_->action_edit_track, SIGNAL(triggered()), SLOT(EditTracks()));
|
||||
@ -302,7 +314,11 @@ MainWindow::MainWindow(Engine::Type engine, QWidget *parent)
|
||||
connect(ui_->action_add_file, SIGNAL(triggered()), SLOT(AddFile()));
|
||||
connect(ui_->action_add_folder, SIGNAL(triggered()), SLOT(AddFolder()));
|
||||
connect(ui_->action_add_stream, SIGNAL(triggered()), SLOT(AddStream()));
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
connect(ui_->action_cover_manager, SIGNAL(triggered()), SLOT(ShowCoverManager()));
|
||||
#else
|
||||
ui_->action_cover_manager->setVisible(false);
|
||||
#endif
|
||||
connect(ui_->action_equalizer, SIGNAL(triggered()), equalizer_.get(), SLOT(show()));
|
||||
connect(ui_->action_transcode, SIGNAL(triggered()), SLOT(ShowTranscodeDialog()));
|
||||
connect(ui_->action_jump, SIGNAL(triggered()), ui_->playlist->view(), SLOT(JumpToCurrentlyPlayingTrack()));
|
||||
@ -452,12 +468,18 @@ MainWindow::MainWindow(Engine::Type engine, QWidget *parent)
|
||||
connect(radio_model_, SIGNAL(OpenSettingsAtPage(SettingsDialog::Page)), SLOT(OpenSettingsDialogAtPage(SettingsDialog::Page)));
|
||||
connect(radio_model_, SIGNAL(AddItemToPlaylist(RadioItem*,bool)), SLOT(InsertRadioItem(RadioItem*,bool)));
|
||||
connect(radio_model_, SIGNAL(AddItemsToPlaylist(PlaylistItemList,bool)), SLOT(InsertRadioItems(PlaylistItemList,bool)));
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
connect(radio_model_->GetLastFMService(), SIGNAL(ScrobblingEnabledChanged(bool)), SLOT(ScrobblingEnabledChanged(bool)));
|
||||
connect(radio_model_->GetLastFMService(), SIGNAL(ButtonVisibilityChanged(bool)), SLOT(LastFMButtonVisibilityChanged(bool)));
|
||||
#endif
|
||||
connect(radio_view_->tree(), SIGNAL(doubleClicked(QModelIndex)), SLOT(RadioDoubleClick(QModelIndex)));
|
||||
connect(radio_model_->Service<MagnatuneService>(), SIGNAL(DownloadFinished(QStringList)), osd_, SLOT(MagnatuneDownloadFinished(QStringList)));
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
LastFMButtonVisibilityChanged(radio_model_->GetLastFMService()->AreButtonsVisible());
|
||||
#else
|
||||
LastFMButtonVisibilityChanged(false);
|
||||
#endif
|
||||
|
||||
// Connections to the saved streams service
|
||||
connect(RadioModel::Service<SavedRadio>(), SIGNAL(ShowAddStreamDialog()), SLOT(AddStream()));
|
||||
@ -769,6 +791,7 @@ void MainWindow::MediaPlaying() {
|
||||
ui_->action_play_pause->setEnabled(
|
||||
! (player_->GetCurrentItem()->options() & PlaylistItem::PauseDisabled));
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
bool is_lastfm = (player_->GetCurrentItem()->options() & PlaylistItem::LastFMControls);
|
||||
LastFMService* lastfm = radio_model_->GetLastFMService();
|
||||
|
||||
@ -776,6 +799,9 @@ void MainWindow::MediaPlaying() {
|
||||
ui_->action_love->setEnabled(lastfm->IsScrobblingEnabled());
|
||||
|
||||
ui_->track_slider->SetCanSeek(!is_lastfm);
|
||||
#else
|
||||
ui_->track_slider->SetCanSeek(true);
|
||||
#endif
|
||||
|
||||
track_position_timer_->start();
|
||||
UpdateTrackPosition();
|
||||
@ -804,6 +830,7 @@ void MainWindow::TrackSkipped(PlaylistItemPtr item) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void MainWindow::ScrobblingEnabledChanged(bool value) {
|
||||
if (!player_->GetState() == Engine::Idle)
|
||||
return;
|
||||
@ -812,6 +839,7 @@ void MainWindow::ScrobblingEnabledChanged(bool value) {
|
||||
ui_->action_ban->setEnabled(value && is_lastfm);
|
||||
ui_->action_love->setEnabled(value);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::LastFMButtonVisibilityChanged(bool value) {
|
||||
ui_->action_ban->setVisible(value);
|
||||
@ -957,11 +985,12 @@ void MainWindow::UpdateTrackPosition() {
|
||||
}
|
||||
|
||||
// Time to scrobble?
|
||||
LastFMService* lastfm = radio_model_->GetLastFMService();
|
||||
|
||||
if (!playlists_->active()->has_scrobbled() &&
|
||||
position >= playlists_->active()->scrobble_point()) {
|
||||
lastfm->Scrobble();
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
radio_model_->GetLastFMService()->Scrobble();
|
||||
#endif
|
||||
playlists_->active()->set_scrobbled(true);
|
||||
|
||||
// Update the play count for the song if it's from the library
|
||||
@ -979,10 +1008,12 @@ void MainWindow::UpdateTrackPosition() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void MainWindow::Love() {
|
||||
radio_model_->GetLastFMService()->Love();
|
||||
ui_->action_love->setEnabled(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::RadioDoubleClick(const QModelIndex& index) {
|
||||
if (autoclear_playlist_)
|
||||
@ -1586,6 +1617,7 @@ void MainWindow::PlaylistCopyToDevice() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void MainWindow::ShowCoverManager() {
|
||||
if (!cover_manager_) {
|
||||
cover_manager_.reset(new AlbumCoverManager(library_->backend()));
|
||||
@ -1599,6 +1631,7 @@ void MainWindow::ShowCoverManager() {
|
||||
|
||||
cover_manager_->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::EnsureSettingsDialogCreated() {
|
||||
if (settings_dialog_)
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
class About;
|
||||
class AddStreamDialog;
|
||||
class AlbumCoverManager;
|
||||
class ArtistInfoView;
|
||||
class BackgroundStreams;
|
||||
class CommandlineOptions;
|
||||
@ -70,6 +69,10 @@ class Ui_MainWindow;
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
class AlbumCoverManager;
|
||||
#endif
|
||||
|
||||
class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
Q_OBJECT
|
||||
|
||||
@ -162,9 +165,11 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void RadioDoubleClick(const QModelIndex& index);
|
||||
void InsertRadioItem(RadioItem*, bool clear_first);
|
||||
void InsertRadioItems(const PlaylistItemList& items, bool clear_first);
|
||||
void ScrobblingEnabledChanged(bool value);
|
||||
void LastFMButtonVisibilityChanged(bool value);
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void ScrobblingEnabledChanged(bool value);
|
||||
void Love();
|
||||
#endif
|
||||
|
||||
void TaskCountChanged(int count);
|
||||
|
||||
@ -185,7 +190,9 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
void SongSaveComplete();
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void ShowCoverManager();
|
||||
#endif
|
||||
void ShowAboutDialog();
|
||||
void ShowTranscodeDialog();
|
||||
void ShowErrorDialog(const QString& message);
|
||||
@ -240,7 +247,9 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
boost::scoped_ptr<SettingsDialog> settings_dialog_;
|
||||
boost::scoped_ptr<AddStreamDialog> add_stream_dialog_;
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
boost::scoped_ptr<AlbumCoverManager> cover_manager_;
|
||||
#endif
|
||||
boost::scoped_ptr<Equalizer> equalizer_;
|
||||
boost::scoped_ptr<TranscodeDialog> transcode_dialog_;
|
||||
boost::scoped_ptr<ErrorDialog> error_dialog_;
|
||||
|
@ -28,6 +28,10 @@
|
||||
|
||||
#include "ui_settingsdialog.h"
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
#include "radio/lastfmconfig.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WIIMOTEDEV
|
||||
#include "ui/wiimotedevshortcutsconfig.h"
|
||||
#include "ui_wiimotedevshortcutsconfig.h"
|
||||
@ -95,6 +99,22 @@ SettingsDialog::SettingsDialog(BackgroundStreams* streams, QWidget* parent)
|
||||
pretty_popup_->SetMessage(tr("OSD Preview"), tr("Drag to reposition"),
|
||||
QImage(":nocover.png"));
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
ui_->list->insertItem(Page_Lastfm, tr("Last.fm"));
|
||||
ui_->list->item(Page_Lastfm)->setIcon(QIcon(":/last.fm/as.png"));
|
||||
|
||||
QWidget* lastfm_page = new QWidget;
|
||||
QVBoxLayout* lastfm_layout = new QVBoxLayout;
|
||||
lastfm_layout->setContentsMargins(0, 0, 0, 0);
|
||||
lastfm_config_ = new LastFMConfig;
|
||||
lastfm_layout->addWidget(lastfm_config_);
|
||||
lastfm_page->setLayout(lastfm_layout);
|
||||
|
||||
ui_->stacked_widget->insertWidget(Page_Lastfm, lastfm_page);
|
||||
|
||||
connect(lastfm_config_, SIGNAL(ValidationComplete(bool)), SLOT(LastFMValidationComplete(bool)));
|
||||
#endif
|
||||
|
||||
// Icons
|
||||
ui_->list->item(Page_Playback)->setIcon(IconLoader::Load("media-playback-start"));
|
||||
ui_->list->item(Page_SongInformation)->setIcon(IconLoader::Load("view-media-lyrics"));
|
||||
@ -177,9 +197,6 @@ SettingsDialog::SettingsDialog(BackgroundStreams* streams, QWidget* parent)
|
||||
}
|
||||
#endif
|
||||
|
||||
// Last.fm
|
||||
connect(ui_->lastfm, SIGNAL(ValidationComplete(bool)), SLOT(LastFMValidationComplete(bool)));
|
||||
|
||||
// List box
|
||||
connect(ui_->list, SIGNAL(currentTextChanged(QString)), SLOT(CurrentTextChanged(QString)));
|
||||
ui_->list->setCurrentRow(Page_Playback);
|
||||
@ -232,21 +249,25 @@ void SettingsDialog::SetGlobalShortcutManager(GlobalShortcuts *manager) {
|
||||
ui_->global_shortcuts->SetManager(manager);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void SettingsDialog::LastFMValidationComplete(bool success) {
|
||||
ui_->buttonBox->setEnabled(true);
|
||||
|
||||
if (success)
|
||||
accept();
|
||||
}
|
||||
#endif
|
||||
|
||||
void SettingsDialog::accept() {
|
||||
if (ui_->lastfm->NeedsValidation()) {
|
||||
ui_->lastfm->Validate();
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
if (lastfm_config_->NeedsValidation()) {
|
||||
lastfm_config_->Validate();
|
||||
ui_->buttonBox->setEnabled(false);
|
||||
return;
|
||||
} else {
|
||||
ui_->lastfm->Save();
|
||||
lastfm_config_->Save();
|
||||
}
|
||||
#endif
|
||||
|
||||
QSettings s;
|
||||
|
||||
@ -399,7 +420,9 @@ void SettingsDialog::showEvent(QShowEvent*) {
|
||||
ui_->lyric_settings->Load();
|
||||
|
||||
// Last.fm
|
||||
ui_->lastfm->Load();
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
lastfm_config_->Load();
|
||||
#endif
|
||||
|
||||
// Magnatune
|
||||
ui_->magnatune->Load();
|
||||
|
@ -35,6 +35,9 @@ class OSDPretty;
|
||||
class SongInfoView;
|
||||
class Ui_SettingsDialog;
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
class LastFMConfig;
|
||||
#endif
|
||||
#ifdef ENABLE_WIIMOTEDEV
|
||||
class WiimotedevShortcutsConfig;
|
||||
#endif
|
||||
@ -55,7 +58,9 @@ class SettingsDialog : public QDialog {
|
||||
Page_GlobalShortcuts,
|
||||
Page_Notifications,
|
||||
Page_Library,
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
Page_Lastfm,
|
||||
#endif
|
||||
Page_Magnatune,
|
||||
Page_BackgroundStreams,
|
||||
#ifdef ENABLE_WIIMOTEDEV
|
||||
@ -85,7 +90,9 @@ class SettingsDialog : public QDialog {
|
||||
private slots:
|
||||
void CurrentTextChanged(const QString& text);
|
||||
void NotificationTypeChanged();
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
void LastFMValidationComplete(bool success);
|
||||
#endif
|
||||
|
||||
void PrettyOpacityChanged(int value);
|
||||
void PrettyColorPresetChanged(int index);
|
||||
@ -105,6 +112,9 @@ class SettingsDialog : public QDialog {
|
||||
void StreamVolumeChanged(int value);
|
||||
|
||||
private:
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
LastFMConfig* lastfm_config_;
|
||||
#endif
|
||||
#ifdef ENABLE_WIIMOTEDEV
|
||||
WiimotedevShortcutsConfig* wiimotedev_config_;
|
||||
#endif
|
||||
|
@ -84,15 +84,6 @@
|
||||
<string>Music Library</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Last.fm</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../data/data.qrc">
|
||||
<normaloff>:/last.fm/as.png</normaloff>:/last.fm/as.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Magnatune</string>
|
||||
@ -777,16 +768,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="lastfm_page">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="LastFMConfig" name="lastfm" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="magnatune_page">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||
<property name="spacing">
|
||||
@ -850,12 +831,6 @@
|
||||
<extends>QLineEdit</extends>
|
||||
<header>widgets/lineedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LastFMConfig</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>radio/lastfmconfig.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LibraryConfig</class>
|
||||
<extends>QWidget</extends>
|
||||
|
Loading…
x
Reference in New Issue
Block a user