Permalink
Browse files

Add ability for an alternative notification style.

All notifications theme must be of the same size.
  • Loading branch information...
jyavenard committed Jul 6, 2013
1 parent ede1fc4 commit a0f00c510cf31db7ede178efbc7a0e6426dac71f
@@ -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 =
@@ -105,7 +103,6 @@ void MythUINotificationScreen::SetNotification(MythNotification &notification)
QString path = img->GetImagePath();
m_update |= kImage;
newcontent |= kImage;
if (path.isNull())
{
@@ -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
@@ -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;
@@ -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
@@ -57,6 +57,7 @@ class MythUINotificationScreen : public MythScreenType
kImage = 1 << 0,
kDuration = 1 << 1,
kMetaData = 1 << 2,
kStyle = 1 << 3,
kAll = ~kNone,
};
@@ -95,6 +96,7 @@ public slots:
int m_index;
MythPoint m_position;
QTimer *m_timer;
QString m_style;
};
//// class MythScreenNotificationStack

0 comments on commit a0f00c5

Please sign in to comment.