Skip to content

Commit

Permalink
MythMusic: Add TOGGLESHUFFLE and TOGGLEREPEAT keybindings
Browse files Browse the repository at this point in the history
(cherry picked from commit 91e7b1d)

Signed-off-by: Stuart Morgan <smorgan@mythtv.org>
  • Loading branch information
Paul Harrison authored and stuartm committed May 18, 2012
1 parent e7e6492 commit fa9edd6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
4 changes: 4 additions & 0 deletions mythplugins/mythmusic/mythmusic/main.cpp
Expand Up @@ -591,6 +591,10 @@ static void setupKeys(void)
"Decrease Play Speed"), "X");
REG_KEY("Music", "MARK", QT_TRANSLATE_NOOP("MythControls",
"Toggle track selection"), "T");
REG_KEY("Music", "TOGGLESHUFFLE", QT_TRANSLATE_NOOP("MythControls",
"Toggle shuffle mode"), "");
REG_KEY("Music", "TOGGLEREPEAT", QT_TRANSLATE_NOOP("MythControls",
"Toggle repeat mode"), "");

// switch to view key bindings
REG_KEY("Music", "SWITCHTOPLAYLIST", QT_TRANSLATE_NOOP("MythControls",
Expand Down
52 changes: 35 additions & 17 deletions mythplugins/mythmusic/mythmusic/musiccommon.cpp
Expand Up @@ -287,9 +287,14 @@ void MusicCommon::updateRepeatMode(void)
break;
}
}

// need this to update the next track info
Metadata *curMeta = gPlayer->getCurrentMetadata();
if (curMeta)
updateTrackInfo(curMeta);
}

void MusicCommon::updateShuffleMode(void)
void MusicCommon::updateShuffleMode(bool updateUIList)
{
if (m_shuffleState)
{
Expand Down Expand Up @@ -327,6 +332,24 @@ void MusicCommon::updateShuffleMode(void)
break;
}
}

if (updateUIList)
{
// store id of current track
int curTrackID = -1;
if (gPlayer->getCurrentMetadata())
curTrackID = gPlayer->getCurrentMetadata()->ID();

updateUIPlaylist();

if (!restorePosition(curTrackID))
playFirstTrack();

// need this to update the next track info
Metadata *curMeta = gPlayer->getCurrentMetadata();
if (curMeta)
updateTrackInfo(curMeta);
}
}

void MusicCommon::switchView(MusicView view)
Expand Down Expand Up @@ -677,6 +700,16 @@ bool MusicCommon::keyPressEvent(QKeyEvent *e)
switchView(MV_SEARCH);
else if (action == "SWITCHTOVISUALISER" && m_currentView != MV_VISUALIZER)
switchView(MV_VISUALIZER);
else if (action == "TOGGLESHUFFLE")
{
gPlayer->toggleShuffleMode();
updateShuffleMode(true);
}
else if (action == "TOGGLEREPEAT")
{
gPlayer->toggleRepeatMode();
updateRepeatMode();
}
else
handled = false;
}
Expand Down Expand Up @@ -1294,22 +1327,7 @@ void MusicCommon::customEvent(QEvent *event)
{
int mode = dce->GetData().toInt();
gPlayer->setShuffleMode((MusicPlayer::ShuffleMode) mode);
updateShuffleMode();

// store id of current track
int curTrackID = -1;
if (gPlayer->getCurrentMetadata())
curTrackID = gPlayer->getCurrentMetadata()->ID();

updateUIPlaylist();

if (!restorePosition(curTrackID))
playFirstTrack();

// need this to update the next track info
Metadata *curMeta = gPlayer->getCurrentMetadata();
if (curMeta)
updateTrackInfo(curMeta);
updateShuffleMode(true);
}
else if (resultid == "exitmenu")
{
Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mythmusic/mythmusic/musiccommon.h
Expand Up @@ -115,7 +115,7 @@ class MPUBLIC MusicCommon : public MythScreenType
void updatePlaylistStats(void);
void updateUIPlayedList(void); // for streaming
void updateRepeatMode(void);
void updateShuffleMode(void);
void updateShuffleMode(bool updateUIList = false);

void changeVolume(bool up);
void changeSpeed(bool up);
Expand Down

0 comments on commit fa9edd6

Please sign in to comment.