Play in last.fm context menu
This commit is contained in:
parent
9608e8fb32
commit
bfc81e4d5c
|
@ -42,8 +42,11 @@ LastFMService::LastFMService(QObject* parent)
|
|||
config_->ui_.username->setText(lastfm::ws::Username);
|
||||
config_->ui_.scrobble->setEnabled(scrobbling_enabled_);
|
||||
|
||||
play_action_ = context_menu_->addAction(QIcon(":media-playback-start.png"), "Add to playlist", this, SLOT(AddToPlaylist()));
|
||||
context_menu_->addSeparator();
|
||||
context_menu_->addAction(QIcon(":configure.png"), "Configure Last.fm...",
|
||||
config_, SLOT(show()));
|
||||
|
||||
}
|
||||
|
||||
LastFMService::~LastFMService() {
|
||||
|
@ -365,7 +368,10 @@ void LastFMService::Ban() {
|
|||
LoadNext(last_url_);
|
||||
}
|
||||
|
||||
void LastFMService::ShowContextMenu(RadioItem *, const QPoint &global_pos) {
|
||||
void LastFMService::ShowContextMenu(RadioItem* item, const QPoint &global_pos) {
|
||||
context_item_ = item;
|
||||
|
||||
play_action_->setEnabled(item->playable);
|
||||
context_menu_->popup(global_pos);
|
||||
}
|
||||
|
||||
|
@ -434,3 +440,7 @@ void LastFMService::RefreshNeighboursFinished() {
|
|||
item->InsertNotify(neighbours_list_);
|
||||
}
|
||||
}
|
||||
|
||||
void LastFMService::AddToPlaylist() {
|
||||
emit AddItemToPlaylist(context_item_);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <lastfm/RadioTuner>
|
||||
|
||||
class QMenu;
|
||||
class QAction;
|
||||
|
||||
class LastFMConfig;
|
||||
|
||||
|
@ -78,6 +79,8 @@ class LastFMService : public RadioService {
|
|||
void TunerTrackAvailable();
|
||||
void TunerError(lastfm::ws::Error error);
|
||||
|
||||
void AddToPlaylist();
|
||||
|
||||
private:
|
||||
RadioItem* CreateStationItem(ItemType type, const QString& name,
|
||||
const QString& icon, RadioItem* parent);
|
||||
|
@ -93,7 +96,10 @@ class LastFMService : public RadioService {
|
|||
lastfm::Track last_track_;
|
||||
|
||||
LastFMConfig* config_;
|
||||
|
||||
QMenu* context_menu_;
|
||||
QAction* play_action_;
|
||||
RadioItem* context_item_;
|
||||
|
||||
QUrl last_url_;
|
||||
bool initial_tune_;
|
||||
|
|
|
@ -156,6 +156,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(radio_model_, SIGNAL(StreamFinished()), player_, SLOT(Next()));
|
||||
connect(radio_model_, SIGNAL(StreamReady(QUrl,QUrl)), player_, SLOT(StreamReady(QUrl,QUrl)));
|
||||
connect(radio_model_, SIGNAL(StreamMetadataFound(QUrl,Song)), playlist_, SLOT(SetStreamMetadata(QUrl,Song)));
|
||||
connect(radio_model_, SIGNAL(AddItemToPlaylist(RadioItem*)), SLOT(InsertRadioItem(RadioItem*)));
|
||||
connect(radio_model_->GetLastFMService(), SIGNAL(ScrobblingEnabledChanged(bool)), SLOT(ScrobblingEnabledChanged(bool)));
|
||||
connect(ui_.radio_view, SIGNAL(doubleClicked(QModelIndex)), SLOT(RadioDoubleClick(QModelIndex)));
|
||||
|
||||
|
@ -363,8 +364,12 @@ void MainWindow::Love() {
|
|||
}
|
||||
|
||||
void MainWindow::RadioDoubleClick(const QModelIndex& index) {
|
||||
InsertRadioItem(radio_model_->IndexToItem(index));
|
||||
}
|
||||
|
||||
void MainWindow::InsertRadioItem(RadioItem* item) {
|
||||
QModelIndex first_song = playlist_->InsertRadioStations(
|
||||
QList<RadioItem*>() << radio_model_->IndexToItem(index));
|
||||
QList<RadioItem*>() << item);
|
||||
|
||||
if (first_song.isValid() && player_->GetState() != Engine::Playing)
|
||||
player_->PlayAt(first_song.row());
|
||||
|
|
|
@ -12,6 +12,7 @@ class Library;
|
|||
class LibraryConfig;
|
||||
class RadioModel;
|
||||
class Song;
|
||||
class RadioItem;
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
class SystemTrayIcon;
|
||||
|
@ -50,6 +51,7 @@ class MainWindow : public QMainWindow {
|
|||
void UpdateTrackPosition();
|
||||
|
||||
void RadioDoubleClick(const QModelIndex& index);
|
||||
void InsertRadioItem(RadioItem*);
|
||||
void ScrobblingEnabledChanged(bool value);
|
||||
void Love();
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ void RadioModel::AddService(RadioService *service) {
|
|||
connect(service, SIGNAL(StreamFinished()), SIGNAL(StreamFinished()));
|
||||
connect(service, SIGNAL(StreamError(QString)), SIGNAL(StreamError(QString)));
|
||||
connect(service, SIGNAL(StreamMetadataFound(QUrl,Song)), SIGNAL(StreamMetadataFound(QUrl,Song)));
|
||||
connect(service, SIGNAL(AddItemToPlaylist(RadioItem*)), SIGNAL(AddItemToPlaylist(RadioItem*)));
|
||||
}
|
||||
|
||||
RadioService* RadioModel::ServiceByName(const QString& name) {
|
||||
|
|
|
@ -42,6 +42,8 @@ class RadioModel : public SimpleTreeModel<RadioItem> {
|
|||
void StreamError(const QString& message);
|
||||
void StreamMetadataFound(const QUrl& original_url, const Song& song);
|
||||
|
||||
void AddItemToPlaylist(RadioItem* item);
|
||||
|
||||
protected:
|
||||
void LazyPopulate(RadioItem* parent);
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ class RadioService : public QObject {
|
|||
void StreamError(const QString& message);
|
||||
void StreamMetadataFound(const QUrl& original_url, const Song& song);
|
||||
|
||||
void AddItemToPlaylist(RadioItem* item);
|
||||
|
||||
private:
|
||||
QString name_;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue