Refactor some functions
This commit is contained in:
@@ -528,7 +528,6 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd
|
||||
connect(app_->player(), SIGNAL(Stopped()), SLOT(MediaStopped()));
|
||||
connect(app_->player(), SIGNAL(Seeked(qlonglong)), SLOT(Seeked(qlonglong)));
|
||||
connect(app_->player(), SIGNAL(TrackSkipped(PlaylistItemPtr)), SLOT(TrackSkipped(PlaylistItemPtr)));
|
||||
connect(this, SIGNAL(IntroPointReached()), app_->player(), SLOT(IntroPointReached()));
|
||||
connect(app_->player(), SIGNAL(VolumeChanged(int)), SLOT(VolumeChanged(int)));
|
||||
|
||||
connect(app_->player(), SIGNAL(Paused()), ui_->playlist, SLOT(ActivePaused()));
|
||||
@@ -1365,14 +1364,14 @@ void MainWindow::ResumePlaybackSeek(const int playback_position) {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::PlayIndex(const QModelIndex &index) {
|
||||
void MainWindow::PlayIndex(const QModelIndex &idx) {
|
||||
|
||||
if (!index.isValid()) return;
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
int row = index.row();
|
||||
if (index.model() == app_->playlist_manager()->current()->proxy()) {
|
||||
int row = idx.row();
|
||||
if (idx.model() == app_->playlist_manager()->current()->proxy()) {
|
||||
// The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model.
|
||||
row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
||||
row = app_->playlist_manager()->current()->proxy()->mapToSource(idx).row();
|
||||
}
|
||||
|
||||
app_->playlist_manager()->SetActiveToCurrent();
|
||||
@@ -1380,14 +1379,14 @@ void MainWindow::PlayIndex(const QModelIndex &index) {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistDoubleClick(const QModelIndex &index) {
|
||||
void MainWindow::PlaylistDoubleClick(const QModelIndex &idx) {
|
||||
|
||||
if (!index.isValid()) return;
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
int row = index.row();
|
||||
if (index.model() == app_->playlist_manager()->current()->proxy()) {
|
||||
int row = idx.row();
|
||||
if (idx.model() == app_->playlist_manager()->current()->proxy()) {
|
||||
// The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model.
|
||||
row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row();
|
||||
row = app_->playlist_manager()->current()->proxy()->mapToSource(idx).row();
|
||||
}
|
||||
|
||||
switch (doubleclick_playlist_addmode_) {
|
||||
@@ -1397,7 +1396,7 @@ void MainWindow::PlaylistDoubleClick(const QModelIndex &index) {
|
||||
break;
|
||||
|
||||
case BehaviourSettingsPage::PlaylistAddBehaviour_Enqueue:
|
||||
app_->playlist_manager()->current()->queue()->ToggleTracks(QModelIndexList() << index);
|
||||
app_->playlist_manager()->current()->queue()->ToggleTracks(QModelIndexList() << idx);
|
||||
if (app_->player()->GetState() != Engine::Playing) {
|
||||
app_->player()->PlayAt(app_->playlist_manager()->current()->queue()->TakeNext(), Engine::Manual, true);
|
||||
}
|
||||
@@ -1482,7 +1481,7 @@ void MainWindow::FilePathChanged(const QString &path) {
|
||||
settings_.setValue("file_path", path);
|
||||
}
|
||||
|
||||
void MainWindow::Seeked(qlonglong microseconds) {
|
||||
void MainWindow::Seeked(const qlonglong microseconds) {
|
||||
|
||||
const int position = microseconds / kUsecPerSec;
|
||||
const int length = app_->player()->GetCurrentItem()->Metadata().length_nanosec() / kNsecPerSec;
|
||||
@@ -1528,7 +1527,7 @@ void MainWindow::UpdateTrackSliderPosition() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const {
|
||||
void MainWindow::ApplyAddBehaviour(const BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const {
|
||||
|
||||
switch (b) {
|
||||
case BehaviourSettingsPage::AddBehaviour_Append:
|
||||
@@ -1552,7 +1551,7 @@ void MainWindow::ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeDa
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const {
|
||||
void MainWindow::ApplyPlayBehaviour(const BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const {
|
||||
|
||||
switch (b) {
|
||||
case BehaviourSettingsPage::PlayBehaviour_Always:
|
||||
@@ -1973,10 +1972,10 @@ void MainWindow::RenumberTracks() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &index) {
|
||||
void MainWindow::SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &idx) {
|
||||
|
||||
if (reply->is_successful() && index.isValid()) {
|
||||
app_->playlist_manager()->current()->ReloadItems(QList<int>()<< index.row());
|
||||
if (reply->is_successful() && idx.isValid()) {
|
||||
app_->playlist_manager()->current()->ReloadItems(QList<int>()<< idx.row());
|
||||
}
|
||||
reply->deleteLater();
|
||||
|
||||
@@ -2133,8 +2132,8 @@ void MainWindow::PlaylistClearCurrent() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistEditFinished(const QModelIndex &index) {
|
||||
if (index == playlist_menu_index_) SelectionSetValue();
|
||||
void MainWindow::PlaylistEditFinished(const QModelIndex &idx) {
|
||||
if (idx == playlist_menu_index_) SelectionSetValue();
|
||||
}
|
||||
|
||||
void MainWindow::CommandlineOptionsReceived(const quint32 instanceId, const QByteArray &string_options) {
|
||||
|
||||
@@ -100,14 +100,14 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd, const CommandlineOptions& options, QWidget *parent = nullptr);
|
||||
explicit MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd, const CommandlineOptions &options, QWidget *parent = nullptr);
|
||||
~MainWindow() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
static const char *kAllFilesFilterSpec;
|
||||
|
||||
void SetHiddenInTray(const bool hidden);
|
||||
void CommandlineOptionsReceived(const CommandlineOptions& options);
|
||||
void CommandlineOptionsReceived(const CommandlineOptions &options);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
@@ -120,7 +120,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
// PlatformInterface
|
||||
void Activate() override;
|
||||
bool LoadUrl(const QString& url) override;
|
||||
bool LoadUrl(const QString &url) override;
|
||||
|
||||
signals:
|
||||
void AlbumCoverReady(const Song &song, const QImage &image);
|
||||
@@ -128,23 +128,21 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
// Signals that stop playing after track was toggled.
|
||||
void StopAfterToggled(bool stop);
|
||||
|
||||
void IntroPointReached();
|
||||
|
||||
void AuthorizationUrlReceived(const QUrl &url);
|
||||
|
||||
private slots:
|
||||
void FilePathChanged(const QString& path);
|
||||
void FilePathChanged(const QString &path);
|
||||
|
||||
void EngineChanged(Engine::EngineType enginetype);
|
||||
void MediaStopped();
|
||||
void MediaPaused();
|
||||
void MediaPlaying();
|
||||
void TrackSkipped(PlaylistItemPtr item);
|
||||
void ForceShowOSD(const Song& song, const bool toggle);
|
||||
void ForceShowOSD(const Song &song, const bool toggle);
|
||||
|
||||
void PlaylistMenuHidden();
|
||||
void PlaylistRightClick(const QPoint& global_pos, const QModelIndex& index);
|
||||
void PlaylistCurrentChanged(const QModelIndex& current);
|
||||
void PlaylistRightClick(const QPoint &global_pos, const QModelIndex &index);
|
||||
void PlaylistCurrentChanged(const QModelIndex ¤t);
|
||||
void PlaylistViewSelectionModelChanged();
|
||||
void PlaylistPlay();
|
||||
void PlaylistStopAfter();
|
||||
@@ -152,7 +150,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void PlaylistQueuePlayNext();
|
||||
void PlaylistSkip();
|
||||
void PlaylistRemoveCurrent();
|
||||
void PlaylistEditFinished(const QModelIndex& index);
|
||||
void PlaylistEditFinished(const QModelIndex &idx);
|
||||
void PlaylistClearCurrent();
|
||||
void RescanSongs();
|
||||
void EditTracks();
|
||||
@@ -175,17 +173,17 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
void ChangeCollectionQueryMode(QAction *action);
|
||||
|
||||
void PlayIndex(const QModelIndex& index);
|
||||
void PlaylistDoubleClick(const QModelIndex& index);
|
||||
void PlayIndex(const QModelIndex &idx);
|
||||
void PlaylistDoubleClick(const QModelIndex &idx);
|
||||
void StopAfterCurrent();
|
||||
|
||||
void SongChanged(const Song& song);
|
||||
void SongChanged(const Song &song);
|
||||
void VolumeChanged(const int volume);
|
||||
|
||||
void CopyFilesToCollection(const QList<QUrl>& urls);
|
||||
void MoveFilesToCollection(const QList<QUrl>& urls);
|
||||
void CopyFilesToDevice(const QList<QUrl>& urls);
|
||||
void EditFileTags(const QList<QUrl>& urls);
|
||||
void CopyFilesToCollection(const QList<QUrl> &urls);
|
||||
void MoveFilesToCollection(const QList<QUrl> &urls);
|
||||
void CopyFilesToDevice(const QList<QUrl> &urls);
|
||||
void EditFileTags(const QList<QUrl> &urls);
|
||||
|
||||
void AddToPlaylist(QMimeData *q_mimedata);
|
||||
void AddToPlaylist(QAction *action);
|
||||
@@ -217,12 +215,12 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
void PlayingWidgetPositionChanged(const bool above_status_bar);
|
||||
|
||||
void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex& index);
|
||||
void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &idx);
|
||||
|
||||
void ShowCoverManager();
|
||||
|
||||
void ShowAboutDialog();
|
||||
void ShowErrorDialog(const QString& message);
|
||||
void ShowErrorDialog(const QString &message);
|
||||
void ShowTranscodeDialog();
|
||||
SettingsDialog *CreateSettingsDialog();
|
||||
EditTagDialog *CreateEditTagDialog();
|
||||
@@ -270,8 +268,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
void SaveSettings();
|
||||
|
||||
void ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const;
|
||||
void ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const;
|
||||
void ApplyAddBehaviour(const BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const;
|
||||
void ApplyPlayBehaviour(const BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const;
|
||||
|
||||
void CheckFullRescanRevisions();
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
|
||||
void Player::Next() { NextInternal(Engine::Manual); }
|
||||
|
||||
void Player::NextInternal(Engine::TrackChangeFlags change) {
|
||||
void Player::NextInternal(const Engine::TrackChangeFlags change) {
|
||||
|
||||
if (HandleStopAfter()) return;
|
||||
|
||||
@@ -362,7 +362,7 @@ void Player::NextInternal(Engine::TrackChangeFlags change) {
|
||||
|
||||
}
|
||||
|
||||
void Player::NextItem(Engine::TrackChangeFlags change) {
|
||||
void Player::NextItem(const Engine::TrackChangeFlags change) {
|
||||
|
||||
Playlist *active_playlist = app_->playlist_manager()->active();
|
||||
|
||||
@@ -487,7 +487,7 @@ bool Player::PreviousWouldRestartTrack() const {
|
||||
|
||||
void Player::Previous() { PreviousItem(Engine::Manual); }
|
||||
|
||||
void Player::PreviousItem(Engine::TrackChangeFlags change) {
|
||||
void Player::PreviousItem(const Engine::TrackChangeFlags change) {
|
||||
|
||||
const bool ignore_repeat_track = change & Engine::Manual;
|
||||
|
||||
@@ -514,7 +514,7 @@ void Player::PreviousItem(Engine::TrackChangeFlags change) {
|
||||
|
||||
}
|
||||
|
||||
void Player::EngineStateChanged(Engine::State state) {
|
||||
void Player::EngineStateChanged(const Engine::State state) {
|
||||
|
||||
if (Engine::Error == state) {
|
||||
nb_errors_received_++;
|
||||
@@ -542,7 +542,7 @@ void Player::EngineStateChanged(Engine::State state) {
|
||||
|
||||
}
|
||||
|
||||
void Player::SetVolume(int value) {
|
||||
void Player::SetVolume(const int value) {
|
||||
|
||||
int old_volume = engine_->volume();
|
||||
|
||||
@@ -558,7 +558,7 @@ void Player::SetVolume(int value) {
|
||||
|
||||
int Player::GetVolume() const { return engine_->volume(); }
|
||||
|
||||
void Player::PlayAt(int index, Engine::TrackChangeFlags change, bool reshuffle) {
|
||||
void Player::PlayAt(const int index, Engine::TrackChangeFlags change, const bool reshuffle) {
|
||||
|
||||
if (current_item_ && change == Engine::Manual && engine_->position_nanosec() != engine_->length_nanosec()) {
|
||||
emit TrackSkipped(current_item_);
|
||||
@@ -611,7 +611,7 @@ void Player::CurrentMetadataChanged(const Song &metadata) {
|
||||
|
||||
}
|
||||
|
||||
void Player::SeekTo(int seconds) {
|
||||
void Player::SeekTo(const int seconds) {
|
||||
|
||||
const qint64 length_nanosec = engine_->length_nanosec();
|
||||
|
||||
@@ -662,7 +662,7 @@ void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle) {
|
||||
|
||||
}
|
||||
|
||||
PlaylistItemPtr Player::GetItemAt(int pos) const {
|
||||
PlaylistItemPtr Player::GetItemAt(const int pos) const {
|
||||
|
||||
if (pos < 0 || pos >= app_->playlist_manager()->active()->rowCount())
|
||||
return PlaylistItemPtr();
|
||||
@@ -763,8 +763,6 @@ void Player::TrackAboutToEnd() {
|
||||
|
||||
}
|
||||
|
||||
void Player::IntroPointReached() { NextInternal(Engine::Intro); }
|
||||
|
||||
void Player::FatalError() {
|
||||
nb_errors_received_ = 0;
|
||||
Stop();
|
||||
|
||||
@@ -72,7 +72,7 @@ class PlayerInterface : public QObject {
|
||||
virtual void ReloadSettings() = 0;
|
||||
|
||||
// Manual track change to the specified track
|
||||
virtual void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle) = 0;
|
||||
virtual void PlayAt(const int row, Engine::TrackChangeFlags change, const bool reshuffle) = 0;
|
||||
|
||||
// If there's currently a song playing, pause it, otherwise play the track that was playing last, or the first one on the playlist
|
||||
virtual void PlayPause() = 0;
|
||||
@@ -82,10 +82,10 @@ class PlayerInterface : public QObject {
|
||||
virtual void Next() = 0;
|
||||
|
||||
virtual void Previous() = 0;
|
||||
virtual void SetVolume(int value) = 0;
|
||||
virtual void SetVolume(const int value) = 0;
|
||||
virtual void VolumeUp() = 0;
|
||||
virtual void VolumeDown() = 0;
|
||||
virtual void SeekTo(int seconds) = 0;
|
||||
virtual void SeekTo(const int seconds) = 0;
|
||||
// Moves the position of the currently playing song five seconds forward.
|
||||
virtual void SeekForward() = 0;
|
||||
// Moves the position of the currently playing song five seconds backwards.
|
||||
@@ -109,14 +109,14 @@ class PlayerInterface : public QObject {
|
||||
void PlaylistFinished();
|
||||
void VolumeEnabled(bool);
|
||||
void VolumeChanged(int volume);
|
||||
void Error(const QString &message);
|
||||
void Error(QString message);
|
||||
void TrackSkipped(PlaylistItemPtr old_track);
|
||||
// Emitted when there's a manual change to the current's track position.
|
||||
void Seeked(qlonglong microseconds);
|
||||
|
||||
// Emitted when Player has processed a request to play another song.
|
||||
// This contains the URL of the song and a flag saying whether it was able to play the song.
|
||||
void SongChangeRequestProcessed(const QUrl &url, bool valid);
|
||||
void SongChangeRequestProcessed(QUrl url, bool valid);
|
||||
|
||||
// The toggle parameter is true when user requests to toggle visibility for Pretty OSD
|
||||
void ForceShowOSD(Song, bool toggle);
|
||||
@@ -158,15 +158,15 @@ class Player : public PlayerInterface {
|
||||
public slots:
|
||||
void ReloadSettings() override;
|
||||
|
||||
void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle) override;
|
||||
void PlayAt(const int row, Engine::TrackChangeFlags change, const bool reshuffle) override;
|
||||
void PlayPause() override;
|
||||
void RestartOrPrevious() override;
|
||||
void Next() override;
|
||||
void Previous() override;
|
||||
void SetVolume(int value) override;
|
||||
void SetVolume(const int value) override;
|
||||
void VolumeUp() override { SetVolume(GetVolume() + 5); }
|
||||
void VolumeDown() override { SetVolume(GetVolume() - 5); }
|
||||
void SeekTo(int seconds) override;
|
||||
void SeekTo(const int seconds) override;
|
||||
void SeekForward() override;
|
||||
void SeekBackward() override;
|
||||
|
||||
@@ -176,7 +176,6 @@ class Player : public PlayerInterface {
|
||||
void Pause() override;
|
||||
void Stop(bool stop_after = false) override;
|
||||
void StopAfterCurrent();
|
||||
void IntroPointReached();
|
||||
void Play() override;
|
||||
void ShowOSD() override;
|
||||
void TogglePrettyOSD();
|
||||
@@ -187,15 +186,15 @@ class Player : public PlayerInterface {
|
||||
void EngineChanged(Engine::EngineType enginetype);
|
||||
|
||||
private slots:
|
||||
void EngineStateChanged(Engine::State);
|
||||
void EngineStateChanged(const Engine::State);
|
||||
void EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle);
|
||||
void TrackAboutToEnd();
|
||||
void TrackEnded();
|
||||
// Play the next item on the playlist - disregarding radio stations like last.fm that might have more tracks.
|
||||
void NextItem(Engine::TrackChangeFlags change);
|
||||
void PreviousItem(Engine::TrackChangeFlags change);
|
||||
void NextItem(const Engine::TrackChangeFlags change);
|
||||
void PreviousItem(const Engine::TrackChangeFlags change);
|
||||
|
||||
void NextInternal(Engine::TrackChangeFlags);
|
||||
void NextInternal(const Engine::TrackChangeFlags);
|
||||
|
||||
void FatalError();
|
||||
void ValidSongRequested(const QUrl&);
|
||||
|
||||
Reference in New Issue
Block a user