Skip to content

Commit

Permalink
Define StateType when a MythNotificationError is displayed
Browse files Browse the repository at this point in the history
This allows to define the behaviour on how to display errors in the theme
  • Loading branch information
jyavenard committed Jul 14, 2013
1 parent c97bd58 commit 7f0300e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
24 changes: 19 additions & 5 deletions mythtv/libs/libmythui/mythuinotificationcenter.cpp
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -103,6 +106,13 @@ void MythUINotificationScreen::SetNotification(MythNotification &notification)
bool update = notification.type() == MythNotification::Update;
m_update = kNone;

MythErrorNotification *error =
dynamic_cast<MythErrorNotification*>(&notification);
if (error)
{
m_update |= kError;
}

MythImageNotification *img =
dynamic_cast<MythImageNotification*>(&notification);
if (img)
Expand Down Expand Up @@ -197,15 +207,14 @@ bool MythUINotificationScreen::Create(void)
if (!foundtheme) // If we cannot load the theme for any reason ...
return false;

// The xml should contain an <imagetype> named 'coverart', if it doesn't
// then we cannot display the image and may as well abort
m_artworkImage = dynamic_cast<MythUIImage*>(GetChild("image"));
m_titleText = dynamic_cast<MythUIText*>(GetChild("title"));
m_originText = dynamic_cast<MythUIText*>(GetChild("origin"));
m_descriptionText = dynamic_cast<MythUIText*>(GetChild("description"));
m_extraText = dynamic_cast<MythUIText*>(GetChild("extra"));
m_progresstextText = dynamic_cast<MythUIText*>(GetChild("progress_text"));
m_progressBar = dynamic_cast<MythUIProgressBar*>(GetChild("progress"));
m_errorState = dynamic_cast<MythUIStateType*>(GetChild("errorstate"));

// store original position
m_position = GetPosition();
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythui/mythuinotificationcenter_private.h
Expand Up @@ -22,6 +22,7 @@
#include "mythuitext.h"
#include "mythuiprogressbar.h"
#include "mythuinotificationcenter.h"
#include "mythuistatetype.h"

// Forward declarations
class MythUINotificationScreen;
Expand Down Expand Up @@ -183,6 +184,7 @@ class MythUINotificationScreen : public MythScreenType
kDuration = 1 << 1,
kMetaData = 1 << 2,
kStyle = 1 << 3,
kError = 1 << 4,
kAll = ~kNone,
};

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7f0300e

Please sign in to comment.