Permalink
Browse files

MythMusic: Add TOGGLESHUFFLE and TOGGLEREPEAT keybindings

(cherry picked from commit 91e7b1d)

Signed-off-by: Stuart Morgan <smorgan@mythtv.org>
  • Loading branch information...
Paul Harrison authored and stuartm committed May 10, 2012
1 parent e7e6492 commit fa9edd607d0025bdebd29cac5c26e0909e50a1e4
@@ -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",
@@ -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)
{
@@ -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)
@@ -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;
}
@@ -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")
{
@@ -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);

0 comments on commit fa9edd6

Please sign in to comment.