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:
@@ -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 <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);
|
||||
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
else if (actionKey == "shellwindow"){
|
||||
sigc::slot3<void, std::string*, int *, bool *> 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)
|
||||
|
Reference in New Issue
Block a user