Fix playlist behaviour (#5330)
* Do not restore playback state on application start if overwritten by command line options This also fixes unwanted pausing if a new instance is started with commandline URL combined with playback restore. Note that the actual buggy code (MainWindow::ResumePlayback()) is not fixed here. * Fix for commandline URLs for new instances are always appended to playlist.
This commit is contained in:
parent
75d7179dd7
commit
11670e1760
|
@ -299,6 +299,11 @@ bool CommandlineOptions::is_empty() const {
|
|||
toggle_pretty_osd_ == false && urls_.isEmpty();
|
||||
}
|
||||
|
||||
bool CommandlineOptions::contains_play_options() const {
|
||||
return player_action_ != Player_None || play_track_at_ != -1 ||
|
||||
!urls_.isEmpty();
|
||||
}
|
||||
|
||||
QByteArray CommandlineOptions::Serialize() const {
|
||||
QBuffer buf;
|
||||
buf.open(QIODevice::WriteOnly);
|
||||
|
|
|
@ -60,6 +60,7 @@ class CommandlineOptions {
|
|||
bool Parse();
|
||||
|
||||
bool is_empty() const;
|
||||
bool contains_play_options() const;
|
||||
|
||||
UrlListAction url_list_action() const { return url_list_action_; }
|
||||
PlayerAction player_action() const { return player_action_; }
|
||||
|
|
|
@ -462,7 +462,7 @@ int main(int argc, char* argv[]) {
|
|||
#endif
|
||||
|
||||
// Window
|
||||
MainWindow w(&app, tray_icon.get(), &osd);
|
||||
MainWindow w(&app, tray_icon.get(), &osd, options);
|
||||
#ifdef Q_OS_DARWIN
|
||||
mac::EnableFullScreen(w);
|
||||
#endif // Q_OS_DARWIN
|
||||
|
@ -474,7 +474,6 @@ int main(int argc, char* argv[]) {
|
|||
#endif
|
||||
QObject::connect(&a, SIGNAL(messageReceived(QByteArray)), &w,
|
||||
SLOT(CommandlineOptionsReceived(QByteArray)));
|
||||
w.CommandlineOptionsReceived(options);
|
||||
|
||||
int ret = a.exec();
|
||||
|
||||
|
|
|
@ -118,7 +118,8 @@ Playlist::Playlist(PlaylistBackend* backend, TaskManager* task_manager,
|
|||
playlist_sequence_(nullptr),
|
||||
ignore_sorting_(false),
|
||||
undo_stack_(new QUndoStack(this)),
|
||||
special_type_(special_type) {
|
||||
special_type_(special_type),
|
||||
cancel_restore_(false) {
|
||||
undo_stack_->setUndoLimit(kUndoStackSize);
|
||||
|
||||
connect(this, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
|
||||
|
@ -1470,6 +1471,7 @@ void Playlist::Restore() {
|
|||
virtual_items_.clear();
|
||||
library_items_by_id_.clear();
|
||||
|
||||
cancel_restore_ = false;
|
||||
QFuture<QList<PlaylistItemPtr>> future =
|
||||
QtConcurrent::run(backend_, &PlaylistBackend::GetPlaylistItems, id_);
|
||||
NewClosure(future, this, SLOT(ItemsLoaded(QFuture<PlaylistItemList>)),
|
||||
|
@ -1477,6 +1479,9 @@ void Playlist::Restore() {
|
|||
}
|
||||
|
||||
void Playlist::ItemsLoaded(QFuture<PlaylistItemList> future) {
|
||||
if (cancel_restore_)
|
||||
return;
|
||||
|
||||
PlaylistItemList items = future.result();
|
||||
|
||||
// backend returns empty elements for library items which it couldn't
|
||||
|
@ -1749,6 +1754,9 @@ void Playlist::UpdateScrobblePoint(qint64 seek_point_nanosec) {
|
|||
}
|
||||
|
||||
void Playlist::Clear() {
|
||||
// If loading songs from session restore async, don't insert them
|
||||
cancel_restore_ = true;
|
||||
|
||||
const int count = items_.count();
|
||||
|
||||
if (count > kUndoItemLimit) {
|
||||
|
|
|
@ -443,6 +443,9 @@ signals:
|
|||
QList<SongInsertVetoListener*> veto_listeners_;
|
||||
|
||||
QString special_type_;
|
||||
|
||||
// Cancel async restore if songs are already replaced
|
||||
bool cancel_restore_;
|
||||
};
|
||||
|
||||
// QDataStream& operator <<(QDataStream&, const Playlist*);
|
||||
|
|
|
@ -165,7 +165,7 @@ const int kTrackPositionUpdateTimeMs = 1000;
|
|||
}
|
||||
|
||||
MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
QWidget* parent)
|
||||
const CommandlineOptions& options, QWidget* parent)
|
||||
: QMainWindow(parent),
|
||||
ui_(new Ui_MainWindow),
|
||||
thumbbar_(new Windows7ThumbBar(this)),
|
||||
|
@ -1038,7 +1038,10 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
|||
|
||||
CheckFullRescanRevisions();
|
||||
|
||||
LoadPlaybackStatus();
|
||||
CommandlineOptionsReceived(options);
|
||||
|
||||
if (!options.contains_play_options())
|
||||
LoadPlaybackStatus();
|
||||
|
||||
qLog(Debug) << "Started";
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
|||
|
||||
public:
|
||||
MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
QWidget* parent = nullptr);
|
||||
const CommandlineOptions& options, QWidget* parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
static const char* kSettingsGroup;
|
||||
|
|
Loading…
Reference in New Issue