Skip to content

Commit

Permalink
Implement Visibility feature in notification. Change how position on …
Browse files Browse the repository at this point in the history
…screen is calculated: so after a full screen, position restart at 0.

Currently, only kPlayback visibility is implemented....
  • Loading branch information
jyavenard committed Jul 7, 2013
1 parent e52b3df commit e1d98d9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 17 deletions.
58 changes: 42 additions & 16 deletions mythtv/libs/libmythui/mythuinotificationcenter.cpp
Expand Up @@ -146,7 +146,9 @@ void MythUINotificationScreen::SetNotification(MythNotification &notification)
m_fullscreen = notification.GetFullScreen(); m_fullscreen = notification.GetFullScreen();
} }


m_duration = notification.GetDuration(); m_duration = notification.GetDuration();
m_visibility = notification.GetVisibility();
m_priority = notification.GetPriority();


// Set timer if need be // Set timer if need be
SetSingleShotTimer(m_duration); SetSingleShotTimer(m_duration);
Expand Down Expand Up @@ -202,6 +204,12 @@ bool MythUINotificationScreen::Create(void)
m_position = GetPosition(); m_position = GetPosition();
m_created = true; m_created = true;


if ((m_visibility & ~MythNotification::kPlayback) == 0)
{
// Visibility will be set automatically during video playback
// so can be ignored here
SetVisible(false);
}
return true; return true;
} }


Expand Down Expand Up @@ -241,7 +249,7 @@ void MythUINotificationScreen::Init(void)
if (m_update != kNone) if (m_update != kNone)
{ {
InfoMap tmap; InfoMap tmap;

tmap["title"] = m_title; tmap["title"] = m_title;
if (m_update & kImage) if (m_update & kImage)
{ {
Expand Down Expand Up @@ -437,6 +445,8 @@ MythUINotificationScreen &MythUINotificationScreen::operator=(const MythUINotifi
m_expiry = s.m_expiry; m_expiry = s.m_expiry;
m_index = s.m_index; m_index = s.m_index;
m_style = s.m_style; m_style = s.m_style;
m_visibility = s.m_visibility;
m_priority = s.m_priority;


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


Expand Down Expand Up @@ -552,7 +562,7 @@ void MythUINotificationCenter::ScreenDeleted(void)
if (n >= 0) if (n >= 0)
{ {
m_screens.removeAll(screen); m_screens.removeAll(screen);
AdjustScreenPosition(n, false); RefreshScreenPosition();
} }
else else
{ {
Expand Down Expand Up @@ -706,18 +716,10 @@ void MythUINotificationCenter::ProcessQueue(void)
if (created || !m_screens.contains(screen)) if (created || !m_screens.contains(screen))
{ {
int pos = InsertScreen(screen); int pos = InsertScreen(screen);
if (!screen->m_fullscreen) // adjust vertical positions
{ RefreshScreenPosition(pos);
// adjust vertical position
screen->AdjustIndex(pos, true);
int n = m_screens.size();
if (pos < n - 1)
{
// screen was inserted before others, adjust their positions
AdjustScreenPosition(pos + 1, true);
}
}
} }

screen->doInit(); screen->doInit();
delete n; delete n;
} }
Expand Down Expand Up @@ -895,16 +897,30 @@ int MythUINotificationCenter::RemoveScreen(MythUINotificationScreen *screen)
/** /**
* Re-position screens on display. * Re-position screens on display.
*/ */
void MythUINotificationCenter::AdjustScreenPosition(int from, bool down) void MythUINotificationCenter::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; it += from;
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)
{ {
(*it)->AdjustIndex(down ? 1 : -1, false); if ((*it)->IsVisible())
{
(*it)->AdjustIndex(position++, true);
}
if ((*it)->m_fullscreen)
{
position = 0;
continue;
}
} }
} }


Expand Down Expand Up @@ -942,13 +958,17 @@ void MythUINotificationCenter::GetNotificationScreens(QList<MythScreenType*> &_s
QVector<MythScreenType*>::const_iterator it = screens.begin(); QVector<MythScreenType*>::const_iterator it = screens.begin();
QVector<MythScreenType*>::const_iterator itend = screens.end(); QVector<MythScreenType*>::const_iterator itend = screens.end();


int position = 0;
for (; it != itend; ++it) for (; it != itend; ++it)
{ {
MythUINotificationScreen *screen = MythUINotificationScreen *screen =
dynamic_cast<MythUINotificationScreen*>(*it); dynamic_cast<MythUINotificationScreen*>(*it);


if (screen) if (screen)
{ {
if ((screen->m_visibility & MythNotification::kPlayback) == 0)
continue;

MythUINotificationScreen *newscreen; MythUINotificationScreen *newscreen;


if (!m_converted.contains(screen)) if (!m_converted.contains(screen))
Expand All @@ -964,6 +984,12 @@ void MythUINotificationCenter::GetNotificationScreens(QList<MythScreenType*> &_s
// Copy old content in case it changed // Copy old content in case it changed
*newscreen = *screen; *newscreen = *screen;
} }
newscreen->SetVisible(true);
newscreen->m_index = position++;
if (screen->m_fullscreen)
{
position = 0;
}
list.append(newscreen); list.append(newscreen);
} }
else else
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythuinotificationcenter.h
Expand Up @@ -121,7 +121,7 @@ private slots:
void DeleteAllScreens(void); void DeleteAllScreens(void);
int InsertScreen(MythUINotificationScreen *screen); int InsertScreen(MythUINotificationScreen *screen);
int RemoveScreen(MythUINotificationScreen *screen); int RemoveScreen(MythUINotificationScreen *screen);
void AdjustScreenPosition(int from, bool down); void RefreshScreenPosition(int from = 0);


private: private:
MythNotificationScreenStack *m_screenStack; MythNotificationScreenStack *m_screenStack;
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythui/mythuinotificationcenter_private.h
Expand Up @@ -97,6 +97,8 @@ public slots:
MythPoint m_position; MythPoint m_position;
QTimer *m_timer; QTimer *m_timer;
QString m_style; QString m_style;
uint32_t m_visibility;
uint32_t m_priority;
}; };


//// class MythScreenNotificationStack //// class MythScreenNotificationStack
Expand Down

0 comments on commit e1d98d9

Please sign in to comment.