Skip to content

Commit

Permalink
Put notification card in suspended mode if user delete it with ESC
Browse files Browse the repository at this point in the history
Each notification update would make the notification card reappear; which could make it a tad invasive... So suspend the card, ignoring all future updates; it will be active again when a "New" notification is received
  • Loading branch information
jyavenard committed Jul 1, 2013
1 parent 66f80e0 commit 90703e6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
33 changes: 24 additions & 9 deletions mythtv/libs/libmythui/mythuinotificationcenter.cpp
Expand Up @@ -604,15 +604,8 @@ void MythUINotificationCenter::ScreenDeleted(void)
// Copy old content
*newscreen = *screen;
m_registrations[screen->m_id] = newscreen;
int pos = InsertScreen(newscreen);
// adjust vertical position
newscreen->AdjustYPosition((newscreen->GetHeight() + HGAP) * pos);

if (pos < n - 1)
{
// screen was inserted before others, adjust their positions
AdjustScreenPosition(pos, true);
}
// Screen was deleted, add it to suspended list
m_suspended.append(screen->m_id);
}
}
// so screen will be refreshed by Draw() or DrawDirect()
Expand Down Expand Up @@ -643,6 +636,22 @@ bool MythUINotificationCenter::Queue(MythNotification &notification)
.arg(id));
id = -1;
}
else
{
// check if notification card has been suspended, in which case
// refuse all notification updates
if (m_suspended.contains(id))
{
if (notification.type() == MythNotification::Update)
{
delete tmp;
return false;
}
// got something else than an update, remove it from the
// suspended list
m_suspended.removeAll(id);
}
}
}
m_notifications.append(tmp);

Expand Down Expand Up @@ -671,6 +680,7 @@ void MythUINotificationCenter::ProcessQueue(void)
foreach (MythNotification *n, m_notifications)
{
int id = n->GetId();
bool created = false;
MythUINotificationScreen *screen = NULL;

if (id > 0)
Expand All @@ -691,6 +701,11 @@ void MythUINotificationCenter::ProcessQueue(void)
{
m_registrations[id] = screen;
}
created = true;
}

if (created || !m_screens.contains(screen))
{
int pos = InsertScreen(screen);
// adjust vertical position
screen->AdjustYPosition((screen->GetHeight() + HGAP) * pos);
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythui/mythuinotificationcenter.h
Expand Up @@ -103,6 +103,7 @@ private slots:
QList<MythUINotificationScreen*> m_screens;
QList<MythUINotificationScreen*> m_deletedScreens;
QMap<int, MythUINotificationScreen*> m_registrations;
QList<int> m_suspended;
QMap<int, void*> m_clients;
QMutex m_lock;
int m_currentId;
Expand Down

0 comments on commit 90703e6

Please sign in to comment.