Permalink
Browse files

Subtitles OSD: Use Enable/Disable instead of Toggle.

For a slightly improved user experience.
  • Loading branch information...
1 parent 58499b3 commit 6ec2085869bcedfbbaec3d625515047b7bd5cf75 Mark Kendall committed Oct 20, 2011
@@ -1469,6 +1469,18 @@ void MythPlayer::SetCaptionsEnabled(bool enable, bool osd_msg)
}
}
+bool MythPlayer::GetCaptionsEnabled(void)
+{
+ return (kDisplayNUVTeletextCaptions == textDisplayMode) ||
+ (kDisplayTeletextCaptions == textDisplayMode) ||
+ (kDisplayAVSubtitle == textDisplayMode) ||
+ (kDisplayCC608 == textDisplayMode) ||
+ (kDisplayCC708 == textDisplayMode) ||
+ (kDisplayTextSubtitle == textDisplayMode) ||
+ (kDisplayRawTextSubtitle == textDisplayMode) ||
+ (kDisplayTeletextMenu == textDisplayMode);
+}
+
QStringList MythPlayer::GetTracks(uint type)
{
if (decoder)
@@ -434,6 +434,7 @@ class MTV_PUBLIC MythPlayer
bool ToggleCaptions(uint mode);
bool HasTextSubtitles(void) { return subReader.HasTextSubtitles(); }
void SetCaptionsEnabled(bool, bool osd_msg=true);
+ bool GetCaptionsEnabled(void);
virtual void DisableCaptions(uint mode, bool osd_msg=true);
virtual void EnableCaptions(uint mode, bool osd_msg=true);
@@ -43,6 +43,9 @@
#define ACTION_EXITSHOWNOPROMPTS "EXITSHOWNOPROMPTS"
+#define ACTION_ENABLESUBS "ENABLESUBS"
+#define ACTION_DISABLESUBS "DISABLESUBS"
+#define ACTION_TOGGLESUBS "TOGGLECC"
#define ACTION_ENABLEFORCEDSUBS "ENABLEFORCEDSUBS"
#define ACTION_DISABLEFORCEDSUBS "DISABLEFORCEDSUBS"
@@ -574,8 +574,12 @@ void TV::InitKeys(void)
"Toggle the video aspect ratio"), "Ctrl+W");
REG_KEY("TV Playback", "TOGGLEFILL", QT_TRANSLATE_NOOP("MythControls",
"Next Preconfigured Zoom mode"), "W");
- REG_KEY("TV Playback", "TOGGLECC", QT_TRANSLATE_NOOP("MythControls",
+ REG_KEY("TV Playback", ACTION_TOGGLESUBS, QT_TRANSLATE_NOOP("MythControls",
"Toggle any captions"), "T");
+ REG_KEY("TV Playback", ACTION_ENABLESUBS, QT_TRANSLATE_NOOP("MythControls",
+ "Enable any captions"), "");
+ REG_KEY("TV Playback", ACTION_DISABLESUBS, QT_TRANSLATE_NOOP("MythControls",
+ "Disable any captions"), "");
REG_KEY("TV Playback", "TOGGLETTC", QT_TRANSLATE_NOOP("MythControls",
"Toggle Teletext Captions"),"");
REG_KEY("TV Playback", "TOGGLESUBTITLE", QT_TRANSLATE_NOOP("MythControls",
@@ -3276,7 +3280,17 @@ bool TV::HandleTrackAction(PlayerContext *ctx, const QString &action)
handled = true;
ctx->player->SetAllowForcedSubtitles(false);
}
- else if (action == "TOGGLECC" && !browsehelper->IsBrowsing())
+ else if (action == ACTION_ENABLESUBS)
+ {
+ handled = true;
+ ctx->player->SetCaptionsEnabled(true, true);
+ }
+ else if (action == ACTION_DISABLESUBS)
+ {
+ handled = true;
+ ctx->player->SetCaptionsEnabled(false, true);
+ }
+ else if (action == ACTION_TOGGLESUBS && !browsehelper->IsBrowsing())
{
handled = true;
if (ccInputMode)
@@ -6609,7 +6623,7 @@ bool TV::CommitQueuedInput(PlayerContext *ctx)
{
commited = true;
if (HasQueuedInput())
- HandleTrackAction(ctx, "TOGGLECC");
+ HandleTrackAction(ctx, ACTION_TOGGLESUBS);
}
else if (asInputMode)
{
@@ -10182,10 +10196,12 @@ void TV::FillOSDMenuSubtitles(const PlayerContext *ctx, OSD *osd,
uint text_curtrack = ~0;
bool havetext = false;
bool forcedon = true;
+ bool enabled = false;
ctx->LockDeletePlayer(__FILE__, __LINE__);
if (ctx->player)
{
// capmode = ctx->player->GetCaptionMode();
+ enabled = ctx->player->GetCaptionsEnabled();
havetext = ctx->player->HasTextSubtitles();
forcedon = ctx->player->GetAllowForcedSubtitles();
av_tracks = ctx->player->GetTracks(kTrackTypeSubtitle);
@@ -10225,8 +10241,10 @@ void TV::FillOSDMenuSubtitles(const PlayerContext *ctx, OSD *osd,
backaction = "MAIN";
currenttext = tr("Subtitles");
- if (have_subs)
- osd->DialogAddButton(tr("Toggle Subtitles"), "TOGGLECC");
+ if (have_subs &&enabled)
+ osd->DialogAddButton(tr("Disable Subtitles"), ACTION_DISABLESUBS);
+ else if (have_subs && !enabled)
+ osd->DialogAddButton(tr("Enable Subtitles"), ACTION_ENABLESUBS);
if (!av_tracks.empty())
{
if (forcedon)

0 comments on commit 6ec2085

Please sign in to comment.