From 380e84afcdbeccc2fc1899f1a92e3ab97bf3819d Mon Sep 17 00:00:00 2001 From: kamel5 Date: Sat, 9 Nov 2019 15:04:52 +0100 Subject: [PATCH] Refactor cRecMenuSearchNothingFound --- recmenus.c | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/recmenus.c b/recmenus.c index 62c13fa..71accdc 100644 --- a/recmenus.c +++ b/recmenus.c @@ -1243,6 +1243,20 @@ const cEvent *cRecMenuSearchResults::GetEvent(void) { return NULL; } +// --- cRecMenuSearchNothingFound --------------------------------------------------------- +cRecMenuSearchNothingFound::cRecMenuSearchNothingFound(std::string searchString, bool tooShort) { // OK + SetWidthPercent(50); + + const cString line1 = cString::sprintf("%s", (!tooShort) ? tr("Nothing found for Search String") : tr("Search String has to have at least three letters")); + const cString line2 = cString::sprintf("\"%s\"", searchString.c_str()); + + AddHeader(new cRecMenuItemInfo(*line1, 2, *line2, "", "", width - 2 * border)); + AddFooter(new cRecMenuItemButton(tr("OK"), rmsSearchNothingFoundConfirm, true, true)); + + CalculateHeight(); + CreatePixmap(); + Arrange(); +} // --- cRecMenuSearchConfirmTimer --------------------------------------------------------- cRecMenuSearchConfirmTimer::cRecMenuSearchConfirmTimer(const cEvent *event, eRecMenuState nextAction) { @@ -1271,31 +1285,6 @@ cRecMenuSearchConfirmTimer::cRecMenuSearchConfirmTimer(const cEvent *event, eRec Arrange(); } -// --- cRecMenuSearchNothingFound --------------------------------------------------------- -cRecMenuSearchNothingFound::cRecMenuSearchNothingFound(std::string searchString, bool tooShort) { - SetWidthPercent(50); - cString text; - if (!tooShort) { - cString message = tr("Nothing found for Search String"); - text = cString::sprintf("%s\n\"%s\"", - *message, - searchString.c_str()); - } else { - cString message = tr("Search String has to have at least three letters"); - text = cString::sprintf("%s\n\"%s\"", - *message, - searchString.c_str()); - - } - cRecMenuItemInfo *infoItem = new cRecMenuItemInfo(*text); - infoItem->CalculateHeight(width - 2 * border); - AddMenuItem(infoItem); - AddMenuItem(new cRecMenuItemButton(tr("OK"), rmsSearchNothingFoundConfirm, true, true)); - CalculateHeight(); - CreatePixmap(); - Arrange(); -} - /****************************************************************************************** * Recording Search Menus ******************************************************************************************/