MainWindow: Delay command line options until playlists are loaded
Fixes #1546
This commit is contained in:
@@ -401,6 +401,7 @@ MainWindow::MainWindow(Application *app,
|
||||
was_minimized_(false),
|
||||
exit_(false),
|
||||
exit_count_(0),
|
||||
playlists_loaded_(false),
|
||||
delete_files_(false) {
|
||||
|
||||
qLog(Debug) << "Starting";
|
||||
@@ -667,7 +668,7 @@ MainWindow::MainWindow(Application *app,
|
||||
QObject::connect(&*app_->player(), &Player::Playing, playlist_list_, &PlaylistListContainer::ActivePlaying);
|
||||
QObject::connect(&*app_->player(), &Player::Stopped, playlist_list_, &PlaylistListContainer::ActiveStopped);
|
||||
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::AllPlaylistsLoaded, &*app->player(), &Player::PlaylistsLoaded);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::AllPlaylistsLoaded, this, &MainWindow::PlaylistsLoaded);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &MainWindow::SongChanged);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, &*app_->player(), &Player::CurrentMetadataChanged);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::EditingFinished, this, &MainWindow::PlaylistEditFinished);
|
||||
@@ -1408,6 +1409,19 @@ void MainWindow::ExitFinished() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistsLoaded() {
|
||||
|
||||
playlists_loaded_ = true;
|
||||
|
||||
if (options_.has_value()) {
|
||||
CommandlineOptionsReceived(options_.value());
|
||||
options_.reset();
|
||||
}
|
||||
|
||||
app_->player()->PlaylistsLoaded();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::MediaStopped() {
|
||||
|
||||
setWindowTitle(u"Strawberry Music Player"_s);
|
||||
@@ -2463,6 +2477,11 @@ void MainWindow::CommandlineOptionsReceived(const QByteArray &string_options) {
|
||||
|
||||
void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
|
||||
if (!playlists_loaded_) {
|
||||
options_ = options;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (options.player_action()) {
|
||||
case CommandlineOptions::PlayerAction::Play:
|
||||
if (options.urls().empty()) {
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
@@ -52,6 +54,7 @@
|
||||
#include "core/platforminterface.h"
|
||||
#include "core/song.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/commandlineoptions.h"
|
||||
#include "tagreader/tagreaderclient.h"
|
||||
#include "osd/osdbase.h"
|
||||
#include "playlist/playlist.h"
|
||||
@@ -144,6 +147,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void AuthorizationUrlReceived(const QUrl &url);
|
||||
|
||||
private Q_SLOTS:
|
||||
void PlaylistsLoaded();
|
||||
|
||||
void FilePathChanged(const QString &path);
|
||||
|
||||
void MediaStopped();
|
||||
@@ -412,7 +417,9 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
AlbumCoverImageResult album_cover_;
|
||||
bool exit_;
|
||||
int exit_count_;
|
||||
bool playlists_loaded_;
|
||||
bool delete_files_;
|
||||
std::optional<CommandlineOptions> options_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user