From 5c54c549abf993cc2476f2859d995536720e97ed Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 30 Jan 2011 14:44:09 -0800 Subject: [PATCH] Add current playing time on LCD displays with 4 rows or more Patch from #9391, slightly massaged to fit master. On LCD displays with 4 rows or more mythlcdserver uses only 3 rows (1, 2 and 4) when watching a show (Channel, Title and a progress bar). This commit fills row 3 with "elapsed time / total time". I kept consistency with how mythmusic shows the elapsed time. The time is only written when 4 or more rows are available. Signed-off-by: Gavin Hurlbut --- mythtv/libs/libmythbase/lcddevice.cpp | 5 +++-- mythtv/libs/libmythbase/lcddevice.h | 2 +- mythtv/libs/libmythtv/tv_play.cpp | 11 +++++++++-- mythtv/programs/mythlcdserver/lcdprocclient.cpp | 9 ++++++++- mythtv/programs/mythlcdserver/lcdprocclient.h | 3 ++- mythtv/programs/mythlcdserver/lcdserver.cpp | 6 +++--- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/mythtv/libs/libmythbase/lcddevice.cpp b/mythtv/libs/libmythbase/lcddevice.cpp index 67ddc87ffaf..e971b6a58c5 100644 --- a/mythtv/libs/libmythbase/lcddevice.cpp +++ b/mythtv/libs/libmythbase/lcddevice.cpp @@ -473,13 +473,14 @@ void LCD::setTunerLEDs(enum LCDTunerSet tuner, bool on) sendToServer(QString("UPDATE_LEDS %1").arg(lcd_ledmask)); } -void LCD::setChannelProgress(float value) +void LCD::setChannelProgress(const QString time, float value) { if (!lcd_ready || !lcd_showchannel) return; value = std::min(std::max(0.0f, value), 1.0f); - sendToServer(QString("SET_CHANNEL_PROGRESS %1").arg(value)); + sendToServer(QString("SET_CHANNEL_PROGRESS %1 %2").arg(quotedString(time)) + .arg(value)); } void LCD::setGenericProgress(float value) diff --git a/mythtv/libs/libmythbase/lcddevice.h b/mythtv/libs/libmythbase/lcddevice.h index 16353b81691..c8181821204 100644 --- a/mythtv/libs/libmythbase/lcddevice.h +++ b/mythtv/libs/libmythbase/lcddevice.h @@ -236,7 +236,7 @@ class MPUBLIC LCD : public QObject, public MythSocketCBs // While watching Live/Recording/Pause Buffer, occasionaly describe how // much of the program has been seen (between 0.0 and 1.0) // (e.g. [current time - start time] / [end time - start time] ) - void setChannelProgress(float percentViewed); + void setChannelProgress(const QString time, float percentViewed); // Show the Menu // QPtrList is a pointer to a bunch of menu items diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp index 92844947a66..d1a27cc8dfb 100644 --- a/mythtv/libs/libmythtv/tv_play.cpp +++ b/mythtv/libs/libmythtv/tv_play.cpp @@ -2930,6 +2930,7 @@ bool TV::HandleLCDTimerEvent(void) if (lcd) { float progress = 0.0f; + QString lcd_time_string; bool showProgress = true; if (StateIsLiveTV(GetState(actx))) @@ -2944,10 +2945,16 @@ bool TV::HandleLCDTimerEvent(void) if (showProgress) { osdInfo info; - if (actx->CalcPlayerSliderPosition(info)) + if (actx->CalcPlayerSliderPosition(info)) { progress = info.values["position"] * 0.001f; + + lcd_time_string = info.text["playedtime"] + " / " + info.text["totaltime"]; + // if the string is longer than the LCD width, remove all spaces + if (lcd_time_string.length() > (int)lcd->getLCDWidth()) + lcd_time_string.remove(' '); + } } - lcd->setChannelProgress(progress); + lcd->setChannelProgress(lcd_time_string, progress); } ReturnPlayerLock(actx); diff --git a/mythtv/programs/mythlcdserver/lcdprocclient.cpp b/mythtv/programs/mythlcdserver/lcdprocclient.cpp index 301a269e49b..7df20f47a77 100644 --- a/mythtv/programs/mythlcdserver/lcdprocclient.cpp +++ b/mythtv/programs/mythlcdserver/lcdprocclient.cpp @@ -473,6 +473,7 @@ void LCDProcClient::init() setPriority("Channel", LOW); sendToServer("widget_add Channel topWidget string"); sendToServer("widget_add Channel botWidget string"); + sendToServer("widget_add Channel timeWidget string"); sendToServer("widget_add Channel progressBar hbar"); // The Generic Screen @@ -1124,6 +1125,7 @@ void LCDProcClient::startChannel(QString channum, QString title, QString subtitl formatScrollingWidgets(); } + channel_time = ""; progress = 0.0; outputChannel(); } @@ -1679,12 +1681,13 @@ void LCDProcClient::setLevels(int numbLevels, float *values) } } -void LCDProcClient::setChannelProgress(float value) +void LCDProcClient::setChannelProgress(const QString &time, float value) { if (!lcd_ready) return; progress = value; + channel_time = time; if (progress < 0.0) progress = 0.0; @@ -2160,6 +2163,9 @@ void LCDProcClient::outputChannel() aString += " "; aString += QString::number((int)rint(progress * lcdWidth * cellWidth)); sendToServer(aString); + + if (lcdHeight >= 4) + outputCenteredText("Channel", channel_time, "timeWidget", 3); } else sendToServer("widget_set Channel progressBar 1 1 0"); @@ -2313,6 +2319,7 @@ void LCDProcClient::removeWidgets() { sendToServer("widget_del Channel progressBar"); sendToServer("widget_del Channel topWidget"); + sendToServer("widget_del Channel timeWidget"); sendToServer("screen_del Channel"); sendToServer("widget_del Generic progressBar"); diff --git a/mythtv/programs/mythlcdserver/lcdprocclient.h b/mythtv/programs/mythlcdserver/lcdprocclient.h index 5a31200fbad..a87339d3862 100644 --- a/mythtv/programs/mythlcdserver/lcdprocclient.h +++ b/mythtv/programs/mythlcdserver/lcdprocclient.h @@ -43,7 +43,7 @@ class LCDProcClient : public QObject void setLevels(int numbLevels, float *values); void switchToChannel(QString channum = "", QString title = "", QString subtitle = ""); - void setChannelProgress(float percentViewed); + void setChannelProgress(const QString &time, float percentViewed); void switchToMenu(QList *menuItems, QString app_name = "", bool popMenu = true); void switchToGeneric(QList *textItems); @@ -169,6 +169,7 @@ class LCDProcClient : public QObject float EQlevels[10]; float progress; + QString channel_time; /** true if the generic progress indicator is a busy (ie. doesn't have a known total steps */ bool busy_progress; diff --git a/mythtv/programs/mythlcdserver/lcdserver.cpp b/mythtv/programs/mythlcdserver/lcdserver.cpp index fce6036d559..7ffb2b0699f 100644 --- a/mythtv/programs/mythlcdserver/lcdserver.cpp +++ b/mythtv/programs/mythlcdserver/lcdserver.cpp @@ -579,7 +579,7 @@ void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket QString flat = tokens.join(" "); - if (tokens.count() != 2) + if (tokens.count() != 3) { VERBOSE(VB_IMPORTANT, "LCDServer: bad SET_CHANNEL_PROGRESS command: " << flat); @@ -588,7 +588,7 @@ void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket } bool bOK; - float progress = tokens[1].toFloat(&bOK); + float progress = tokens[2].toFloat(&bOK); if (!bOK) { VERBOSE(VB_IMPORTANT, "LCDServer: bad float value in " @@ -598,7 +598,7 @@ void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket } if (m_lcd) - m_lcd->setChannelProgress(progress); + m_lcd->setChannelProgress(tokens[1], progress); sendMessage(socket, "OK"); }