Skip to content

Commit

Permalink
Add MythUINotificationCenter
Browse files Browse the repository at this point in the history
Preliminary Notification Center manager. Will allow for an application to send informative message that will be queued and displayed to the screen in a permanent or temporary fashion.

For the time being, only handle a permanent position and uses the music miniplayer theme for ease.
First client will be the AirTunes (AirPlay) server that will display artwork and information about the song being played
  • Loading branch information
jyavenard committed Jun 27, 2013
1 parent f67e502 commit d33d8cd
Show file tree
Hide file tree
Showing 6 changed files with 745 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mythtv/libs/libmythui/libmythui.pro
Expand Up @@ -6,7 +6,7 @@ QT += webkit
}
contains(QT_VERSION, ^5\\.[0-9]\\..*) {
QT += widgets
# QT += webkitwidgets # this does not seem to work..
# QT += webkitwidgets # this does not seem to work..
}

TEMPLATE = lib
Expand Down Expand Up @@ -41,6 +41,7 @@ HEADERS += mythrender_base.h mythfontmanager.h mythuieditbar.h
HEADERS += mythdisplay.h mythuivideo.h mythudplistener.h
HEADERS += mythuiexp.h mythuisimpletext.h mythuistatetracker.h
HEADERS += mythuianimation.h mythuiscrollbar.h
HEADERS += mythuinotificationcenter.h mythnotification.h

SOURCES = mythmainwindow.cpp mythpainter.cpp mythimage.cpp mythrect.cpp
SOURCES += myththemebase.cpp mythpainter_qimage.cpp mythpainter_yuva.cpp
Expand All @@ -60,6 +61,7 @@ SOURCES += mythfontmanager.cpp mythuieditbar.cpp
SOURCES += mythdisplay.cpp mythuivideo.cpp mythudplistener.cpp
SOURCES += mythuisimpletext.cpp mythuistatetracker.cpp
SOURCES += mythuianimation.cpp mythuiscrollbar.cpp
SOURCES += mythuinotificationcenter.cpp mythnotification.cpp

contains(QT_VERSION, ^4\\.[0-9]\\..*) {
SOURCES += mythuiwebbrowser.cpp
Expand Down
8 changes: 8 additions & 0 deletions mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -83,6 +83,8 @@ using namespace std;
#include "mythpainter_d3d9.h"
#endif

#include "mythuinotificationcenter.h"

#define GESTURE_TIMEOUT 1000
#define STANDBY_TIMEOUT 90 // Minutes

Expand Down Expand Up @@ -193,6 +195,8 @@ class MythMainWindowPrivate
standby(false),
enteringStandby(false)
{
// Will create Notification Center singleton
(void)MythUINotificationCenter::GetInstance();
}

int TranslateKeyNum(QKeyEvent *e);
Expand Down Expand Up @@ -2404,6 +2408,10 @@ void MythMainWindow::customEvent(QEvent *ce)
if (!message.isEmpty())
ShowOkPopup(message);
}
else if ((MythEvent::Type)(ce->type()) == MythUINotificationCenterEvent::kEventType)
{
MythUINotificationCenter::GetInstance()->ProcessQueue();
}
}

QObject *MythMainWindow::getTarget(QKeyEvent &key)
Expand Down
21 changes: 21 additions & 0 deletions mythtv/libs/libmythui/mythnotification.cpp
@@ -0,0 +1,21 @@
//
// mythnotification.cpp
// MythTV
//
// Created by Jean-Yves Avenard on 25/06/13.
// Copyright (c) 2013 Bubblestuff Pty Ltd. All rights reserved.
//

#include "mythnotification.h"

#include <QCoreApplication>

QEvent::Type MythNotification::New =
(QEvent::Type) QEvent::registerEventType();
QEvent::Type MythNotification::Update =
(QEvent::Type) QEvent::registerEventType();
QEvent::Type MythNotification::Info =
(QEvent::Type) QEvent::registerEventType();
QEvent::Type MythNotification::Error =
(QEvent::Type) QEvent::registerEventType();

184 changes: 184 additions & 0 deletions mythtv/libs/libmythui/mythnotification.h
@@ -0,0 +1,184 @@
//
// mythnotification.h
// MythTV
//
// Created by Jean-Yves Avenard on 25/06/13.
// Copyright (c) 2013 Bubblestuff Pty Ltd. All rights reserved.
//

#ifndef __MythTV__mythnotification__
#define __MythTV__mythnotification__

#include <QMutex>
#include <QMap>
#include <QImage>

#include "mythevent.h"
#include "mythuiexp.h"

typedef QMap<QString,QString> DMAP;

class MUI_PUBLIC MythNotification : public MythEvent
{
public:

static Type New;
static Type Update;
static Type Info;
static Type Error;

MythNotification(Type t, void *parent = NULL) :
MythEvent(t), m_id(-1), m_parent(parent), m_fullScreen(false),
m_duration(0), m_visibility(kAll), m_priority(kDefault)

{
}

MythNotification(int id, void *parent) :
MythEvent(Update), m_id(id), m_parent(parent), m_fullScreen(false),
m_duration(0), m_visibility(kAll), m_priority(kDefault)
{
}

virtual ~MythNotification()
{
}

virtual MythEvent *clone(void) const { return new MythNotification(*this); }

/** Priority enum
* A notification can be given a priority. Display order of notification
* will be sorted according to the priority level
*/
enum Priority {
kDefault = 0,
kLow,
kMedium,
kHigh,
kHigher,
kHighest,
};

/** Visibility enum
* A notification can be given visibility mask allowing to not be visible
* under some circumstances, like the screen currently being displayed.
* This is used to prevent redundant information appearing more than once:
* like in MythMusic, there's no need to show music notifications
*/
enum Visibility {
kNone = 0,
kAll = ~0,
kPlayback = (1 << 1),
kSettings = (1 << 2),
kWizard = (1 << 3),
kVideos = (1 << 4),
kMusic = (1 << 5),
kRecordings = (1 << 6),
};

// Setter
/**
* Optional MythNotification elements
*/
/**
* contains the application registration id
* Required to update an existing notification screen owned by an application
*/
void SetId(int id) { m_id = id; }
/**
* contains the parent address. Required if id is set
* Id provided must match the parent address as provided during the
* MythUINotificationCenter registration, otherwise the id value will be
* ignored
*/
void SetParent(void *parent) { m_parent = parent; }
/**
* a notification may request to be displayed in full screen,
* this request may not be fullfilled should the theme not handle full screen
* notification
*/
void SetFullScreem(bool f) { m_fullScreen = f; }
/**
* contains a short description of the notification
*/
void SetDescription(QString desc) { m_description = desc; }
/**
* metadata of the notification.
* In DMAP format. DMAP can contains various information such as artist,
* album name, author name, genre etc..
*/
void SetMetaData(DMAP data) { m_metadata = data; }
/**
* contains a duration during which the notification will be displayed.
* The duration is informative only as the MythUINotificationCenter will
* determine automatically how long a notification can be displayed for
* and will depend on priority, visibility and other factors
*/
void SetDuration(int duration) { m_duration = duration; };
void SetVisibility(Visibility n) { m_visibility = n; }
void SetPriority(Priority n) { m_priority = n; }

// Getter
int GetId(void) { return m_id; }
void *GetParent(void) { return m_parent; }
QString GetDescription(void) { return m_description; }
DMAP GetMetaData(void) { return m_metadata; }
int GetDuration(void) { return m_duration; };
Visibility GetVisibility(void) { return m_visibility; }
Priority GetPriority(void) { return m_priority; }

protected:
MythNotification(const MythNotification &o) : MythEvent(o),
m_id(o.m_id), m_parent(o.m_parent), m_fullScreen(o.m_fullScreen),
m_description(o.m_description),
m_duration(o.m_duration), m_metadata(o.m_metadata),
m_visibility(o.m_visibility), m_priority(o.m_priority)
{
}

MythNotification &operator=(const MythNotification&);

protected:
int m_id;
void *m_parent;
bool m_fullScreen;
QString m_description;
int m_duration;
DMAP m_metadata;
Visibility m_visibility;
Priority m_priority;
};

class MUI_PUBLIC MythImageNotification : public MythNotification
{
public:
MythImageNotification(Type t, QImage &image, DMAP &metadata) :
MythNotification(t), m_image(image)
{
m_metadata = metadata;
}

virtual MythEvent *clone(void) const { return new MythImageNotification(*this); }

// Setter
/**
* image to be displayed with the notification
*/
void SetImage(QImage &image) { m_image = image; }

//Getter
QImage GetImage(void) { return m_image; }

protected:
MythImageNotification(const MythImageNotification &o) : MythNotification(o),
m_image(o.m_image)
{
}

MythImageNotification &operator=(const MythImageNotification&);

private:
QImage m_image;
};

#endif /* defined(__MythTV__mythnotification__) */

0 comments on commit d33d8cd

Please sign in to comment.