summaryrefslogtreecommitdiff
path: root/libsowatch/watch.h
blob: 6a24d3e4f9edbb26b4dad5849cc493813653b767 (plain)
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
#ifndef SOWATCH_WATCH_H
#define SOWATCH_WATCH_H

#include <QtCore/QObject>
#include <QtCore/QDateTime>
#include <QtCore/QStringList>
#include <QtGui/QPaintDevice>
#include <QtGui/QImage>
#include "notification.h"
#include "weathernotification.h"
#include "sowatch_global.h"

namespace sowatch
{

class WatchletsModel;
class NotificationsModel;

class SOWATCH_EXPORT Watch : public QObject, public QPaintDevice
{
	Q_OBJECT
	Q_PROPERTY(QString model READ model CONSTANT)
	Q_PROPERTY(bool connected READ isConnected)
	Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged)
	Q_PROPERTY(int batteryLevel READ batteryLevel NOTIFY batteryLevelChanged)
	Q_PROPERTY(bool charging READ charging NOTIFY chargingChanged)

public:
	explicit Watch(QObject* parent = 0);
	~Watch();

	/** Return a string identifying this watch's model. */
	virtual QString model() const = 0;

	/** Names for all the buttons this watch has. Order is important. */
	virtual QStringList buttons() const = 0;

	/** Should return true if the watch is connected. */
	virtual bool isConnected() const = 0;
	/** Indicates if watch is too busy atm and we should limit frame rate. */
	virtual bool busy() const = 0;

	/** Sets the current date/time on the watch. */
	virtual void setDateTime(const QDateTime& dateTime) = 0;
	/** Asynchronously queries battery date/time from the watch; once the
	 *  query is finished, dateTimeChanged() will be signaled and dateTime()
	 *  will return the updated value.
	 *  This is not mandatory and returning currentDateTime() is just fine.
     */
	virtual void queryDateTime() = 0;
	/** Gets the current date/time as last fetched from the watch. */
	virtual QDateTime dateTime() const = 0;

	/** Asynchronously queries battery level from the watch. */
	virtual void queryBatteryLevel() = 0;
	/** Gets the battery level (range [0-100]) as last read from the watch. */
	virtual int batteryLevel() const = 0;

	/** Asynchronously queries whether the watch is connected to a charger. */
	virtual void queryCharging() = 0;
	virtual bool charging() const = 0;

	virtual void setWatchletsModel(WatchletsModel *model);
	virtual void setNotificationsModel(NotificationsModel *model);

public slots:
	/** Go back to the idle screen. */
	virtual void displayIdleScreen() = 0;
	/** A standard notification; it's up to the watch when to stop showing it. */
	virtual void displayNotification(Notification* notification) = 0;
	/** Enter application mode; after this, server can draw on the QPaintDevice. */
	virtual void displayApplication() = 0;

	/** Vibrate for a while. The default implementation does nothing. */
	virtual void vibrate(int msecs);

signals:
	/** The watch has been found and linked to. */
	void connected();
	/** The watch connection has been lost. */
	void disconnected();
	/** The watch has returned to the idle screen by either inactivity or notification cleared/timeout. */
	void idling();
	/** Emitted once the queryDateTime() operation is completed. */
	void dateTimeChanged();
	/** Emitted once the queryBatteryLevel() operation is completed. */
	void batteryLevelChanged();
	/** Emitted once the queryCharging() operation is completed. */
	void chargingChanged();
	/** A button has been pressed. */
	void buttonPressed(int button);
	/** A button has been pressed and then released. */
	void buttonReleased(int button);
	/** Emitted when e.g. either via the watch menu, or similar, advancing watchlet carrousel is requested. */
	void nextWatchletRequested();
	/** Emitted when e.g. either via the watch menu, or similar, a given watchlet is requested. */
	void watchletRequested(const QString& id);
	/** Emitted when closing the current watchlet is requested. */
	void closeWatchledRequested();
};

}

#endif // SOWATCH_WATCH_H