diff --git a/mythtv/libs/libmythui/mythscreentype.cpp b/mythtv/libs/libmythui/mythscreentype.cpp index 81be39a9483..8eca29b2907 100644 --- a/mythtv/libs/libmythui/mythscreentype.cpp +++ b/mythtv/libs/libmythui/mythscreentype.cpp @@ -441,10 +441,9 @@ static void DoSetTextFromMap(MythUIType *UItype, QHash &infoMa MythUIType *type = i.next(); textType = dynamic_cast (type); - if (textType && infoMap.contains(textType->objectName())) + if (textType) textType->SetTextFromMap(infoMap); - MythUIGroup *group = dynamic_cast (type); if (group) DoSetTextFromMap(type, infoMap); diff --git a/mythtv/libs/libmythui/mythuitext.cpp b/mythtv/libs/libmythui/mythuitext.cpp index 7c7a5d4998d..7300cb55fb3 100644 --- a/mythtv/libs/libmythui/mythuitext.cpp +++ b/mythtv/libs/libmythui/mythuitext.cpp @@ -151,51 +151,47 @@ void MythUIText::SetText(const QString &text) void MythUIText::SetTextFromMap(QHash &map) { - if (map.contains(objectName())) - { - QString newText = GetTemplateText(); + QString newText = GetTemplateText(); - if (newText.isEmpty()) - newText = GetDefaultText(); + if (newText.isEmpty()) + newText = GetDefaultText(); - QRegExp regexp("%(([^\\|%]+)?\\||\\|(.))?(\\w+)(\\|(.+))?%"); - regexp.setMinimal(true); + QRegExp regexp("%(([^\\|%]+)?\\||\\|(.))?(\\w+)(\\|(.+))?%"); + regexp.setMinimal(true); - if (!newText.isEmpty() && newText.contains(regexp)) - { - int pos = 0; + if (!newText.isEmpty() && newText.contains(regexp)) + { + int pos = 0; - QString translatedTemplate = qApp->translate("ThemeUI", - newText.toUtf8(), - NULL, - QCoreApplication::UnicodeUTF8); + QString translatedTemplate = qApp->translate("ThemeUI", + newText.toUtf8(), + NULL, + QCoreApplication::UnicodeUTF8); - QString tempString = translatedTemplate; + QString tempString = translatedTemplate; - while ((pos = regexp.indexIn(translatedTemplate, pos)) != -1) - { - QString key = regexp.cap(4).toLower().trimmed(); - QString replacement; - - if (!map.value(key).isEmpty()) - { - replacement = QString("%1%2%3%4") - .arg(regexp.cap(2)) - .arg(regexp.cap(3)) - .arg(map.value(key)) - .arg(regexp.cap(6)); - } + while ((pos = regexp.indexIn(translatedTemplate, pos)) != -1) + { + QString key = regexp.cap(4).toLower().trimmed(); + QString replacement; - tempString.replace(regexp.cap(0), replacement); - pos += regexp.matchedLength(); + if (!map.value(key).isEmpty()) + { + replacement = QString("%1%2%3%4") + .arg(regexp.cap(2)) + .arg(regexp.cap(3)) + .arg(map.value(key)) + .arg(regexp.cap(6)); } - newText = tempString; + tempString.replace(regexp.cap(0), replacement); + pos += regexp.matchedLength(); } - else - newText = map.value(objectName()); - - SetText(newText); + SetText(tempString); + } + else if (map.contains(objectName())) + { + SetText(map.value(objectName())); } }