Permalink
Browse files

Extend ShowNotification utility method

Will be used by ServiceAPI
  • Loading branch information...
jyavenard committed Jul 18, 2013
1 parent 6a94511 commit e4f6e69b28f00e0eedf9e053e617e86ffc867764
Showing with 92 additions and 16 deletions.
  1. +78 −16 mythtv/libs/libmythui/mythuinotificationcenter.cpp
  2. +14 −0 mythtv/libs/libmythui/mythuinotificationcenter.h
@@ -268,6 +268,11 @@ void MythUINotificationScreen::SetNotification(MythNotification &notification)
m_duration = notification.GetDuration();
m_visibility = notification.GetVisibility();
if (!m_visibility)
{
// no visibility is all visibility to get around QVariant always making 0 the default
m_visibility = ~0;
}
m_priority = notification.GetPriority();
// Set timer if need be
@@ -749,7 +754,9 @@ void NCPrivate::ScreenDeleted(void)
int n = m_screens.indexOf(screen);
if (n >= 0)
{
m_screens.removeAll(screen);
int num = m_screens.removeAll(screen);
LOG(VB_GUI, LOG_DEBUG, LOC +
QString("%1 screen removed from screens list").arg(num));
RefreshScreenPosition();
}
else
@@ -1134,20 +1141,18 @@ void NCPrivate::RefreshScreenPosition(int from)
QList<MythUINotificationScreen*>::iterator it = m_screens.begin();
QList<MythUINotificationScreen*>::iterator itend = m_screens.end();
it += from;
int position = 0;
if (from > 0)
{
position = (*(it-1))->m_fullscreen ? 0 : (*(it-1))->m_index+1;
}
for (; it != itend; ++it)
{
if ((*it)->IsVisible())
{
(*it)->AdjustIndex(position++, true);
}
else
{
(*it)->AdjustIndex(position, true);
}
if ((*it)->m_fullscreen)
{
position = 0;
@@ -1363,11 +1368,7 @@ void ShowNotificationError(const QString &msg,
const VNMask visibility,
const MythNotification::Priority priority)
{
MythErrorNotification n(msg, from, detail);
n.SetPriority(priority);
n.SetVisibility(visibility);
MythUINotificationCenter::GetInstance()->Queue(n);
ShowNotification(true, msg, from, detail);
}
void ShowNotification(const QString &msg,
@@ -1376,9 +1377,70 @@ void ShowNotification(const QString &msg,
const VNMask visibility,
const MythNotification::Priority priority)
{
MythNotification n(msg, from, detail);
n.SetPriority(priority);
n.SetVisibility(visibility);
ShowNotification(false, msg, from, detail,
QString(), QString(), QString(), -1, -1, false,
visibility, priority);
}
void ShowNotification(bool error,
const QString &msg,
const QString &origin,
const QString &detail,
const QString &image,
const QString &extra,
const QString &progress_text, float progress,
int duration,
bool fullscreen,
const VNMask visibility,
const MythNotification::Priority priority,
const QString &style)
{
if (!GetNotificationCenter())
return;
MythNotification *n;
if (error)
{
n = new MythErrorNotification(msg, origin, detail);
}
else
{
DMAP data;
data["minm"] = msg;
data["asar"] = origin.isNull() ? QObject::tr("MythTV") : origin;
data["asal"] = detail;
data["asfm"] = extra;
if (!image.isEmpty())
{
if (progress >= 0)
{
n = new MythMediaNotification(MythNotification::New,
image, data,
progress, progress_text);
}
else
{
n = new MythImageNotification(MythNotification::New, image, data);
}
}
else if (progress >= 0)
{
n = new MythPlaybackNotification(MythNotification::New,
progress, progress_text, data);
}
else
{
n = new MythNotification(MythNotification::New, data);
}
n->SetFullScreen(fullscreen);
}
n->SetDuration(duration);
n->SetPriority(priority);
n->SetVisibility(visibility);
MythUINotificationCenter::GetInstance()->Queue(n);
MythUINotificationCenter::GetInstance()->Queue(*n);
delete n;
}
@@ -130,4 +130,18 @@ MUI_PUBLIC void ShowNotification(const QString &msg,
const VNMask visibility = MythNotification::kAll,
const MythNotification::Priority priority = MythNotification::kDefault);
MUI_PUBLIC void ShowNotification(bool error,
const QString &msg,
const QString &origin = QString(),
const QString &detail = QString(),
const QString &image = QString(),
const QString &extra = QString(),
const QString &progress_text = QString(),
float progress = -1.0f,
int duration = -1,
bool fullscreen = false,
const VNMask visibility = MythNotification::kAll,
const MythNotification::Priority priority = MythNotification::kDefault,
const QString &style = QString());
#endif /* defined(__MythTV__mythnotifications__) */

0 comments on commit e4f6e69

Please sign in to comment.