From 7f0300e40ed68ef0b4a54732cc135c333f2f2d31 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Sun, 14 Jul 2013 23:27:15 +1000 Subject: [PATCH] Define StateType when a MythNotificationError is displayed This allows to define the behaviour on how to display errors in the theme --- .../libmythui/mythuinotificationcenter.cpp | 24 +++++++++++++++---- .../mythuinotificationcenter_private.h | 3 +++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/mythtv/libs/libmythui/mythuinotificationcenter.cpp b/mythtv/libs/libmythui/mythuinotificationcenter.cpp index 26ccf7214df..b433765db30 100644 --- a/mythtv/libs/libmythui/mythuinotificationcenter.cpp +++ b/mythtv/libs/libmythui/mythuinotificationcenter.cpp @@ -46,7 +46,8 @@ MythUINotificationScreen::MythUINotificationScreen(MythScreenStack *stack, m_created(false), m_content(kNone), m_update(kAll), m_artworkImage(NULL), m_titleText(NULL), m_originText(NULL), m_descriptionText(NULL), m_extraText(NULL), m_progresstextText(NULL), - m_progressBar(NULL), m_index(0), m_timer(new QTimer(this)), + m_progressBar(NULL), m_errorState(NULL), m_index(0), + m_timer(new QTimer(this)), m_visibility(MythNotification::kAll), m_priority(MythNotification::kDefault) { @@ -64,7 +65,8 @@ MythUINotificationScreen::MythUINotificationScreen(MythScreenStack *stack, m_update(kAll), m_artworkImage(NULL), m_titleText(NULL), m_originText(NULL), m_descriptionText(NULL), m_extraText(NULL), m_progresstextText(NULL), - m_progressBar(NULL), m_index(0), m_timer(new QTimer(this)), + m_progressBar(NULL), m_errorState(NULL), m_index(0), + m_timer(new QTimer(this)), m_visibility(MythNotification::kAll), m_priority(MythNotification::kDefault) { @@ -80,7 +82,8 @@ MythUINotificationScreen::MythUINotificationScreen(MythScreenStack *stack, m_created(false), m_content(kNone), m_update(kAll), m_artworkImage(NULL), m_titleText(NULL), m_originText(NULL), m_descriptionText(NULL), m_extraText(NULL), m_progresstextText(NULL), - m_progressBar(NULL), m_timer(new QTimer(this)), + m_progressBar(NULL), m_errorState(NULL), + m_timer(new QTimer(this)), m_visibility(MythNotification::kAll), m_priority(MythNotification::kDefault) { @@ -103,6 +106,13 @@ void MythUINotificationScreen::SetNotification(MythNotification ¬ification) bool update = notification.type() == MythNotification::Update; m_update = kNone; + MythErrorNotification *error = + dynamic_cast(¬ification); + if (error) + { + m_update |= kError; + } + MythImageNotification *img = dynamic_cast(¬ification); if (img) @@ -197,8 +207,6 @@ bool MythUINotificationScreen::Create(void) if (!foundtheme) // If we cannot load the theme for any reason ... return false; - // The xml should contain an named 'coverart', if it doesn't - // then we cannot display the image and may as well abort m_artworkImage = dynamic_cast(GetChild("image")); m_titleText = dynamic_cast(GetChild("title")); m_originText = dynamic_cast(GetChild("origin")); @@ -206,6 +214,7 @@ bool MythUINotificationScreen::Create(void) m_extraText = dynamic_cast(GetChild("extra")); m_progresstextText = dynamic_cast(GetChild("progress_text")); m_progressBar = dynamic_cast(GetChild("progress")); + m_errorState = dynamic_cast(GetChild("errorstate")); // store original position m_position = GetPosition(); @@ -321,6 +330,11 @@ void MythUINotificationScreen::Init(void) } + if (m_errorState) + { + m_errorState->DisplayState(m_update & kError ? "error" : "ok"); + } + // No field will be refreshed the next time unless specified otherwise m_update = kNone; diff --git a/mythtv/libs/libmythui/mythuinotificationcenter_private.h b/mythtv/libs/libmythui/mythuinotificationcenter_private.h index fcc5ca2ef4a..20c71e9afb0 100644 --- a/mythtv/libs/libmythui/mythuinotificationcenter_private.h +++ b/mythtv/libs/libmythui/mythuinotificationcenter_private.h @@ -22,6 +22,7 @@ #include "mythuitext.h" #include "mythuiprogressbar.h" #include "mythuinotificationcenter.h" +#include "mythuistatetype.h" // Forward declarations class MythUINotificationScreen; @@ -183,6 +184,7 @@ class MythUINotificationScreen : public MythScreenType kDuration = 1 << 1, kMetaData = 1 << 2, kStyle = 1 << 3, + kError = 1 << 4, kAll = ~kNone, }; @@ -217,6 +219,7 @@ public slots: MythUIText *m_extraText; MythUIText *m_progresstextText; MythUIProgressBar *m_progressBar; + MythUIStateType *m_errorState; QDateTime m_creation, m_expiry; int m_index; MythPoint m_position;