diff --git a/src/networkremote/networkremote.cpp b/src/networkremote/networkremote.cpp index 4728ff3f1..38aa955fd 100644 --- a/src/networkremote/networkremote.cpp +++ b/src/networkremote/networkremote.cpp @@ -217,3 +217,13 @@ void NetworkRemote::CreateRemoteClient(QTcpSocket* client_socket) { incoming_data_parser_.get(), SLOT(Parse(pb::remote::Message))); } } + +void NetworkRemote::EnableKittens(bool aww) { + if (outgoing_data_creator_.get()) + outgoing_data_creator_->EnableKittens(aww); +} + +void NetworkRemote::SendKitten(quint64 id, const QImage &kitten) { + if (outgoing_data_creator_.get()) + outgoing_data_creator_->SendKitten(kitten); +} diff --git a/src/networkremote/networkremote.h b/src/networkremote/networkremote.h index 60b85e8d1..5de164eb3 100644 --- a/src/networkremote/networkremote.h +++ b/src/networkremote/networkremote.h @@ -26,6 +26,8 @@ public slots: void StartServer(); void ReloadSettings(); void AcceptConnection(); + void EnableKittens(bool aww); + void SendKitten(quint64 id, const QImage& kitten); private: boost::scoped_ptr server_; diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index ce28beb4a..0c1fab7e6 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -33,6 +33,7 @@ const quint32 OutgoingDataCreator::kFileChunkSize = 100000; // in Bytes OutgoingDataCreator::OutgoingDataCreator(Application* app) : app_(app), + aww_(false), ultimate_reader_(new UltimateLyricsReader(this)), fetcher_(new SongInfoFetcher(this)) { @@ -314,21 +315,26 @@ void OutgoingDataCreator::SendFirstData(bool send_playlist_songs) { void OutgoingDataCreator::CurrentSongChanged(const Song& song, const QString& uri, const QImage& img) { current_song_ = song; current_uri_ = uri; - current_image_ = img; - if (!clients_->empty()) { - // Create the message - pb::remote::Message msg; - msg.set_type(pb::remote::CURRENT_METAINFO); - - // If there is no song, create an empty node, otherwise fill it with data - int i = app_->playlist_manager()->active()->current_row(); - CreateSong( - current_song_, img, i, - msg.mutable_response_current_metadata()->mutable_song_metadata()); - - SendDataToClients(&msg); + if (!aww_) { + current_image_ = img; } + + SendSongMetadata(); +} + +void OutgoingDataCreator::SendSongMetadata() { + // Create the message + pb::remote::Message msg; + msg.set_type(pb::remote::CURRENT_METAINFO); + + // If there is no song, create an empty node, otherwise fill it with data + int i = app_->playlist_manager()->active()->current_row(); + CreateSong( + current_song_, current_image_, i, + msg.mutable_response_current_metadata()->mutable_song_metadata()); + + SendDataToClients(&msg); } void OutgoingDataCreator::CreateSong( @@ -774,3 +780,15 @@ void OutgoingDataCreator::SendLibrary(RemoteClient *client) { // Remove temporary file file.remove(); } + +void OutgoingDataCreator::EnableKittens(bool aww) { + aww_ = aww; +} + +void OutgoingDataCreator::SendKitten(const QImage& kitten) { + if (aww_) { + current_image_ = kitten; + SendSongMetadata(); + } +} + diff --git a/src/networkremote/outgoingdatacreator.h b/src/networkremote/outgoingdatacreator.h index 270835a0e..264da2add 100644 --- a/src/networkremote/outgoingdatacreator.h +++ b/src/networkremote/outgoingdatacreator.h @@ -62,6 +62,7 @@ public slots: void PlaylistRenamed(int id, const QString& new_name); void ActiveChanged(Playlist*); void CurrentSongChanged(const Song& song, const QString& uri, const QImage& img); + void SendSongMetadata(); void StateChanged(Engine::State); void SendKeepAlive(); void SendRepeatMode(PlaylistSequence::RepeatMode mode); @@ -73,6 +74,8 @@ public slots: void SendSongs(const pb::remote::RequestDownloadSongs& request, RemoteClient* client); void ResponseSongOffer(RemoteClient* client, bool accepted); void SendLibrary(RemoteClient* client); + void EnableKittens(bool aww); + void SendKitten(const QImage& kitten); private: Application* app_; @@ -86,6 +89,7 @@ private: int keep_alive_timeout_; QMap > download_queue_; int last_track_position_; + bool aww_; boost::scoped_ptr ultimate_reader_; ProviderList provider_list_; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index b4edfb485..1aa3bc0a9 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -58,6 +58,7 @@ #include "library/libraryfilterwidget.h" #include "library/libraryviewcontainer.h" #include "musicbrainz/tagfetcher.h" +#include "networkremote/networkremote.h" #include "playlist/playlistbackend.h" #include "playlist/playlist.h" #include "playlist/playlistlistcontainer.h" @@ -670,6 +671,7 @@ MainWindow::MainWindow(Application* app, SLOT(NowPlayingWidgetPositionChanged(bool))); connect(ui_->action_hypnotoad, SIGNAL(toggled(bool)), ui_->now_playing, SLOT(AllHail(bool))); connect(ui_->action_kittens, SIGNAL(toggled(bool)), ui_->now_playing, SLOT(EnableKittens(bool))); + connect(ui_->action_kittens, SIGNAL(toggled(bool)), app_->network_remote(), SLOT(EnableKittens(bool))); // Hide the console //connect(ui_->action_console, SIGNAL(triggered()), SLOT(ShowConsole())); NowPlayingWidgetPositionChanged(ui_->now_playing->show_above_status_bar()); diff --git a/src/widgets/nowplayingwidget.cpp b/src/widgets/nowplayingwidget.cpp index 5b06a8563..29d81eb6f 100644 --- a/src/widgets/nowplayingwidget.cpp +++ b/src/widgets/nowplayingwidget.cpp @@ -23,6 +23,7 @@ #include "covers/currentartloader.h" #include "covers/kittenloader.h" #include "library/librarybackend.h" +#include "networkremote/networkremote.h" #include "ui/albumcoverchoicecontroller.h" #include "ui/iconloader.h" @@ -423,6 +424,7 @@ void NowPlayingWidget::EnableKittens(bool aww) { kittens_ = new KittenLoader(this); app_->MoveToNewThread(kittens_); connect(kittens_, SIGNAL(ImageLoaded(quint64,QImage)), SLOT(KittenLoaded(quint64,QImage))); + connect(kittens_, SIGNAL(ImageLoaded(quint64,QImage)), app_->network_remote(), SLOT(SendKitten(quint64,QImage))); } aww_ = aww;