Skip to content

Commit

Permalink
Subtitles OSD: Use Enable/Disable instead of Toggle.
Browse files Browse the repository at this point in the history
For a slightly improved user experience.
  • Loading branch information
Mark Kendall committed Oct 20, 2011
1 parent 58499b3 commit 6ec2085
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
12 changes: 12 additions & 0 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythtv/tv_actions.h
Expand Up @@ -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"

Expand Down
28 changes: 23 additions & 5 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -6609,7 +6623,7 @@ bool TV::CommitQueuedInput(PlayerContext *ctx)
{
commited = true;
if (HasQueuedInput())
HandleTrackAction(ctx, "TOGGLECC");
HandleTrackAction(ctx, ACTION_TOGGLESUBS);
}
else if (asInputMode)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6ec2085

Please sign in to comment.