mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
hintbox: expand ShowHintS() with slot parameter
This allows to execute one ore more methods inside the ShowHintS() method. This should simplify calls of CHint messages with or without hide delays In the simplest or most cases, only one code line is necessary for this, see examples inside test_menu.cpp or here: Single methode: old: CHintBox *hintBox new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_GETPLUGINS_HINT)); hintBox->paint(); g_Plugins->loadPlugins(); sleep(1); hintBox->.hide(); delete hintbox; new: ShowHintS(LOCALE_SERVICEMENU_GETPLUGINS_HINT, 1, true, sigc::mem_fun(g_Plugins, &CPlugins::loadPlugins)); Multiple methods: old: 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; new: std::vector <hint_message_data_t> 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); slots can be used with sigc::bind, sigc::hide_return (or what ever) too. sample slot: sigc::slot<void> sl = sigc::bind(sigc::mem_fun(this, &ClassName::method), parameter); Note: Usage of namespace sigc are doing to simplify the lines, but this is a matter of discretion. TODO: - timeoutbar should visualize a kind of busy mode. - implemetations
This commit is contained in:
@@ -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<void> &Slot, int timeout, bool show_background)
|
||||
{
|
||||
int res = messages_return::none;
|
||||
|
||||
sigc::signal<void> 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<void> &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<void> &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<hint_message_data_t>& v_hint_data)
|
||||
{
|
||||
int ret = messages_return::none;
|
||||
for(size_t i=0; i<v_hint_data.size(); i++)
|
||||
{
|
||||
std::string txt = !v_hint_data.at(i).text.empty() ? v_hint_data.at(i).text : g_Locale->getText(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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user