Adding a "play next album" function, in addition to "play next
track". Changed shortcut key for Next Album from "space" to F9 Fixed indentation in player.cpp Fixed spacing in player.cpp. Updated player.cpp to ensure while loop takes into consideration the last song on the playlist. Fixed lint formatting error in player.cpp Additional changes to player.cpp to make sure next album search reacts properly to the given repeat mode. Updated player.cpp to address cpplint issues. Fixing formatting issues. Fixing formatting errors. Finished formatting updates. Final formatting... Final formatting Really final formatting... Addressed issues from code review. Added functionality to disable Next Album option when repeat mode is "repeat track". Added commentary to recent changes. Disable Next Album action also when Repeat Mode is Repeat_Album In addition to disabling this action for the Next_Track repeat mode, the same applies to the Next_Album repeat mode.
This commit is contained in:
parent
8c2ab8fa05
commit
8fcdbd5114
@ -170,7 +170,9 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult& result) {
|
||||
|
||||
void Player::Next() { NextInternal(Engine::Manual); }
|
||||
|
||||
void Player::NextInternal(Engine::TrackChangeFlags change) {
|
||||
void Player::NextAlbum() { NextInternal(Engine::Manual, true); }
|
||||
|
||||
void Player::NextInternal(Engine::TrackChangeFlags change, bool next_album) {
|
||||
if (HandleStopAfter()) return;
|
||||
|
||||
if (app_->playlist_manager()->active()->current_item()) {
|
||||
@ -186,10 +188,10 @@ void Player::NextInternal(Engine::TrackChangeFlags change) {
|
||||
}
|
||||
}
|
||||
|
||||
NextItem(change);
|
||||
NextItem(change, next_album);
|
||||
}
|
||||
|
||||
void Player::NextItem(Engine::TrackChangeFlags change) {
|
||||
void Player::NextItem(Engine::TrackChangeFlags change, bool next_album) {
|
||||
Playlist* active_playlist = app_->playlist_manager()->active();
|
||||
|
||||
// If we received too many errors in auto change, with repeat enabled, we stop
|
||||
@ -213,7 +215,25 @@ void Player::NextItem(Engine::TrackChangeFlags change) {
|
||||
// Manual track changes override "Repeat track"
|
||||
const bool ignore_repeat_track = change & Engine::Manual;
|
||||
|
||||
int i = active_playlist->next_row(ignore_repeat_track);
|
||||
int i = active_playlist->current_row();
|
||||
if (next_album && i != -1) {
|
||||
if (active_playlist->sequence()->repeat_mode() !=
|
||||
PlaylistSequence::Repeat_Track) {
|
||||
int original_index = i;
|
||||
QString album = active_playlist->current_item_metadata().album();
|
||||
|
||||
i = active_playlist->next_row(ignore_repeat_track);
|
||||
while (i != -1 &&
|
||||
active_playlist->item_at(i)->Metadata().album() == album &&
|
||||
i != original_index) {
|
||||
active_playlist->set_current_row(i, true);
|
||||
i = active_playlist->next_row(ignore_repeat_track);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
i = active_playlist->next_row(ignore_repeat_track);
|
||||
}
|
||||
|
||||
if (i == -1) {
|
||||
app_->playlist_manager()->active()->set_current_row(i);
|
||||
emit PlaylistFinished();
|
||||
|
@ -72,6 +72,7 @@ class PlayerInterface : public QObject {
|
||||
|
||||
// Skips this track. Might load more of the current radio station.
|
||||
virtual void Next() = 0;
|
||||
virtual void NextAlbum() = 0;
|
||||
|
||||
virtual void Previous() = 0;
|
||||
virtual void SetVolume(int value) = 0;
|
||||
@ -150,6 +151,7 @@ class Player : public PlayerInterface {
|
||||
void PlayPause();
|
||||
void RestartOrPrevious();
|
||||
void Next();
|
||||
void NextAlbum();
|
||||
void Previous();
|
||||
void PlayPlaylist(const QString& playlistName);
|
||||
void SetVolume(int value);
|
||||
@ -177,10 +179,10 @@ class Player : public PlayerInterface {
|
||||
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 NextItem(Engine::TrackChangeFlags change, bool next_album = false);
|
||||
void PreviousItem(Engine::TrackChangeFlags change);
|
||||
|
||||
void NextInternal(Engine::TrackChangeFlags);
|
||||
void NextInternal(Engine::TrackChangeFlags, bool next_album = false);
|
||||
void PlayPlaylistInternal(Engine::TrackChangeFlags,
|
||||
const QString& playlistName);
|
||||
|
||||
|
@ -356,6 +356,8 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
ui_->action_jump->setIcon(IconLoader::Load("go-jump", IconLoader::Base));
|
||||
ui_->action_next_track->setIcon(
|
||||
IconLoader::Load("media-skip-forward", IconLoader::Base));
|
||||
ui_->action_next_album->setIcon(
|
||||
IconLoader::Load("media-skip-forward", IconLoader::Base));
|
||||
ui_->action_open_media->setIcon(
|
||||
IconLoader::Load("document-open", IconLoader::Base));
|
||||
ui_->action_open_cd->setIcon(
|
||||
@ -417,6 +419,8 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
// Action connections
|
||||
connect(ui_->action_next_track, SIGNAL(triggered()), app_->player(),
|
||||
SLOT(Next()));
|
||||
connect(ui_->action_next_album, SIGNAL(triggered()), app_->player(),
|
||||
SLOT(NextAlbum()));
|
||||
connect(ui_->action_previous_track, SIGNAL(triggered()), app_->player(),
|
||||
SLOT(Previous()));
|
||||
connect(ui_->action_play_pause, SIGNAL(triggered()), app_->player(),
|
||||
@ -547,6 +551,12 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
ui_->action_shuffle_mode->setMenu(ui_->playlist_sequence->shuffle_menu());
|
||||
ui_->action_repeat_mode->setMenu(ui_->playlist_sequence->repeat_menu());
|
||||
|
||||
// Next Actions
|
||||
QMenu* next_menu = new QMenu(this);
|
||||
next_menu->addAction(ui_->action_next_track);
|
||||
next_menu->addAction(ui_->action_next_album);
|
||||
ui_->forward_button->setMenu(next_menu);
|
||||
|
||||
// Stop actions
|
||||
QMenu* stop_menu = new QMenu(this);
|
||||
stop_menu->addAction(ui_->action_stop);
|
||||
@ -971,6 +981,12 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
SIGNAL(ShuffleModeChanged(PlaylistSequence::ShuffleMode)), osd_,
|
||||
SLOT(ShuffleModeChanged(PlaylistSequence::ShuffleMode)));
|
||||
|
||||
// Connect the RepeatModeChanged signal such that it will dis/enable the
|
||||
// action_next_album on the UI
|
||||
connect(app_->playlist_manager()->sequence(),
|
||||
SIGNAL(RepeatModeChanged(PlaylistSequence::RepeatMode)),
|
||||
SLOT(SetNextAlbumEnabled(PlaylistSequence::RepeatMode)));
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
connect(app_->scrobbler(), SIGNAL(CachedToScrobble()),
|
||||
SLOT(CachedToScrobble()));
|
||||
@ -1070,6 +1086,13 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
|
||||
if (!options.contains_play_options()) LoadPlaybackStatus();
|
||||
|
||||
// Set the state of action_next_album based on the repeat mode.
|
||||
if (app_->playlist_manager()->current()->sequence()->repeat_mode() ==
|
||||
PlaylistSequence::Repeat_Track ||
|
||||
app_->playlist_manager()->current()->sequence()->repeat_mode() ==
|
||||
PlaylistSequence::Repeat_Album)
|
||||
ui_->action_next_album->setDisabled(true);
|
||||
|
||||
initialized_ = true;
|
||||
|
||||
qLog(Debug) << "Started";
|
||||
@ -3096,3 +3119,16 @@ void MainWindow::keyPressEvent(QKeyEvent* event) {
|
||||
QMainWindow::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
// Change the state of action_next_album based when the repeat mode is
|
||||
// changed.
|
||||
void MainWindow::SetNextAlbumEnabled(PlaylistSequence::RepeatMode mode) {
|
||||
if (mode == PlaylistSequence::Repeat_Track ||
|
||||
mode == PlaylistSequence::Repeat_Album) {
|
||||
if (ui_->action_next_album->isEnabled())
|
||||
ui_->action_next_album->setDisabled(true);
|
||||
} else {
|
||||
if (!ui_->action_next_album->isEnabled())
|
||||
ui_->action_next_album->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
void NewDebugConsole(Console* console);
|
||||
private slots:
|
||||
void SetNextAlbumEnabled(PlaylistSequence::RepeatMode mode);
|
||||
void FilePathChanged(const QString& path);
|
||||
|
||||
void SaveSettings(QSettings* settings);
|
||||
|
@ -199,12 +199,21 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="forward_button">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>42</width>
|
||||
<height>29</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::MenuButtonPopup</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -477,7 +486,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1131</width>
|
||||
<height>23</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_music">
|
||||
@ -945,6 +954,17 @@
|
||||
<string>Show or hide the sidebar</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_next_album">
|
||||
<property name="text">
|
||||
<string>Next album</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Skip to the next album</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F9</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
Loading…
x
Reference in New Issue
Block a user