Make "Add and play now" work
This commit is contained in:
parent
b45c5a866e
commit
e10efbc484
|
@ -26,20 +26,24 @@ class MimeData : public QMimeData {
|
||||||
public:
|
public:
|
||||||
MimeData(bool clear = false, bool play_now = false,
|
MimeData(bool clear = false, bool play_now = false,
|
||||||
bool enqueue = false, bool open_in_new_playlist = false)
|
bool enqueue = false, bool open_in_new_playlist = false)
|
||||||
: clear_first_(clear),
|
: override_user_settings_(false),
|
||||||
|
clear_first_(clear),
|
||||||
play_now_(play_now),
|
play_now_(play_now),
|
||||||
enqueue_now_(enqueue),
|
enqueue_now_(enqueue),
|
||||||
open_in_new_playlist_(open_in_new_playlist),
|
open_in_new_playlist_(open_in_new_playlist),
|
||||||
name_for_new_playlist_(QString()),
|
name_for_new_playlist_(QString()),
|
||||||
from_doubleclick_(false) {}
|
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
|
// If this is set then the playlist will be cleared before these songs
|
||||||
// are inserted.
|
// are inserted.
|
||||||
bool clear_first_;
|
bool clear_first_;
|
||||||
|
|
||||||
// If this is set then the first item that is inserted will start playing
|
// 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
|
// 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_;
|
bool play_now_;
|
||||||
|
|
||||||
// If this is set then the items are added to the queue after being inserted.
|
// If this is set then the items are added to the queue after being inserted.
|
||||||
|
|
|
@ -498,13 +498,15 @@ void GlobalSearchWidget::TracksLoaded(int id, MimeData* mime_data) {
|
||||||
|
|
||||||
if (trigger == NULL) {
|
if (trigger == NULL) {
|
||||||
mime_data->from_doubleclick_ = true;
|
mime_data->from_doubleclick_ = true;
|
||||||
} else if (trigger == add_) {
|
} else {
|
||||||
} else if (trigger == add_and_play_) {
|
if (trigger == add_and_play_) {
|
||||||
mime_data->play_now_ = true;
|
mime_data->override_user_settings_ = true;
|
||||||
} else if (trigger == add_and_queue_) {
|
mime_data->play_now_ = true;
|
||||||
mime_data->enqueue_now_ = true;
|
} else if (trigger == add_and_queue_) {
|
||||||
} else if (trigger == replace_) {
|
mime_data->enqueue_now_ = true;
|
||||||
mime_data->clear_first_= true;
|
} else if (trigger == replace_) {
|
||||||
|
mime_data->clear_first_= true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit AddToPlaylist(mime_data);
|
emit AddToPlaylist(mime_data);
|
||||||
|
|
|
@ -1180,7 +1180,9 @@ void MainWindow::AddToPlaylist(QMimeData* data) {
|
||||||
|
|
||||||
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
||||||
// Should we replace the flags with the user's preference?
|
// 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);
|
ApplyAddBehaviour(doubleclick_addmode_, mime_data);
|
||||||
ApplyPlayBehaviour(doubleclick_playmode_, mime_data);
|
ApplyPlayBehaviour(doubleclick_playmode_, mime_data);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue