Make "Add and play now" work

This commit is contained in:
David Sansome 2011-09-18 23:26:21 +01:00
parent b45c5a866e
commit e10efbc484
3 changed files with 18 additions and 10 deletions

View File

@ -26,20 +26,24 @@ class MimeData : public QMimeData {
public:
MimeData(bool clear = false, bool play_now = false,
bool enqueue = false, bool open_in_new_playlist = false)
: clear_first_(clear),
: override_user_settings_(false),
clear_first_(clear),
play_now_(play_now),
enqueue_now_(enqueue),
open_in_new_playlist_(open_in_new_playlist),
name_for_new_playlist_(QString()),
from_doubleclick_(false) {}
// If this is set then MainWindow will not touch any of the other flags.
bool override_user_settings_;
// If this is set then the playlist will be cleared before these songs
// are inserted.
bool clear_first_;
// If this is set then the first item that is inserted will start playing
// immediately. Note: this is always overridden with the user's preference
// if the MimeData goes via MainWindow.
// if the MimeData goes via MainWindow, unless you set override_user_settings_.
bool play_now_;
// If this is set then the items are added to the queue after being inserted.

View File

@ -498,13 +498,15 @@ void GlobalSearchWidget::TracksLoaded(int id, MimeData* mime_data) {
if (trigger == NULL) {
mime_data->from_doubleclick_ = true;
} else if (trigger == add_) {
} else if (trigger == add_and_play_) {
mime_data->play_now_ = true;
} else if (trigger == add_and_queue_) {
mime_data->enqueue_now_ = true;
} else if (trigger == replace_) {
mime_data->clear_first_= true;
} else {
if (trigger == add_and_play_) {
mime_data->override_user_settings_ = true;
mime_data->play_now_ = true;
} else if (trigger == add_and_queue_) {
mime_data->enqueue_now_ = true;
} else if (trigger == replace_) {
mime_data->clear_first_= true;
}
}
emit AddToPlaylist(mime_data);

View File

@ -1180,7 +1180,9 @@ void MainWindow::AddToPlaylist(QMimeData* data) {
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
// Should we replace the flags with the user's preference?
if (mime_data->from_doubleclick_) {
if (mime_data->override_user_settings_) {
// Do nothing
} else if (mime_data->from_doubleclick_) {
ApplyAddBehaviour(doubleclick_addmode_, mime_data);
ApplyPlayBehaviour(doubleclick_playmode_, mime_data);
} else {