diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index 99a3cace5..15dd92544 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -414,6 +414,7 @@ void CImageInfo::InitInfoText(const std::string& text) //add a caption for info contents Font * caption_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]; int caption_height = caption_font->getHeight(); + y_tmp = max(y_tmp, cc_tv->getYPos()+cc_tv->getHeight()); if (cc_sub_caption == NULL) cc_sub_caption = new CComponentsLabel(cc_info->getXPos(), y_tmp, cc_info->getWidth(), caption_height, g_Locale->getText(LOCALE_IMAGEINFO_LICENSE), CTextBox::AUTO_WIDTH, item_font); diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index 19b134237..4d2aae37b 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -2971,7 +2971,7 @@ bool CMovieBrowser::loadTsFileNamesFromDir(const std::string & dirname) CFileList flist; if (readDir(dirname, &flist) == true) { - for (unsigned int i = 0; i < flist.size(); i++) + for (size_t i = 0; i < flist.size(); i++) { if (S_ISDIR(flist[i].Mode)) { if (m_settings.ts_only || !CFileBrowser::checkBD(flist[i])) { @@ -2982,6 +2982,7 @@ bool CMovieBrowser::loadTsFileNamesFromDir(const std::string & dirname) } else { result |= addFile(flist[i], dirItNr); } + OnLoadFile(i, flist.size(), g_Locale->getText(LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES)); } //result = true; } @@ -3220,7 +3221,8 @@ void CMovieBrowser::loadMovies(bool doRefresh) { TRACE("[mb] loadMovies: \n"); - CHintBox loadBox((show_mode == MB_SHOW_YT) ? LOCALE_MOVIEPLAYER_YTPLAYBACK : LOCALE_MOVIEBROWSER_HEAD, g_Locale->getText(LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES)); + CProgressWindow loadBox((show_mode == MB_SHOW_YT) ? LOCALE_MOVIEPLAYER_YTPLAYBACK : LOCALE_MOVIEBROWSER_HEAD, 500, 150, show_mode == MB_SHOW_YT ? &ytparser.OnLoadVideoInfo : &OnLoadFile); + loadBox.enableShadow(); loadBox.paint(); if (show_mode == MB_SHOW_YT) { diff --git a/src/gui/moviebrowser/mb.h b/src/gui/moviebrowser/mb.h index 18f8ee91c..ae7c758d9 100644 --- a/src/gui/moviebrowser/mb.h +++ b/src/gui/moviebrowser/mb.h @@ -364,6 +364,7 @@ class CMovieBrowser : public CMenuTarget void clearSelection(); bool supportedExtension(CFile &file); bool addFile(CFile &file, int dirItNr); + sigc::signal OnLoadFile; }; // I tried a lot to use the menu.cpp as ListBox selection, and I got three solution which are all garbage. diff --git a/src/gui/widget/progresswindow.cpp b/src/gui/widget/progresswindow.cpp index f7c84e024..84c74e15d 100644 --- a/src/gui/widget/progresswindow.cpp +++ b/src/gui/widget/progresswindow.cpp @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Implementation of CComponent Window class. - Copyright (C) 2014 Thilo Graf 'dbt' + Copyright (C) 2014-2017 Thilo Graf 'dbt' License: GPL @@ -32,15 +32,42 @@ #include #include +using namespace sigc; +using namespace std; -CProgressWindow::CProgressWindow(CComponentsForm *parent) -: CComponentsWindow(0, 0, 700, 200, string(), NEUTRINO_ICON_INFO, parent, CC_SHADOW_ON) +CProgressWindow::CProgressWindow(CComponentsForm *parent, + const int &dx, + const int &dy, + signal *statusSignal, + signal *localSignal, + signal *globalSignal) + : CComponentsWindow(0, 0, dx, dy, string(), NEUTRINO_ICON_INFO, parent, CC_SHADOW_ON) { - Init(); + Init(statusSignal, localSignal, globalSignal); } -void CProgressWindow::Init() +CProgressWindow::CProgressWindow(const neutrino_locale_t title, + const int &dx, + const int &dy, + signal *statusSignal, + signal *localSignal, + signal *globalSignal) + : CComponentsWindow(0, 0, dx, dy, g_Locale->getText(title), NEUTRINO_ICON_INFO, NULL, CC_SHADOW_ON) { + Init(statusSignal, localSignal, globalSignal); +} + +void CProgressWindow::Init( signal *statusSignal, + signal *localSignal, + signal *globalSignal) +{ + if (statusSignal) + *statusSignal->connect(mem_fun(*this, &CProgressWindow::showStatus)); + if (localSignal) + *localSignal->connect(mem_fun(*this, &CProgressWindow::showLocalStatus)); + if (globalSignal) + *globalSignal->connect(mem_fun(*this, &CProgressWindow::showGlobalStatus)); + global_progress = local_progress = 100; showFooter(false); @@ -48,7 +75,7 @@ void CProgressWindow::Init() int x_item = 10; int y_item = 10; - setWidthP(75); + int w_item = width-2*x_item; int h_item = 14; int h_pbar = 20; @@ -60,6 +87,7 @@ void CProgressWindow::Init() status_txt->setDimensionsAll(x_item, y_item, w_item, h_txt); status_txt->setColorBody(col_body); status_txt->doPaintTextBoxBg(true); + status_txt->doPaintBg(false); addWindowItem(status_txt); y_item += h_txt + 10; @@ -86,7 +114,7 @@ void CProgressWindow::Init() y_item += 2*h_pbar; h_height = ccw_head->getHeight(); - height = y_item + h_height; + height = max(height, y_item + h_height); setCenterPos(); } @@ -100,7 +128,7 @@ void CProgressWindow::setTitle(const neutrino_locale_t title) #endif // VFD_UPDATE } -void CProgressWindow::setTitle(const std::string & title) +void CProgressWindow::setTitle(const string & title) { setWindowCaption(title); @@ -121,7 +149,7 @@ void CProgressWindow::fitItems() } } -void CProgressWindow::showStatus(const unsigned int prog) +void CProgressWindow::showStatus(const unsigned int prog, const unsigned int max, const string &statusText) { if (global_progress == prog) return; @@ -132,17 +160,19 @@ void CProgressWindow::showStatus(const unsigned int prog) global_bar->setHeight(g_height + g_height/2); } - showGlobalStatus(prog); + showGlobalStatus(prog, max, statusText); } -void CProgressWindow::showGlobalStatus(const unsigned int prog) +void CProgressWindow::showGlobalStatus(const unsigned int prog, const unsigned int max, const string &statusText) { if (global_progress == prog) return; global_bar->allowPaint(true); global_progress = prog; - global_bar->setValues(prog, 100); + global_bar->setValues(prog, (int)max); + if (!statusText.empty()) + showStatusMessageUTF(statusText); global_bar->paint(false); #ifdef VFD_UPDATE @@ -150,14 +180,16 @@ void CProgressWindow::showGlobalStatus(const unsigned int prog) #endif // VFD_UPDATE } -void CProgressWindow::showLocalStatus(const unsigned int prog) +void CProgressWindow::showLocalStatus(const unsigned int prog, const unsigned int max, const string &statusText) { if (local_progress == prog) return; local_bar->allowPaint(true); local_progress = prog; - local_bar->setValues(prog, 100); + local_bar->setValues(prog, (int)max); + if (!statusText.empty()) + showStatusMessageUTF(statusText); local_bar->paint(false); #ifdef VFD_UPDATE @@ -167,7 +199,7 @@ void CProgressWindow::showLocalStatus(const unsigned int prog) #endif // VFD_UPDATE } -void CProgressWindow::showStatusMessageUTF(const std::string & text) +void CProgressWindow::showStatusMessageUTF(const string & text) { string txt = text; int w_txt = status_txt->getWidth(); @@ -192,7 +224,7 @@ void CProgressWindow::hide() CComponentsWindow::hide(); } -int CProgressWindow::exec(CMenuTarget* parent, const std::string & /*actionKey*/) +int CProgressWindow::exec(CMenuTarget* parent, const string & /*actionKey*/) { if(parent) { diff --git a/src/gui/widget/progresswindow.h b/src/gui/widget/progresswindow.h index 6b8ff9e72..811b5714a 100644 --- a/src/gui/widget/progresswindow.h +++ b/src/gui/widget/progresswindow.h @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Implementation of CComponent Window class. - Copyright (C) 2014 Thilo Graf 'dbt' + Copyright (C) 2014-2017 Thilo Graf 'dbt' License: GPL @@ -38,24 +38,189 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget unsigned int local_progress; int w_bar_frame; int h_height; - void Init(); + void Init( sigc::signal *statusSignal, + sigc::signal *localSignal, + sigc::signal *globalSignal); void fitItems(); public: + /**CProgressWindow Constructor + * @param[in] parent + * @li optional: expects type CComponentsForm * as possible parent object, default = NULL + * @param[in] dx + * @li optional: expects type const &int, width of window, default = 0, auto size with declared default values + * @param[in] dy + * @li optional: expects type const &int, height of window, default = 0, auto size with declared default values + * @param[in] status_Signal + * @li optional: expects type sigc::signal, defines an optional signal container for + * current changing values. + * @param[in] localSignal + * @li optional: expects type sigc::signal, defines an optional signal container for + * current changing local values. + * @param[in] globalSignal + * @li optional: expects type sigc::signal, defines an optional signal container for + * current changing global values. + * + * @example + * void CFooClass::DoCount{ + * //Usage with classic init inside method: + * + * //Create a CProgressWindow object + * CProgressWindow progress; + * + * //set possible properties, eg. like here we dont't need a header + * status.showHeader(false); + * + * //paint window + * status.paint(); + * + * //set possible properties, like current status text + * status.showStatusMessageUTF("test progress"); + * + * //set current progress, call functions, methods or use a while, next loop or what ever + * status.showStatus(25) + * + * //finally remove window from screen + * status.hide(); + * } + * + * //That's it. Until now these steps are a classical way inside neutrino, but you can use proress window with signals too. + * //Working with signals have the advantage that the implementation could be more compactly, because + * //complex constructions within the classes are usually unnecessary, + * //beacuse of the signals can be installed where they directly take the required values. See next example: + * + * class CFooClass + * { + * //Usage with signals: + * //declare a signal eg. in header file + * private: + * //other members... + * sigc::signal OnProgress; + * //other members... + * public: + * //other members... + * void DoAnything(); + * //other members... + * }; + * + * //add the OnProgress signal into a counter methode + * void CFooClass::DoCount{ + * size_t max = 10 + * for (size_t i = 0; i < max; i++){ + * OnProgress(i, max, "Test"); + * } + * } + * + * void CFooClass::DoAnything{ + * //inside of methode which calls the progress define a CProgressWindow object and the counter method: + * //...any code + * CProgressWindow progress(NULL, 500, 150, &OnProgress); + * //paint window + * progress.paint(); // paint() + * + * //... + * + * DoCount(); + * + * //... + * + * //finally remove window from screen + * progress.hide(); + * } + * @note + * Don't use status_Signal at same time with localSignal and globalSignal. In This case please set status_Signal = NULL + */ + CProgressWindow(CComponentsForm *parent = NULL, + const int &dx = 700, + const int &dy = 200, + sigc::signal *status_Signal = NULL, + sigc::signal *localSignal = NULL, + sigc::signal *globalSignal = NULL); - CProgressWindow(CComponentsForm *parent = NULL); + /**CProgressWindow Constructor + * @param[in] title + * @li expects type neutrino_locale_t as window title + * + * @see For other arguments and examples, see related constructor(s) + */ + CProgressWindow(const neutrino_locale_t title, + const int &dx = 700, + const int &dy = 200, + sigc::signal *status_Signal = NULL, + sigc::signal *localSignal = NULL, + sigc::signal *globalSignal = NULL); + + /**Sets titel of window + * @param[in] title + * @li expects type neutrino_locale_t as window title + */ void setTitle(const neutrino_locale_t title); + + /**Sets titel of window + * @param[in] title + * @li expects type std::string as window title + */ + void setTitle(const std::string & title); + + /** + * Remove window from screen, restores background. + */ virtual void hide(); + /** + * Executes the exec contents. In this case it will paint the window and remove possible parents from screen + * @param[in] parent + * @li optional: expects type CMenuTarget* + * @param[in] actionKey + * @li optional: without effect + * @return int = menu_return::RETURN_REPAINT + */ virtual int exec( CMenuTarget* parent, const std::string & actionKey ); - void showStatus(const unsigned int prog); - void showGlobalStatus(const unsigned int prog); + /** + * Sets current progress value and show progress in window. + * @param[in] prog + * @li expects type unsigned int, describes current progress value + * @param[in] max + * @li optional: expects type unsigned int, describes maximal progress value, default = 100 + * @param[in] statusText + * @li optional: expects type std::string, describes current status text, default = empty + */ + void showStatus(const unsigned int prog, const unsigned int max = 100, const std::string &statusText = std::string()); + + /** + * Sets current local progressbar value and show progress in window. + * @note For other arguments take a look to related method showStatus() + * @see showStatus() + */ + void showLocalStatus(const unsigned int prog, const unsigned int max = 100, const std::string &statusText = std::string()); + + /** + * Sets current global progressbar value and show progress in window. + * @note For other arguments take a look to related method showStatus() + * @see showStatus() + */ + void showGlobalStatus(const unsigned int prog, const unsigned int max = 100, const std::string &statusText = std::string()); + + /** + * Gets current progress value + * @return unsigned int + */ unsigned int getGlobalStatus(void); - void showLocalStatus(const unsigned int prog); + + /** + * Sets current progress value and show progress in window. + * @param[in] text + * @li expects type std::string, describes current status text + */ void showStatusMessageUTF(const std::string & text); // UTF-8 + + /** + * Paint window + * @param[in] do_save_bg + * @li optional: expects type bool, sets background save mode + */ void paint(bool do_save_bg = true); - void setTitle(const std::string & title); }; diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index 928df3afe..3c558ee1b 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -323,6 +323,7 @@ bool cYTFeedParser::parseFeedJSON(std::string &answer) Json::Value elements = root["items"]; for(unsigned int i=0; igetText(LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES)); #ifdef DEBUG_PARSER printf("=========================================================\n"); printf("Element %d in elements\n", i); diff --git a/src/system/ytparser.h b/src/system/ytparser.h index adb30ba67..c54c2239b 100644 --- a/src/system/ytparser.h +++ b/src/system/ytparser.h @@ -27,7 +27,7 @@ #include #include #include - +#include #include #include @@ -155,6 +155,8 @@ class cYTFeedParser void SetMaxResults(int count) { max_results = count; } void SetConcurrentDownloads(int count) { concurrent_downloads = count; } void SetThumbnailDir(std::string &_thumbnail_dir); + + sigc::signal OnLoadVideoInfo; }; #endif