diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 307f52951..efde48b41 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -1010,7 +1010,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) DisplayInfoMessage("Info Test!"); return menu_return::RETURN_REPAINT; } - else if (actionKey == "short_hint"){ + else if (actionKey == "short_hint with sleep and CHint instance"){ CHint *hint = new CHint("Info Test!"); // Set the message window outside of screen mid to demonstrate the hide behavior, // so that the hide behavior will not be influenced by any other window or menu. @@ -1027,6 +1027,41 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) ShowHintS("Info Test...", 3, true); return menu_return::RETURN_REPAINT; } + else if (actionKey == "short_hint_timed_slot"){ + ShowHintS("Info test with function...", sigc::mem_fun(*this, &CTestMenu::showRecords), 3); + return menu_return::RETURN_REPAINT; + } + else if (actionKey == "short_hint_struct"){ + hint_message_data_t hint; + hint.text = "Info Test..."; + hint.slot = sigc::mem_fun(*this, &CTestMenu::showRecords); + hint.timeout = 3; + ShowHintS(hint); + return menu_return::RETURN_REPAINT; + } + else if (actionKey=="restarttuner") + { +#if 0 +// use with CHint instance + CHint *hint = new CHint("Restart Tuner"); + hint->paint(); + g_Zapit->setStandby(true); + sleep(2); + g_Zapit->setStandby(false); + sleep(2); + g_Zapit->Rezap(); + delete hint; +#endif +// Use of ShowHintS with slot does the same like previous block, +// but with multiple messages and despite that with lesser effort. + std::vector hints; + hints.push_back({sigc::bind(sigc::mem_fun(g_Zapit, &CZapitClient::setStandby), true),"Stopping tuner...", NONEXISTANT_LOCALE, 2, true}); + hints.push_back({sigc::bind(sigc::mem_fun(g_Zapit, &CZapitClient::setStandby), false), "Start tuner...", NONEXISTANT_LOCALE, 2, true}); + hints.push_back({sigc::hide_return(sigc::mem_fun(g_Zapit, &CZapitClient::Rezap)), "Rezap...", NONEXISTANT_LOCALE, 2, true}); + ShowHintS(hints); + + return menu_return::RETURN_REPAINT; + } else if (actionKey == "shellwindow"){ sigc::slot3 sl_shell_output; sl_shell_output = sigc::mem_fun(*this, &CTestMenu::handleShellOutput); @@ -1277,6 +1312,8 @@ void CTestMenu::showHWTests(CMenuWidget *widget) #endif widget->addItem(new CMenuForwarder("HDD", true, NULL, this, "hdd")); widget->addItem(new CMenuForwarder("SD/MMC", true, NULL, this, "mmc")); + widget->addItem(new CMenuForwarder("Tuner Reset", true, NULL, this, "restarttuner")); + #if 0 //some parts DEPRECATED for (unsigned i = 0; i < sizeof(test_pos)/sizeof(int); i++) { CServiceManager::getInstance()->InitSatPosition(test_pos[i], NULL, true); @@ -1347,6 +1384,8 @@ void CTestMenu::showMsgTests(CMenuWidget *widget) widget->addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, "Short Hint")); widget->addItem(new CMenuForwarder("Short hint!", true, NULL, this, "short_hint")); widget->addItem(new CMenuForwarder("Short hint with timeout!", true, NULL, this, "short_hint_timed")); + widget->addItem(new CMenuForwarder("Short hint with timeout and function!", true, NULL, this, "short_hint_timed_slot")); + widget->addItem(new CMenuForwarder("Short hint with struct arg!", true, NULL, this, "short_hint_struct")); } void CTestMenu::showSeparatorTypes(CMenuWidget *widget) diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 59768df4d..18387bb3f 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -497,7 +497,6 @@ CHint::CHint(const neutrino_locale_t Text, bool show_background) : CHintBox("" , int ShowHintS(const char * const Text, int timeout, bool show_background) { int res = messages_return::none; - CHint hint(Text, show_background); hint.setTimeOut(timeout); hint.paint(); @@ -511,3 +510,55 @@ int ShowHintS(const neutrino_locale_t Text, int timeout, bool show_background) { return ShowHintS(g_Locale->getText(Text), timeout, show_background); } + +int ShowHintS(const std::string& Text, int timeout, bool show_background) +{ + return ShowHintS(Text.c_str(), timeout, show_background); +} + +int ShowHintS(const char * const Text, const sigc::slot &Slot, int timeout, bool show_background) +{ + int res = messages_return::none; + + sigc::signal OnCall; + OnCall.connect(Slot); + CHint hint(Text, show_background); + hint.setTimeOut(timeout); + hint.paint(); + OnCall(); + res = hint.exec(); + hint.hide(); + + return res; +} + +int ShowHintS(const neutrino_locale_t Text, const sigc::slot &Slot, int timeout, bool show_background) +{ + return ShowHintS(g_Locale->getText(Text), Slot, timeout, show_background); +} + +int ShowHintS(const std::string& Text, const sigc::slot &Slot, int timeout, bool show_background) +{ + return ShowHintS(Text.c_str(), Slot, timeout, show_background); +} + +int ShowHintS(const hint_message_data_t &hint_data) +{ + std::string text = !hint_data.text.empty() ? hint_data.text : g_Locale->getText(hint_data.text_locale); + return ShowHintS(text, hint_data.slot, hint_data.timeout, hint_data.show_background); +} + +int ShowHintS(const std::vector& v_hint_data) +{ + int ret = messages_return::none; + for(size_t i=0; igetText(v_hint_data.at(i).text_locale); + ret = ShowHintS(txt, + v_hint_data.at(i).slot, + v_hint_data.at(i).timeout, + v_hint_data.at(i).show_background); + } + + return ret; +} diff --git a/src/gui/widget/hintbox.h b/src/gui/widget/hintbox.h index 05824c64b..d8b0419ea 100644 --- a/src/gui/widget/hintbox.h +++ b/src/gui/widget/hintbox.h @@ -371,17 +371,58 @@ class CHint : public CHintBox virtual ~CHint(){}; }; + +typedef struct hint_message_data_t +{ + sigc::slot slot; + std::string text; + neutrino_locale_t text_locale; + int timeout; + bool show_background; +// hint_message_data_t(): text(std::string()), +// text_locale(NONEXISTANT_LOCALE), +// timeout(HINTBOX_DEFAULT_TIMEOUT), +// show_background(true){} +} hint_message_data_struct_t; + /** * Simplified methodes to show hintboxes without titlebar and footer * Text is UTF-8 encoded +* @param[in] Text +* @li expects type neutrino_locale_t or const char* * @param[in] timeout -* @li optional: expects type int as seconds, default = HINTBOX_DEFAULT_TIMEOUT (get from settings) +* @li optional: expects type int as seconds, default = HINTBOX_DEFAULT_TIMEOUT (get from settings) * @param[in] show_background * @li optional: expects type bool, enable/disable backround paint, default = true * @see for possible text parameters take a look to CHintBox() */ int ShowHintS(const neutrino_locale_t Text, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true); int ShowHintS(const char * const Text, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true); +int ShowHintS(const std::string &Text, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true); +/** + * Simplified methodes to show hintboxes without titlebar and footer with mounted function as slot for custom action + * Text is UTF-8 encoded + * @param[in] Text + * @li expects type neutrino_locale_t or const char* + * @param[in] Slot + * @li expects sigc::slot + * @li example: + * @li sigc::slot sl = sigc::mem_fun(g_Plugins, &CPlugins::loadPlugins);\n + * ShowHintS(LOCALE_SERVICEMENU_GETPLUGINS_HINT, 1, true, &sl); + * @li or use a function with parameter(s): + * sigc::slot sl = sigc::bind(sigc::mem_fun(*this, &CMyClass::foo), arg1, arg2, arg3, arg4);\n + * ShowHintS(LOCALE_SERVICEMENU_GETPLUGINS_HINT, 1, true, &sl); + * @param[in] timeout + * @li optional: expects type int as seconds, default = HINTBOX_DEFAULT_TIMEOUT (get from settings) + * @param[in] show_background + * @li optional: expects type bool, enable/disable backround paint, default = true + */ +int ShowHintS(const neutrino_locale_t Text, const sigc::slot &Slot, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true); +int ShowHintS(const char * const Text, const sigc::slot &Slot, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true); +int ShowHintS(const std::string &Text, const sigc::slot &Slot, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true); + +int ShowHintS(const hint_message_data_t &hint_data); +int ShowHintS(const std::vector &v_hint_data); #endif