From 90703e6d1e458354fc7992fae95a0744b4e20efb Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 2 Jul 2013 00:15:44 +1000 Subject: [PATCH] Put notification card in suspended mode if user delete it with ESC 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 --- .../libmythui/mythuinotificationcenter.cpp | 33 ++++++++++++++----- .../libs/libmythui/mythuinotificationcenter.h | 1 + 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/mythtv/libs/libmythui/mythuinotificationcenter.cpp b/mythtv/libs/libmythui/mythuinotificationcenter.cpp index ed9536b7bc8..a589c017884 100644 --- a/mythtv/libs/libmythui/mythuinotificationcenter.cpp +++ b/mythtv/libs/libmythui/mythuinotificationcenter.cpp @@ -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() @@ -643,6 +636,22 @@ bool MythUINotificationCenter::Queue(MythNotification ¬ification) .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); @@ -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) @@ -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); diff --git a/mythtv/libs/libmythui/mythuinotificationcenter.h b/mythtv/libs/libmythui/mythuinotificationcenter.h index 8049ee4dc0d..47d75bd75ba 100644 --- a/mythtv/libs/libmythui/mythuinotificationcenter.h +++ b/mythtv/libs/libmythui/mythuinotificationcenter.h @@ -103,6 +103,7 @@ private slots: QList m_screens; QList m_deletedScreens; QMap m_registrations; + QList m_suspended; QMap m_clients; QMutex m_lock; int m_currentId;