Messages: try to fix API message handling

Passed timeout for messeages an popup's fired by yWeb API was not really
ok.
For popups now we have a setting with default value of 6 seconds timeout
Popups fired with ShowHint() use this as default. Value of 0 and -1
are ignored.
Messages fired with ShowMsg() should be fixed and interpret
value 0 or -1 as no timeout and will remain on the screen.


Origin commit data
------------------
Commit: 8b97f72ed1
Author: Thilo Graf <dbt@novatux.de>
Date: 2016-11-22 (Tue, 22 Nov 2016)
This commit is contained in:
2016-11-22 10:32:10 +01:00
parent e2afccba70
commit 97b57a783d
8 changed files with 24 additions and 12 deletions

View File

@@ -196,6 +196,10 @@ int CHintBox::exec()
neutrino_msg_t msg;
neutrino_msg_data_t data;
int res = messages_return::none;
if (timeout == NO_TIMEOUT || timeout == 0)
timeout = HINTBOX_DEFAULT_TIMEOUT;
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout );
if (timeout > 0)

View File

@@ -35,7 +35,8 @@
#define HINTBOX_MIN_WIDTH 420
#define HINTBOX_MIN_HEIGHT 125
#define HINTBOX_MAX_HEIGHT 520
#define HINTBOX_DEFAULT_TIMEOUT 5
#define HINTBOX_DEFAULT_TIMEOUT g_settings.timing[SNeutrinoSettings::TIMING_POPUP_MESSAGES]
#define NO_TIMEOUT -1
//frame around hint container as indent
#define W_FRAME std::max(HINTBOX_MIN_WIDTH, HINTBOX_MIN_HEIGHT) * 2/100
//frame color around hint/message box
@@ -328,7 +329,7 @@ class CHint : public CHintBox
* Simplified methodes to show hintboxes without titlebar and footer
* Text is UTF-8 encoded
* @param[in] timeout
* @li optional: exepts type int as seconds, default = HINTBOX_DEFAULT_TIMEOUT (5 sec)
* @li optional: exepts type int as seconds, default = HINTBOX_DEFAULT_TIMEOUT (get from settings)
* @param[in] show_background
* @li optional: exepts type bool, enable/disable backround paint, default = true
* @see for possible text parameters take a look to CHintBox()

View File

@@ -236,6 +236,9 @@ int CMsgBox::exec()
ccw_footer->getSelectedButtonObject()->setButtonAlias(mb_show_button);
int selected = ccw_footer->getSelectedButton();
if (timeout == NO_TIMEOUT)
timeout = 0;
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
if (timeout > 0)
@@ -432,7 +435,7 @@ int ShowMsg2UTF( const neutrino_locale_t Title,
const int& Text_mode,
fb_pixel_t color_frame)
{
int result = ShowMsg( g_Locale->getText(Title), Text, Default, ShowButtons, Icon, Width, Timeout, returnDefaultOnTimeout, Text_mode, color_frame);
int result = ShowMsg2UTF(g_Locale->getText(Title), Text, Default, ShowButtons, Icon, Width, Timeout, returnDefaultOnTimeout, Text_mode, color_frame);
return (result);
}

View File

@@ -321,7 +321,7 @@ int ShowMsg2UTF( const neutrino_locale_t Title,
const uint32_t ShowButtons,
const char * const Icon = NULL,
const int Width = MSGBOX_MIN_WIDTH,
const int Timeout = -1,
const int Timeout = NO_TIMEOUT,
bool returnDefaultOnTimeout = false,
const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE,
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
@@ -332,7 +332,7 @@ int ShowMsg2UTF( const char * const Title,
const uint32_t ShowButtons,
const char * const Icon = NULL,
const int Width = MSGBOX_MIN_WIDTH,
const int Timeout = -1,
const int Timeout = NO_TIMEOUT,
bool returnDefaultOnTimeout = false,
const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE,
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
@@ -343,7 +343,7 @@ int ShowMsg( const neutrino_locale_t Title,
const uint32_t ShowButtons,
const char * const Icon = NULL,
const int Width = MSGBOX_MIN_WIDTH,
const int Timeout = -1,
const int Timeout = NO_TIMEOUT,
bool returnDefaultOnTimeout = false,
const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE,
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
@@ -354,7 +354,7 @@ int ShowMsg( const char * const Title,
const uint32_t ShowButtons,
const char * const Icon = NULL,
const int Width = MSGBOX_MIN_WIDTH,
const int Timeout = -1,
const int Timeout = NO_TIMEOUT,
bool returnDefaultOnTimeout = false,
const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE,
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
@@ -365,7 +365,7 @@ int ShowMsg( const neutrino_locale_t Title,
const uint32_t ShowButtons,
const char * const Icon = NULL,
const int Width = MSGBOX_MIN_WIDTH,
const int Timeout = -1,
const int Timeout = NO_TIMEOUT,
bool returnDefaultOnTimeout = false,
const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE,
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
@@ -376,7 +376,7 @@ int ShowMsg( const neutrino_locale_t Title,
const uint32_t ShowButtons,
const char * const Icon = NULL,
const int Width = MSGBOX_MIN_WIDTH,
const int Timeout = -1,
const int Timeout = NO_TIMEOUT,
bool returnDefaultOnTimeout = false,
const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE,
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
@@ -387,7 +387,7 @@ int ShowMsg( const std::string & Title,
const uint32_t ShowButtons,
const char * const Icon = NULL,
const int Width = MSGBOX_MIN_WIDTH,
const int Timeout = -1,
const int Timeout = NO_TIMEOUT,
bool returnDefaultOnTimeout = false,
const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE,
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8

View File

@@ -3350,7 +3350,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
}
else if (msg == NeutrinoMessages::EVT_POPUP || msg == NeutrinoMessages::EVT_EXTMSG) {
if (mode != mode_scart && mode != mode_standby) {
int timeout = HINTBOX_DEFAULT_TIMEOUT;
int timeout = NO_TIMEOUT;
std::string text = (char*)data;
std::string::size_type pos;

View File

@@ -2433,6 +2433,7 @@ typedef enum
LOCALE_TIMING_INFOBAR_RADIO,
LOCALE_TIMING_MENU,
LOCALE_TIMING_NUMERICZAP,
LOCALE_TIMING_POPUP_MESSAGES,
LOCALE_TIMING_VOLUMEBAR,
LOCALE_TMDB_API_KEY,
LOCALE_TMDB_ENABLED,

View File

@@ -2433,6 +2433,7 @@ const char * locale_real_names[] =
"timing.infobar_radio",
"timing.menu",
"timing.numericzap",
"timing.popup_messages",
"timing.volumebar",
"tmdb.api_key",
"tmdb.enabled",

View File

@@ -405,6 +405,7 @@ struct SNeutrinoSettings
TIMING_VOLUMEBAR = 6,
TIMING_FILEBROWSER = 7,
TIMING_NUMERICZAP = 8,
TIMING_POPUP_MESSAGES = 9,
TIMING_SETTING_COUNT
};
@@ -873,7 +874,8 @@ const time_settings_struct_t timing_setting[SNeutrinoSettings::TIMING_SETTING_CO
{ 6, LOCALE_TIMING_INFOBAR_MOVIEPLAYER},
{ 3, LOCALE_TIMING_VOLUMEBAR },
{ 60, LOCALE_TIMING_FILEBROWSER },
{ 3, LOCALE_TIMING_NUMERICZAP }
{ 3, LOCALE_TIMING_NUMERICZAP },
{ 6, LOCALE_TIMING_POPUP_MESSAGES}
};
// lcdd