Navigation Menu

Skip to content

Commit

Permalink
Extend ShowNotification utility method
Browse files Browse the repository at this point in the history
Will be used by ServiceAPI
  • Loading branch information
jyavenard committed Jul 18, 2013
1 parent 6a94511 commit e4f6e69
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 16 deletions.
94 changes: 78 additions & 16 deletions mythtv/libs/libmythui/mythuinotificationcenter.cpp
Expand Up @@ -268,6 +268,11 @@ void MythUINotificationScreen::SetNotification(MythNotification &notification)


m_duration = notification.GetDuration(); m_duration = notification.GetDuration();
m_visibility = notification.GetVisibility(); 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(); m_priority = notification.GetPriority();


// Set timer if need be // Set timer if need be
Expand Down Expand Up @@ -749,7 +754,9 @@ void NCPrivate::ScreenDeleted(void)
int n = m_screens.indexOf(screen); int n = m_screens.indexOf(screen);
if (n >= 0) 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(); RefreshScreenPosition();
} }
else else
Expand Down Expand Up @@ -1134,20 +1141,18 @@ void NCPrivate::RefreshScreenPosition(int from)
QList<MythUINotificationScreen*>::iterator it = m_screens.begin(); QList<MythUINotificationScreen*>::iterator it = m_screens.begin();
QList<MythUINotificationScreen*>::iterator itend = m_screens.end(); QList<MythUINotificationScreen*>::iterator itend = m_screens.end();


it += from;
int position = 0; int position = 0;


if (from > 0)
{
position = (*(it-1))->m_fullscreen ? 0 : (*(it-1))->m_index+1;
}

for (; it != itend; ++it) for (; it != itend; ++it)
{ {
if ((*it)->IsVisible()) if ((*it)->IsVisible())
{ {
(*it)->AdjustIndex(position++, true); (*it)->AdjustIndex(position++, true);
} }
else
{
(*it)->AdjustIndex(position, true);
}
if ((*it)->m_fullscreen) if ((*it)->m_fullscreen)
{ {
position = 0; position = 0;
Expand Down Expand Up @@ -1363,11 +1368,7 @@ void ShowNotificationError(const QString &msg,
const VNMask visibility, const VNMask visibility,
const MythNotification::Priority priority) const MythNotification::Priority priority)
{ {
MythErrorNotification n(msg, from, detail); ShowNotification(true, msg, from, detail);
n.SetPriority(priority);
n.SetVisibility(visibility);

MythUINotificationCenter::GetInstance()->Queue(n);
} }


void ShowNotification(const QString &msg, void ShowNotification(const QString &msg,
Expand All @@ -1376,9 +1377,70 @@ void ShowNotification(const QString &msg,
const VNMask visibility, const VNMask visibility,
const MythNotification::Priority priority) const MythNotification::Priority priority)
{ {
MythNotification n(msg, from, detail); ShowNotification(false, msg, from, detail,
n.SetPriority(priority); QString(), QString(), QString(), -1, -1, false,
n.SetVisibility(visibility); 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;
} }
14 changes: 14 additions & 0 deletions mythtv/libs/libmythui/mythuinotificationcenter.h
Expand Up @@ -130,4 +130,18 @@ MUI_PUBLIC void ShowNotification(const QString &msg,
const VNMask visibility = MythNotification::kAll, const VNMask visibility = MythNotification::kAll,
const MythNotification::Priority priority = MythNotification::kDefault); 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__) */ #endif /* defined(__MythTV__mythnotifications__) */

0 comments on commit e4f6e69

Please sign in to comment.