Ticket #10306: 10306-v1.patch

File 10306-v1.patch, 4.2 KB (added by danielk, 9 years ago)
  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 546c1ec..fdd3a97 100644
    a b void MythPlayer::ToggleStudioLevels(void) 
    48794879    SetOSDMessage(msg, kOSDTimeout_Med);
    48804880}
    48814881
     4882void MythPlayer::ToggleNightMode(void)
     4883{
     4884    if (!videoOutput)
     4885        return;
     4886
     4887    if (!(videoOutput->GetSupportedPictureAttributes() &
     4888          kPictureAttributeSupported_Brightness))
     4889        return;
     4890
     4891    bool has_contrast = (videoOutput->GetSupportedPictureAttributes() &
     4892                         kPictureAttributeSupported_Contrast);
     4893
     4894    int nm = gCoreContext->GetNumSetting("NightModeEnabled", 0);
     4895    int nb = gCoreContext->GetNumSetting("NightModeBrightness", 15);
     4896    int nc = gCoreContext->GetNumSetting("NightModeContrast", 10);
     4897    int b = videoOutput->GetPictureAttribute(kPictureAttribute_Brightness);
     4898    int c = 0;
     4899    if (has_contrast)
     4900        c = videoOutput->GetPictureAttribute(kPictureAttribute_Contrast);
     4901    QString val = "1";
     4902    QString msg;
     4903    if (!nm)
     4904    {
     4905        msg = QObject::tr("Enabled Night Mode");
     4906        b -= nb;
     4907        c -= nc;
     4908    }
     4909    else
     4910    {
     4911        msg = QObject::tr("Disabled Night Mode");
     4912        b += nb;
     4913        c += nc;
     4914    }
     4915
     4916    gCoreContext->SaveSetting("NightModeEnabled", nm ? "0" : "1");
     4917    videoOutput->SetPictureAttribute(kPictureAttribute_Brightness, b);
     4918    if (has_contrast)
     4919        videoOutput->SetPictureAttribute(kPictureAttribute_Contrast, c);
     4920
     4921    SetOSDMessage(msg, kOSDTimeout_Med);
     4922}
     4923
    48824924bool MythPlayer::CanVisualise(void)
    48834925{
    48844926    if (videoOutput)
  • mythtv/libs/libmythtv/mythplayer.h

    diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
    index e30c3a7..971a050 100644
    a b class MTV_PUBLIC MythPlayer 
    324324
    325325    // Public picture controls
    326326    void ToggleStudioLevels(void);
     327    void ToggleNightMode(void);
    327328
    328329    // Visualisations
    329330    bool CanVisualise(void);
  • mythtv/libs/libmythtv/tv_play.cpp

    diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
    index 2c3f127..b87f0ca 100644
    a b void TV::InitKeys(void) 
    723723    REG_KEY("TV Playback", "TOGGLEPICCONTROLS",
    724724            QT_TRANSLATE_NOOP("MythControls", "Playback picture adjustments"),
    725725             "F");
     726    REG_KEY("TV Playback", "TOGGLENIGHTMODE",
     727            QT_TRANSLATE_NOOP("MythControls", "Toggle night mode"), "Ctrl+F");
    726728    REG_KEY("TV Playback", ACTION_SETBRIGHTNESS,
    727729            QT_TRANSLATE_NOOP("MythControls", "Set the picture brightness"), "");
    728730    REG_KEY("TV Playback", ACTION_SETCONTRAST,
    bool TV::ToggleHandleAction(PlayerContext *ctx, 
    44014403        EnableVisualisation(ctx, false);
    44024404    else if (has_action("TOGGLEPICCONTROLS", actions))
    44034405        DoTogglePictureAttribute(ctx, kAdjustingPicture_Playback);
     4406    else if (has_action("TOGGLENIGHTMODE", actions))
     4407        DoToggleNightMode(ctx);
    44044408    else if (has_action(ACTION_TOGGLESTUDIOLEVELS, actions))
    44054409        DoToggleStudioLevels(ctx);
    44064410    else if (has_action("TOGGLESTRETCH", actions))
    void TV::DoToggleStudioLevels(const PlayerContext *ctx) 
    91169120    ctx->UnlockDeletePlayer(__FILE__, __LINE__);
    91179121}
    91189122
     9123void TV::DoToggleNightMode(const PlayerContext *ctx)
     9124{
     9125    ctx->LockDeletePlayer(__FILE__, __LINE__);
     9126    ctx->player->ToggleNightMode();
     9127    ctx->UnlockDeletePlayer(__FILE__, __LINE__);
     9128}
     9129
    91199130void TV::DoTogglePictureAttribute(const PlayerContext *ctx,
    91209131                                  PictureAdjustType type)
    91219132{
  • mythtv/libs/libmythtv/tv_play.h

    diff --git a/mythtv/libs/libmythtv/tv_play.h b/mythtv/libs/libmythtv/tv_play.h
    index d17ba29..adce496 100644
    a b class MTV_PUBLIC TV : public QObject 
    491491    void ToggleAdjustFill(PlayerContext*,
    492492                          AdjustFillMode adjustfillMode = kAdjustFill_Toggle);
    493493    void DoToggleStudioLevels(const PlayerContext *ctx);
     494    void DoToggleNightMode(const PlayerContext*);
    494495    void DoTogglePictureAttribute(const PlayerContext*,
    495496                                  PictureAdjustType type);
    496497    void DoChangePictureAttribute(