From 238d243481669fc54011db7bc939268d1b6390df Mon Sep 17 00:00:00 2001
From: Tobias Maier <diespambox@gmx.net>
Date: Wed, 4 Jul 2012 08:43:55 +0200
Subject: [PATCH] Enable mythconfirmation dialog to pause playback. If a
MythUserMessage with ExtraData set to "pauseplayback"
(instead of a timeout) is received while in playback,
playback is paused until the dialog is dissmissed.
---
mythtv/libs/libmythtv/osd.cpp | 35 ++++++++++++++++++++++++-----------
mythtv/libs/libmythtv/osd.h | 2 +-
mythtv/libs/libmythtv/tv_play.cpp | 21 ++++++++++++++++++++-
3 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/mythtv/libs/libmythtv/osd.cpp b/mythtv/libs/libmythtv/osd.cpp
index 6b2f09f..3b5a4b4 100644
a
|
b
|
void OSD::DialogQuit(void) |
967 | 967 | m_PulsedDialogText = QString(); |
968 | 968 | } |
969 | 969 | |
970 | | void OSD::DialogShow(const QString &window, const QString &text, int updatefor) |
| 970 | void OSD::DialogShow(const QString &window, const QString &text, int updatefor, |
| 971 | const QString &confirmationData) |
971 | 972 | { |
972 | 973 | if (m_Dialog) |
973 | 974 | { |
… |
… |
void OSD::DialogShow(const QString &window, const QString &text, int updatefor) |
1009 | 1010 | MythConfirmationDialog *cbox = dynamic_cast<MythConfirmationDialog*>(m_Dialog); |
1010 | 1011 | if (cbox) |
1011 | 1012 | { |
1012 | | cbox->SetReturnEvent(m_ParentObject, window); |
1013 | | cbox->SetData("DIALOG_CONFIRM_X_X"); |
| 1013 | PositionWindow(dialog); |
| 1014 | m_Dialog = dialog; |
| 1015 | MythDialogBox *dbox = dynamic_cast<MythDialogBox*>(m_Dialog); |
| 1016 | if (dbox) |
| 1017 | dbox->SetReturnEvent(m_ParentObject, window); |
| 1018 | MythConfirmationDialog *cbox = dynamic_cast<MythConfirmationDialog*>(m_Dialog); |
| 1019 | if (cbox) |
| 1020 | { |
| 1021 | cbox->SetReturnEvent(m_ParentObject, window); |
| 1022 | if (!confirmationData.isEmpty() && confirmationData.contains("_")) |
| 1023 | cbox->SetData(QString("DIALOG_CONFIRM_%1").arg(confirmationData)); |
| 1024 | else |
| 1025 | cbox->SetData("DIALOG_CONFIRM_X_X"); |
| 1026 | } |
| 1027 | m_Children.insert(window, m_Dialog); |
1014 | 1028 | } |
1015 | | m_Children.insert(window, m_Dialog); |
1016 | | } |
1017 | | else |
1018 | | { |
| 1029 | else |
| 1030 | { |
| 1031 | RevertUIScale(); |
| 1032 | delete dialog; |
| 1033 | return; |
| 1034 | } |
| 1035 | |
1019 | 1036 | RevertUIScale(); |
1020 | | delete dialog; |
1021 | | return; |
1022 | 1037 | } |
1023 | | |
1024 | | RevertUIScale(); |
1025 | 1038 | } |
1026 | 1039 | |
1027 | 1040 | if (updatefor) |
diff --git a/mythtv/libs/libmythtv/osd.h b/mythtv/libs/libmythtv/osd.h
index 2136fa2..b6615ea 100644
a
|
b
|
class OSD |
167 | 167 | bool DialogHandleKeypress(QKeyEvent *e); |
168 | 168 | void DialogQuit(void); |
169 | 169 | void DialogShow(const QString &window, const QString &text = "", |
170 | | int updatefor = 0); |
| 170 | int updatefor = 0, const QString &confirmationData =""); |
171 | 171 | void DialogSetText(const QString &text); |
172 | 172 | void DialogBack(QString text = "", QVariant data = 0, bool exit = false); |
173 | 173 | void DialogAddButton(QString text, QVariant data, |
diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
index 750b3dd..ddd127b 100644
a
|
b
|
void TV::customEvent(QEvent *e) |
8713 | 8713 | return; |
8714 | 8714 | |
8715 | 8715 | uint timeout = 0; |
| 8716 | bool pausePlayback = false; |
8716 | 8717 | if (me->ExtraDataCount() == 1) |
8717 | 8718 | { |
8718 | 8719 | uint t = me->ExtraData(0).toUInt(); |
8719 | 8720 | if (t > 0 && t < 1000) |
8720 | 8721 | timeout = t * 1000; |
| 8722 | |
| 8723 | if (t == 0 && me->ExtraData(0).contains("pauseplayback")) |
| 8724 | pausePlayback = true; |
8721 | 8725 | } |
8722 | 8726 | |
8723 | 8727 | if (timeout > 0) |
8724 | 8728 | message += " (%d)"; |
8725 | 8729 | |
| 8730 | |
8726 | 8731 | PlayerContext *mctx = GetPlayerReadLock(0, __FILE__, __LINE__); |
| 8732 | |
| 8733 | QString confirmationData; |
| 8734 | if (pausePlayback && !ContextIsPaused(mctx, __FILE__, __LINE__)) |
| 8735 | { |
| 8736 | gTV->NormalSpeed(mctx); |
| 8737 | gTV->StopFFRew(mctx); |
| 8738 | gTV->DoTogglePause(mctx, false); |
| 8739 | confirmationData = "RESUME_PLAYBACK"; |
| 8740 | } |
| 8741 | |
8727 | 8742 | OSD *osd = GetOSDLock(mctx); |
8728 | 8743 | if (osd) |
8729 | | osd->DialogShow(OSD_DLG_CONFIRM, message, timeout); |
| 8744 | osd->DialogShow(OSD_DLG_CONFIRM, message, timeout, confirmationData); |
8730 | 8745 | ReturnOSDLock(mctx, osd); |
8731 | 8746 | ReturnPlayerLock(mctx); |
8732 | 8747 | |
… |
… |
void TV::customEvent(QEvent *e) |
8753 | 8768 | { |
8754 | 8769 | DialogCompletionEvent *dce = |
8755 | 8770 | reinterpret_cast<DialogCompletionEvent*>(e); |
| 8771 | |
8756 | 8772 | OSDDialogEvent(dce->GetResult(), dce->GetResultText(), |
8757 | 8773 | dce->GetData().toString()); |
8758 | 8774 | return; |
… |
… |
void TV::OSDDialogEvent(int result, QString text, QString action) |
10171 | 10187 | } |
10172 | 10188 | else if (valid && desc[0] == "CONFIRM") |
10173 | 10189 | { |
| 10190 | if (desc[1] == "RESUME" && desc[2] == "PLAYBACK") |
| 10191 | if (ContextIsPaused(actx, __FILE__, __LINE__)) |
| 10192 | gTV->DoTogglePause(actx, false); |
10174 | 10193 | } |
10175 | 10194 | else |
10176 | 10195 | { |