Skip to content

Commit

Permalink
Add support for templates in notifications theme.
Browse files Browse the repository at this point in the history
available keywords:
%TITLE%, %IMAGE%, %ORIGIN%, %DECRIPTION%, %EXTRA%, %PROGRESS_TEXT%, %PROGRESS% (value between 0-100)
  • Loading branch information
jyavenard committed Jul 6, 2013
1 parent 26aeda9 commit 015c57d
Showing 1 changed file with 36 additions and 59 deletions.
95 changes: 36 additions & 59 deletions mythtv/libs/libmythui/mythuinotificationcenter.cpp
Expand Up @@ -238,101 +238,78 @@ void MythUINotificationScreen::Init(void)
}
}

if (m_titleText && (m_update & kMetaData))
if (m_update != kNone)
{
if (!m_title.isNull())
InfoMap tmap;

tmap["title"] = m_title;
if (m_update & kImage)
{
m_titleText->SetText(m_title);
tmap["image"] = m_imagePath;
}
else
tmap["origin"] = m_origin;
tmap["description"] = m_description;
tmap["extra"] = m_extra;
if (m_update & kDuration)
{
// Same as above, calling Reset() allows for a sane, themer defined
//default to be displayed
m_titleText->Reset();
tmap["progress_text"] = m_progresstext;
tmap["progress"] = QString("%1").arg((int)(m_progress * 100));
}
SetTextFromMap(tmap);
}

if (m_originText && (m_update & kMetaData))
if (m_update & kMetaData)
{
if (!m_origin.isNull())
if (m_titleText && m_title.isNull())
{
m_originText->SetText(m_origin);
m_titleText->Reset();
}
else
if (m_originText && m_origin.isNull())
{
// Same as above, calling Reset() allows for a sane, themer defined
//default to be displayed
m_originText->Reset();
}
}

if (m_descriptionText && (m_update & kMetaData))
{
if (!m_description.isNull())
if (m_descriptionText && m_description.isNull())
{
m_descriptionText->SetText(m_description);
}
else
{
// Same as above, calling Reset() allows for a sane, themer defined
//default to be displayed
m_descriptionText->Reset();
}
}

if (m_extraText && (m_update & kMetaData))
{
if (!m_extra.isNull())
{
m_extraText->SetText(m_extra);
}
else
if (m_extraText && m_extra.isNull())
{
// Same as above, calling Reset() allows for a sane, themer defined
//default to be displayed
m_extraText->Reset();
}
}

if (m_progresstextText && (m_update & kDuration))
if (m_update & kDuration)
{
if (!m_progresstext.isEmpty())
if (m_progresstextText && m_progresstext.isEmpty())
{
m_progresstextText->SetText(m_progresstext);
m_progresstextText->Reset();
}
else
if (m_progressBar)
{
// Same as above, calling Reset() allows for a sane, themer defined
//default to be displayed
m_progresstextText->Reset();
if (m_progress >= 0)
{
m_progressBar->SetStart(0);
m_progressBar->SetTotal(100);
m_progressBar->SetUsed(100 * m_progress);
}
else
{
// Same as above, calling Reset() allows for a sane, themer defined
//default to be displayed
m_progressBar->Reset();
}
}
}

if (m_progressBar)
{
m_progressBar->SetVisible((m_content & kDuration) != 0);

}
if (m_progresstextText)
{
m_progresstextText->SetVisible((m_content & kDuration) != 0);
}

if (m_progressBar && (m_update & kDuration))
{
if (m_progress >= 0)
{
m_progressBar->SetStart(0);
m_progressBar->SetTotal(100);
m_progressBar->SetUsed(100 * m_progress);
}
else
{
// Same as above, calling Reset() allows for a sane, themer defined
//default to be displayed
m_progressBar->Reset();
}
}

// No field will be refreshed the next time unless specified otherwise
m_update = kNone;

Expand Down

0 comments on commit 015c57d

Please sign in to comment.