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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
#ifndef SOWATCH_WATCHSERVER_H
#define SOWATCH_WATCHSERVER_H
#include <QtCore/QList>
#include <QtCore/QStringList>
#include <QtCore/QMap>
#include <QtCore/QQueue>
#include <QtCore/QTimer>
#include "sowatch_global.h"
#include "notificationsmodel.h"
namespace sowatch
{
class Watch;
class Watchlet;
class NotificationProvider;
class WeatherNotification;
class SOWATCH_EXPORT WatchServer : public QObject
{
Q_OBJECT
Q_PROPERTY(Watch* watch READ watch CONSTANT)
Q_PROPERTY(QString nextWatchletButton READ nextWatchletButton WRITE setNextWatchletButton)
Q_PROPERTY(Watchlet* idleWatchlet READ idleWatchlet WRITE setIdleWatchlet)
Q_PROPERTY(Watchlet* notificationWatchlet READ notificationWatchlet WRITE setNotificationWatchlet)
public:
explicit WatchServer(Watch *watch, QObject *parent = 0);
Watch* watch();
const Watch* watch() const;
QString nextWatchletButton() const;
void setNextWatchletButton(const QString& value);
Watchlet *idleWatchlet();
void setIdleWatchlet(Watchlet *watchlet);
Watchlet *notificationWatchlet();
void setNotificationWatchlet(Watchlet *watchlet);
void addWatchlet(Watchlet *watchlet);
void insertWatchlet(int position, Watchlet *watchlet);
void moveWatchlet(const Watchlet *watchlet, int to);
void removeWatchlet(const Watchlet *watchlet);
void addProvider(NotificationProvider *provider);
void removeProvider(const NotificationProvider *provider);
/** Get a list of all current live notifications. */
const NotificationsModel * notifications() const;
public slots:
void postNotification(Notification *notification);
void nextNotification();
/** Run the selected watchlet (set it as active, but not as current). */
void runWatchlet(Watchlet* watchlet);
/** Run the selected watchlet and set it as the current.
If the watch is disconnected, a notification arrives, etc. */
void openWatchlet(Watchlet* watchlet);
void openWatchlet(const QString& id);
/** Close the active watchlet (and return back to the current watc) */
void closeWatchlet();
/** Close the active watchlet, advance the current watchlet carousel and open it */
void nextWatchlet();
void syncTime();
signals:
void watchConnected();
void watchDisconnected();
private:
Watch* _watch;
/** The watch button that causes next watchlet to be run. */
int _nextWatchletButton;
/** The amount of seconds that have to pass for a notification to be considered "outdated" and not shown. */
int _oldNotificationThreshold;
/** The watchlet that is activated whenever the watch goes to the idle screen (optional). */
Watchlet *_idleWatchlet;
/** The watchlet that is used to display notifications (optional). */
Watchlet *_notificationWatchlet;
/** A list of watchlets, in order. */
QList<Watchlet*> _watchlets;
/** Stores all the watchlets with a given watchled id. */
QMap<QString, Watchlet*> _watchletIds;
/** Stores current live notifications. */
NotificationsModel *_notifications;
/** A list of notifications that are yet to be shown to the user. */
QQueue<Notification*> _pendingNotifications;
/** Stores the count of notifications hidden between each notification object. */
QMap<Notification*, uint> _notificationCounts;
/** We store a currently live weather forecast. */
WeatherNotification* _weather;
/** Active watchlet is the one that has "focus" right now. */
Watchlet* _activeWatchlet;
/** Current watchlet is the app watchlet (not idle, not notification) that is current in the carrousel. */
Watchlet* _currentWatchlet;
/** The current watchlet index if any, for use by nextWatchlet() */
int _currentWatchletIndex;
/** Used for periodic watch time syncing. */
QTimer* _syncTimeTimer;
/** Counts all notifications from a given type. */
uint getNotificationCount(Notification::Type type);
/** Remove a notification of a certain type. */
void removeNotification(Notification::Type type, Notification* n);
void setWatchletProperties(Watchlet *watchlet);
void unsetWatchletProperties(Watchlet *watchlet);
void activateWatchlet(Watchlet *watchlet);
void deactivateActiveWatchlet();
void activateCurrentWatchlet();
void goToIdle();
private slots:
void handleWatchConnected();
void handleWatchDisconnected();
void handleWatchIdling();
void handleWatchButtonPress(int button);
void handleNotificationChanged();
void handleNotificationDismissed();
void handleNotificationDestroyed();
};
}
#endif // SOWATCH_WATCHSERVER_H
|