From 7466d6f19c08aa0d90ba5aca02897c6783d73570 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Fri, 22 Nov 2013 08:52:08 +0100 Subject: [PATCH] InfoClock: Fix display clock in movie browser, file browser etc. --- src/gui/components/cc_frm_clock.cpp | 3 +-- src/gui/infoclock.cpp | 16 +++++++++++ src/gui/infoclock.h | 1 + src/gui/mediaplayer.cpp | 4 +++ src/gui/movieplayer.cpp | 12 ++++++--- src/gui/pictureviewer.cpp | 4 +++ src/gui/timeosd.cpp | 8 ++---- src/gui/upnpbrowser.cpp | 4 +++ src/gui/volumebar.cpp | 3 --- src/neutrino.cpp | 42 ++++++++++++----------------- 10 files changed, 57 insertions(+), 40 deletions(-) diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index 26afa3ea7..7e0493176 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -251,8 +251,6 @@ void* CComponentsFrmClock::initClockThread(void *arg) time_t count = time(0); //start loop for paint while(1) { - sleep(clock->cl_interval); - if (clock->paintClock) { //refresh item property values clock->refresh(); @@ -265,6 +263,7 @@ void* CComponentsFrmClock::initClockThread(void *arg) clock->cl_thread = 0; break; } + sleep(clock->cl_interval); } return 0; } diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index 876cce7b7..fd58fccd3 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -94,3 +94,19 @@ void CInfoClock::paint(bool do_save_bg) //paint the clock paintForm(do_save_bg); } + +bool CInfoClock::enableInfoClock(bool enable) +{ + bool ret = false; + if (g_settings.mode_clock) { + if (enable) { + if (!paintClock) + ret = StartClock(); + } + else { + if (paintClock) + ret = StopClock(); + } + } + return ret; +} diff --git a/src/gui/infoclock.h b/src/gui/infoclock.h index ffa67fb20..ebefb2686 100644 --- a/src/gui/infoclock.h +++ b/src/gui/infoclock.h @@ -45,6 +45,7 @@ class CInfoClock : public CComponentsFrmClock bool StartClock(); bool StopClock(); + bool enableInfoClock(bool enable); void ClearDisplay(); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); }; diff --git a/src/gui/mediaplayer.cpp b/src/gui/mediaplayer.cpp index f3ce226ce..fd577a8ab 100644 --- a/src/gui/mediaplayer.cpp +++ b/src/gui/mediaplayer.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include #if ENABLE_UPNP @@ -52,6 +53,7 @@ #include #include extern cVideo * videoDecoder; +extern CInfoClock *InfoClock; CMediaPlayerMenu::CMediaPlayerMenu() { @@ -106,6 +108,7 @@ int CMediaPlayerMenu::exec(CMenuTarget* parent, const std::string &actionKey) else if (actionKey == "movieplayer") { audiomute->enableMuteIcon(false); + InfoClock->enableInfoClock(false); int mode = CNeutrinoApp::getInstance()->getMode(); if( mode == NeutrinoMessages::mode_radio ) videoDecoder->StopPicture(); @@ -113,6 +116,7 @@ int CMediaPlayerMenu::exec(CMenuTarget* parent, const std::string &actionKey) if( mode == NeutrinoMessages::mode_radio ) videoDecoder->ShowPicture(DATADIR "/neutrino/icons/radiomode.jpg"); audiomute->enableMuteIcon(true); + InfoClock->enableInfoClock(true); return res; } diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 1b9ae1f4a..05a1349a6 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -203,6 +203,7 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) } else if (actionKey == "ytplayback") { CAudioMute::getInstance()->enableMuteIcon(false); + InfoClock->enableInfoClock(false); isMovieBrowser = true; moviebrowser->setMode(MB_SHOW_YT); } @@ -245,8 +246,10 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); - if (moviebrowser->getMode() == MB_SHOW_YT) + if (moviebrowser->getMode() == MB_SHOW_YT) { CAudioMute::getInstance()->enableMuteIcon(true); + InfoClock->enableInfoClock(true); + } if (timeshift){ timeshift = 0; @@ -399,6 +402,7 @@ bool CMoviePlayerGui::SelectFile() } else { // filebrowser CAudioMute::getInstance()->enableMuteIcon(false); + InfoClock->enableInfoClock(false); if (filebrowser->exec(Path_local.c_str()) == true) { Path_local = filebrowser->getCurrentDir(); CFile *file; @@ -437,6 +441,7 @@ bool CMoviePlayerGui::SelectFile() } else menu_ret = filebrowser->getMenuRet(); CAudioMute::getInstance()->enableMuteIcon(true); + InfoClock->enableInfoClock(true); } if(ret && file_name.empty()) { std::string::size_type pos = full_name.find_last_of('/'); @@ -573,6 +578,7 @@ void CMoviePlayerGui::PlayFile(void) } CAudioMute::getInstance()->enableMuteIcon(true); + InfoClock->enableInfoClock(true); while (playstate >= CMoviePlayerGui::PLAY) { @@ -835,9 +841,7 @@ void CMoviePlayerGui::PlayFile(void) restoreNeutrino(); CAudioMute::getInstance()->enableMuteIcon(false); - - if (g_settings.mode_clock) - InfoClock->StartClock(); + InfoClock->enableInfoClock(false); } void CMoviePlayerGui::callInfoViewer(/*const int duration, const int curr_pos*/) diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index 58ef0afe8..fcf8292ef 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -72,6 +73,7 @@ #include extern cVideo * videoDecoder; +extern CInfoClock *InfoClock; //------------------------------------------------------------------------ bool comparePictureByDate (const CPicture& a, const CPicture& b) @@ -254,6 +256,7 @@ int CPictureViewerGui::show() m_currentTitle = m_audioPlayer->getAudioPlayerM_current(); CAudioMute::getInstance()->enableMuteIcon(false); + InfoClock->enableInfoClock(false); while (loop) { @@ -638,6 +641,7 @@ int CPictureViewerGui::show() hide(); CAudioMute::getInstance()->enableMuteIcon(true); + InfoClock->enableInfoClock(true); return(res); } diff --git a/src/gui/timeosd.cpp b/src/gui/timeosd.cpp index 0978e927d..dedbfc780 100644 --- a/src/gui/timeosd.cpp +++ b/src/gui/timeosd.cpp @@ -54,8 +54,7 @@ CTimeOSD::~CTimeOSD() void CTimeOSD::show(time_t time_show) { - if (g_settings.mode_clock) - InfoClock->StartClock(); + InfoClock->enableInfoClock(false); GetDimensions(); visible = true; @@ -77,8 +76,6 @@ void CTimeOSD::GetDimensions() m_width = g_Font[TIMEOSD_FONT]->getRenderWidth("00:00:00"); t1 = g_Font[TIMEOSD_FONT]->getRenderWidth(widest_number); m_width += t1; - if(g_settings.mode_clock) - m_xend = m_xend - m_width - (m_width/4); } void CTimeOSD::update(time_t time_show) @@ -142,8 +139,7 @@ void CTimeOSD::hide() if(!visible) return; - if (g_settings.mode_clock) - InfoClock->StopClock(); + InfoClock->enableInfoClock(true); //GetDimensions(); frameBuffer->paintBackgroundBoxRel(m_xend - m_width - t1, m_y, m_width, m_height); diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index ef771c75b..f5ea2e49d 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -51,6 +51,7 @@ #include #include +#include #include #include @@ -66,6 +67,7 @@ extern cVideo * videoDecoder; extern CPictureViewer * g_PicViewer; +extern CInfoClock *InfoClock; const struct button_label RescanButton = {NEUTRINO_ICON_BUTTON_BLUE , LOCALE_UPNPBROWSER_RESCAN}; const struct button_label BrowseButtons[4] = @@ -453,6 +455,7 @@ void CUpnpBrowserGui::selectDevice() return; CAudioMute::getInstance()->enableMuteIcon(false); + InfoClock->enableInfoClock(false); while (loop) { @@ -542,6 +545,7 @@ printf("msg: %x\n", (int) msg); } } CAudioMute::getInstance()->enableMuteIcon(true); + InfoClock->enableInfoClock(true); } void CUpnpBrowserGui::playnext(void) diff --git a/src/gui/volumebar.cpp b/src/gui/volumebar.cpp index 755489e93..0f55401f5 100644 --- a/src/gui/volumebar.cpp +++ b/src/gui/volumebar.cpp @@ -107,9 +107,6 @@ void CVolumeBar::initVolumeBarSize() mute_corrY = (height - mute_dy) / 2; cvh->setMuteIconCorrY(mute_corrY); - if ((g_settings.mode_clock) && (!CNeutrinoApp::getInstance()->isMuted())) - CInfoClock::getInstance()->ClearDisplay(); - vb_pbh = height-8; vb_pby = height/2-vb_pbh/2; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 2fcb1463e..175f9e988 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2056,8 +2056,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) else if( msg == CRCInput::RC_text) { g_RCInput->clearRCMsg(); - if(g_settings.mode_clock) - InfoClock->StopClock(); + InfoClock->enableInfoClock(false); StopSubtitles(); tuxtx_stop_subtitle(); @@ -2067,19 +2066,16 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) //if(!g_settings.cacheTXT) // tuxtxt_stop(); g_RCInput->clearRCMsg(); - if(g_settings.mode_clock) - InfoClock->StartClock(); + InfoClock->enableInfoClock(true); StartSubtitles(); } else if( msg == CRCInput::RC_setup ) { if(!g_settings.minimode) { StopSubtitles(); - if(g_settings.mode_clock) - InfoClock->StopClock(); + InfoClock->enableInfoClock(false); int old_ttx = g_settings.cacheTXT; mainMenu.exec(NULL, ""); - if(g_settings.mode_clock) - InfoClock->StartClock(); + InfoClock->enableInfoClock(true); StartSubtitles(); saveSetup(NEUTRINO_SETTINGS_FILE); if (!g_settings.epg_scan) @@ -2146,8 +2142,8 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) else if( msg == (neutrino_msg_t) g_settings.key_zaphistory ) { // Zap-History "Bouquet" if(g_settings.mode_clock && g_settings.key_zaphistory == CRCInput::RC_home) { - g_settings.mode_clock=false; - InfoClock->StopClock(); + InfoClock->enableInfoClock(false); + g_settings.mode_clock = false; } else { numericZap( msg ); } @@ -2306,8 +2302,8 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) else { if (msg == CRCInput::RC_home) { if(g_settings.mode_clock && g_settings.key_zaphistory == CRCInput::RC_home) { - g_settings.mode_clock=false; - InfoClock->StopClock(); + InfoClock->enableInfoClock(false); + g_settings.mode_clock = false; } CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); } @@ -2332,8 +2328,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) int CNeutrinoApp::showChannelList(const neutrino_msg_t _msg, bool from_menu) { neutrino_msg_t msg = _msg; - if(g_settings.mode_clock) - InfoClock->StopClock(); + InfoClock->enableInfoClock(false); StopSubtitles(); @@ -2417,8 +2412,8 @@ _repeat: goto _show; } - if(!from_menu && g_settings.mode_clock) - InfoClock->StartClock(); + if (!from_menu) + InfoClock->enableInfoClock(true); return ((nNewChannel >= 0) ? menu_return::RETURN_EXIT_ALL : menu_return::RETURN_REPAINT); } @@ -3308,9 +3303,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) } CVFD::getInstance()->setBacklight(g_settings.backlight_standby); - if(g_settings.mode_clock) { - InfoClock->StopClock(); - } + InfoClock->enableInfoClock(false); //remember tuned channel-id standby_channel_id = CZapit::getInstance()->GetCurrentChannelID(); @@ -3389,8 +3382,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) g_Sectionsd->setPauseScanning(false); //g_Sectionsd->setServiceChanged(live_channel_id, true ); - if(g_settings.mode_clock) - InfoClock->StartClock(); + InfoClock->enableInfoClock(true); g_audioMute->AudioMute(current_muted, true); StartSubtitles(); @@ -3454,11 +3446,11 @@ void CNeutrinoApp::switchTvRadioMode(const int prev_mode) void CNeutrinoApp::switchClockOnOff() { if(g_settings.mode_clock) { - g_settings.mode_clock=false; - InfoClock->StopClock(); + InfoClock->enableInfoClock(false); + g_settings.mode_clock = false; } else { - g_settings.mode_clock=true; - InfoClock->StartClock(); + g_settings.mode_clock = true; + InfoClock->enableInfoClock(true); } }