/
notificationpreviewpresenter.h
114 lines (92 loc) · 3.29 KB
/
notificationpreviewpresenter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/***************************************************************************
**
** Copyright (c) 2012 Jolla Ltd.
**
** This file is part of lipstick.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#ifndef NOTIFICATIONPREVIEWPRESENTER_H
#define NOTIFICATIONPREVIEWPRESENTER_H
#include "lipstickglobal.h"
#include <QObject>
namespace NemoDeviceLock {
class DeviceLock;
}
class HomeWindow;
class LipstickNotification;
class NotificationFeedbackPlayer;
class ScreenLock;
/*!
* \class NotificationPreviewPresenter
*
* \brief Presents notification previews one at a time.
*
* Creates a transparent notification window which can be used to show
* notification previews.
*/
class LIPSTICK_EXPORT NotificationPreviewPresenter : public QObject
{
Q_OBJECT
Q_PROPERTY(LipstickNotification *notification READ notification NOTIFY notificationChanged)
public:
explicit NotificationPreviewPresenter(ScreenLock *screenLock, NemoDeviceLock::DeviceLock *deviceLock,
QObject *parent = 0);
virtual ~NotificationPreviewPresenter();
/*!
* Returns the notification to be currently shown or 0 if no notification
* should be shown.
*
* \return the notification to be currently shown or 0 if no notification should be shown
*/
LipstickNotification *notification() const;
signals:
//! Sent when the notification to be shown has changed.
void notificationChanged();
public slots:
/*!
* Shows the next notification to be shown, if any. If the notification
* window is not yet visible, shows the window. If there is no
* notification to be shown but the window is visible, hides the window.
*/
void showNextNotification();
private slots:
/*!
* Updates the notification with the given ID.
*
* \param id the ID of the notification to be updated
*/
void updateNotification(uint id);
/*!
* Removes the notification with the given ID.
*
* \param id the ID of the notification to be removed
*/
void removeNotification(uint id, bool onlyFromQueue = false);
//! Creates the notification window if it has not been created yet.
void createWindowIfNecessary();
private:
bool notificationShouldBeShown(LipstickNotification *notification);
//! Sets the given notification as the current notification
void setCurrentNotification(LipstickNotification *notification);
//! The notification window
HomeWindow *m_window;
//! Notifications to be shown
QList<LipstickNotification *> m_notificationQueue;
//! Notification currently being shown
LipstickNotification *m_currentNotification;
//! Player for notification feedbacks
NotificationFeedbackPlayer *m_notificationFeedbackPlayer;
//! For getting information about the touch screen lock state
ScreenLock *m_screenLock;
NemoDeviceLock::DeviceLock *m_deviceLock;
#ifdef UNIT_TEST
friend class Ut_NotificationPreviewPresenter;
#endif
};
#endif // NOTIFICATIONPREVIEWPRESENTER_H