Skip to content

Commit

Permalink
Add ability for an alternative notification style.
Browse files Browse the repository at this point in the history
All notifications theme must be of the same size.
  • Loading branch information
jyavenard committed Jul 6, 2013
1 parent ede1fc4 commit a0f00c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 18 additions & 9 deletions mythtv/libs/libmythui/mythuinotificationcenter.cpp
Expand Up @@ -94,8 +94,6 @@ MythUINotificationScreen::~MythUINotificationScreen()
void MythUINotificationScreen::SetNotification(MythNotification &notification)
{
bool update = notification.type() == MythNotification::Update;
uint32_t newcontent = kNone;

m_update = kNone;

MythImageNotification *img =
Expand All @@ -105,7 +103,6 @@ void MythUINotificationScreen::SetNotification(MythNotification &notification)
QString path = img->GetImagePath();

m_update |= kImage;
newcontent |= kImage;

if (path.isNull())
{
Expand All @@ -119,33 +116,36 @@ void MythUINotificationScreen::SetNotification(MythNotification &notification)

MythPlaybackNotification *play =
dynamic_cast<MythPlaybackNotification*>(&notification);
newcontent &= ~kDuration;
if (play)
{
UpdatePlayback(play->GetProgress(), play->GetProgressText());

m_update |= kDuration;
newcontent |= kDuration;
}

newcontent &= ~kMetaData;
if (!notification.GetMetaData().isEmpty())
{
UpdateMetaData(notification.GetMetaData());
m_update |= kMetaData;
newcontent |= kMetaData;
}
else if (!update)
{
// A new notification, will always update the metadata field
m_update |= kMetaData;
}

if (!notification.GetStyle().isEmpty())
{
m_style = notification.GetStyle();
m_update |= kStyle;
}

if (!update)
{
m_content = newcontent;
m_content = m_update;
m_fullscreen = notification.GetFullScreen();
}

m_duration = notification.GetDuration();

// Set timer if need be
Expand Down Expand Up @@ -175,7 +175,15 @@ bool MythUINotificationScreen::Create(void)
theme = "notification";
}

foundtheme = LoadWindowFromXML("notification-ui.xml", theme, this);
QString theme_attempt = theme + (m_style.isEmpty() ? "" : "-" + m_style);

// See if we have an alternative theme available as defined in the notification
foundtheme = LoadWindowFromXML("notification-ui.xml", theme_attempt, this);
if (!foundtheme && theme_attempt != theme)
{
// if not, default to the main one
foundtheme = LoadWindowFromXML("notification-ui.xml", theme, this);
}

if (!foundtheme) // If we cannot load the theme for any reason ...
return false;
Expand Down Expand Up @@ -451,6 +459,7 @@ MythUINotificationScreen &MythUINotificationScreen::operator=(const MythUINotifi
m_fullscreen = s.m_fullscreen;
m_expiry = s.m_expiry;
m_index = s.m_index;
m_style = s.m_style;

m_update = kAll; // so all fields are initialised regardless of notification type

Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythui/mythuinotificationcenter_private.h
Expand Up @@ -57,6 +57,7 @@ class MythUINotificationScreen : public MythScreenType
kImage = 1 << 0,
kDuration = 1 << 1,
kMetaData = 1 << 2,
kStyle = 1 << 3,
kAll = ~kNone,
};

Expand Down Expand Up @@ -95,6 +96,7 @@ public slots:
int m_index;
MythPoint m_position;
QTimer *m_timer;
QString m_style;
};

//// class MythScreenNotificationStack
Expand Down

0 comments on commit a0f00c5

Please sign in to comment.