diff options
| author | Javier S. Pedro <maemo@javispedro.com> | 2011-12-09 02:26:31 +0100 | 
|---|---|---|
| committer | Javier S. Pedro <maemo@javispedro.com> | 2011-12-09 02:26:31 +0100 | 
| commit | 140c6bfafe91007c7e24ebf59270c8ad8060e875 (patch) | |
| tree | 59c23a95edb83736fb914ade8fc287c5490528fd | |
| parent | cbf8e3ad49917dc71e8c5f6413c55f266c1c4ad3 (diff) | |
| download | sowatch-140c6bfafe91007c7e24ebf59270c8ad8060e875.tar.gz sowatch-140c6bfafe91007c7e24ebf59270c8ad8060e875.zip  | |
Removing the entire grabButton/ungrab mechanism
Applications&server no longer have to grab/ungrab buttons.
Also, LED button should now work everywhere in digital MetaWatch.
| -rw-r--r-- | libsowatch/declarativewatchwrapper.cpp | 21 | ||||
| -rw-r--r-- | libsowatch/declarativewatchwrapper.h | 2 | ||||
| -rw-r--r-- | libsowatch/watch.h | 7 | ||||
| -rw-r--r-- | libsowatch/watchserver.cpp | 3 | ||||
| -rw-r--r-- | libsowatch/watchserver.h | 4 | ||||
| -rw-r--r-- | metawatch/metawatch.cpp | 23 | ||||
| -rw-r--r-- | metawatch/metawatch.h | 7 | ||||
| -rw-r--r-- | metawatch/metawatchanalog.cpp | 4 | ||||
| -rw-r--r-- | metawatch/metawatchdigital.cpp | 12 | ||||
| -rw-r--r-- | notificationswatchlet/metawatch-digital.qml | 4 | ||||
| -rw-r--r-- | qmafwwatchlet/metawatch-digital.qml | 7 | 
11 files changed, 31 insertions, 63 deletions
diff --git a/libsowatch/declarativewatchwrapper.cpp b/libsowatch/declarativewatchwrapper.cpp index 122545f..ebf92b5 100644 --- a/libsowatch/declarativewatchwrapper.cpp +++ b/libsowatch/declarativewatchwrapper.cpp @@ -36,16 +36,6 @@ QList<QObject*> DeclarativeWatchWrapper::notifications() const  	return ol;  } -void DeclarativeWatchWrapper::useButton(int button) -{ -	if (!_usedButtons.contains(button)) { -		_usedButtons.insert(button); -		if (_active) { -			_watch->grabButton(button); -		} -	} -} -  void DeclarativeWatchWrapper::vibrate(int msecs)  {  	if (_active) { @@ -58,11 +48,6 @@ void DeclarativeWatchWrapper::activate()  	if (!_active) {  		_active = true; -		// Grab all of the buttons used by this watchlet -		foreach (int button, _usedButtons) { -			_watch->grabButton(button); -		} -  		// Forward the button signals  		connect(_watch, SIGNAL(buttonPressed(int)), this, SIGNAL(buttonPressed(int)));  		connect(_watch, SIGNAL(buttonReleased(int)), this, SIGNAL(buttonReleased(int))); @@ -84,13 +69,7 @@ void DeclarativeWatchWrapper::deactivate()  		// Stop forwarding button presses  		disconnect(_watch, 0, this, 0); -		// Ungrab all the buttons used by this watchlet -		foreach (int button, _usedButtons) { -			_watch->ungrabButton(button); -		} -  		// Emit the deactivated signal  		emit activeChanged();  	}  } - diff --git a/libsowatch/declarativewatchwrapper.h b/libsowatch/declarativewatchwrapper.h index 5a827ab..8d4fd7d 100644 --- a/libsowatch/declarativewatchwrapper.h +++ b/libsowatch/declarativewatchwrapper.h @@ -28,7 +28,6 @@ public:  	QList<QObject*> notifications() const;  public slots: -	void useButton(int button);  	void vibrate(int msecs);  signals: @@ -42,7 +41,6 @@ private:  	WatchServer *_server;  	Watch* _watch;  	bool _active; -	QSet<int> _usedButtons;  	void activate();  	void deactivate(); diff --git a/libsowatch/watch.h b/libsowatch/watch.h index eb572eb..60a66bd 100644 --- a/libsowatch/watch.h +++ b/libsowatch/watch.h @@ -55,11 +55,6 @@ public:  	virtual void queryCharging() = 0;  	virtual bool charging() const = 0; -	/** Grabs a button from whatever is default function is for the current mode. */ -	virtual void grabButton(int button) = 0; -	/** Restores a button to its default function. */ -	virtual void ungrabButton(int button) = 0; -  	/** Tells the watch to update the unread notifications count, if visible. */  	virtual void updateNotificationCount(Notification::Type type, int count) = 0; @@ -71,7 +66,7 @@ public slots:  	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. */ +	/** Enter application mode; after this, server can draw on the QPaintDevice. */  	virtual void displayApplication() = 0;  	/** Vibrate for a while. The default implementation does nothing. */ diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp index 9d7859d..acb54c3 100644 --- a/libsowatch/watchserver.cpp +++ b/libsowatch/watchserver.cpp @@ -141,9 +141,6 @@ uint WatchServer::getNotificationCount(Notification::Type type)  void WatchServer::goToIdle()  {  	_watch->displayIdleScreen(); -	if (_nextWatchletButton >= 0) { -		_watch->grabButton(_nextWatchletButton); -	}  }  void WatchServer::watchConnected() diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h index f86d224..523efd5 100644 --- a/libsowatch/watchserver.h +++ b/libsowatch/watchserver.h @@ -77,11 +77,13 @@ private:  	/** Used for periodic time syncing. */  	QTimer* _syncTimeTimer; +	/** Called by Watchlet constructor to register itself as a child. */  	void registerWatchlet(Watchlet *watchlet); -	void reactivateCurrentWatchlet(); +	/** Counts all notifications from a given type. */  	uint getNotificationCount(Notification::Type type); +	void reactivateCurrentWatchlet();  	void goToIdle();  private slots: diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp index 3f3b831..a5836ad 100644 --- a/metawatch/metawatch.cpp +++ b/metawatch/metawatch.cpp @@ -102,7 +102,7 @@ MetaWatch::MetaWatch(const QBluetoothAddress& address, QSettings* settings, QObj  	_idleTimer->setSingleShot(true);  	connect(_idleTimer, SIGNAL(timeout()), SIGNAL(idling())); -	_ringTimer->setInterval(2500); +	_ringTimer->setInterval(DelayBetweenRings);  	connect(_ringTimer, SIGNAL(timeout()), SLOT(timedRing()));  	_connectTimer->setSingleShot(true); @@ -110,7 +110,7 @@ MetaWatch::MetaWatch(const QBluetoothAddress& address, QSettings* settings, QObj  	connect(_connectTimer, SIGNAL(timeout()), SLOT(retryConnect()));  	connect(_connectAlignedTimer, SIGNAL(timeout()), SLOT(retryConnect())); -	_sendTimer->setInterval(10); +	_sendTimer->setInterval(DelayBetweenMessages);  	connect(_sendTimer, SIGNAL(timeout()), SLOT(timedSend()));  	retryConnect(); @@ -209,16 +209,6 @@ bool MetaWatch::charging() const  	return _watchCharging;  } -void MetaWatch::grabButton(int button) -{ -	grabButton(_currentMode, (Button) button); -} - -void MetaWatch::ungrabButton(int button) -{ -	ungrabButton(_currentMode, (Button) button); -} -  void MetaWatch::updateNotificationCount(Notification::Type type, int count)  {  	Q_UNUSED(type); @@ -251,7 +241,7 @@ void MetaWatch::displayNotification(Notification *notification)  		_idleTimer->stop();  	} else {  		_ringTimer->stop(); -		setVibrateMode(true, 500, 500, 2); +		setVibrateMode(true, RingLength, RingLength, 2);  		_idleTimer->start();  	}  } @@ -480,6 +470,8 @@ void MetaWatch::enableButton(Mode mode, Button button, ButtonPress press)  	msg.data[1] = btnToWatch[button];  	msg.data[2] = press;  	msg.data[3] = ButtonEvent; +	// We create a custom event code that allows us to know what +	// the pressed button and the event code were.  	msg.data[4] = 0x80 | ((press << 4) & 0x30) | (button & 0xF);  	send(msg); @@ -682,11 +674,6 @@ void MetaWatch::socketConnected()  		// Sync watch date & time  		setDateTime(QDateTime::currentDateTime()); -		// Grab a few buttons from Notification mode that we handle -		grabButton(NotificationMode, BtnA); -		grabButton(NotificationMode, BtnB); -		grabButton(NotificationMode, BtnC); -  		// Call the MetaWatch Model-specific setup routines  		handleWatchConnected(); diff --git a/metawatch/metawatch.h b/metawatch/metawatch.h index 7ea835f..5a42b8d 100644 --- a/metawatch/metawatch.h +++ b/metawatch/metawatch.h @@ -26,6 +26,10 @@ public:  	explicit MetaWatch(const QBluetoothAddress& address, QSettings* settings = 0, QObject *parent = 0);  	~MetaWatch(); +	static const int DelayBetweenMessages = 10; +	static const int DelayBetweenRings = 2500; +	static const int RingLength = 500; +  	enum MessageType {  		NoMessage = 0,  		GetDeviceType = 0x01, @@ -109,9 +113,6 @@ public:  	void queryCharging();  	bool charging() const; -	void grabButton(int button); -	void ungrabButton(int button); -  	void updateNotificationCount(Notification::Type type, int count);  	void updateWeather(WeatherNotification *weather); diff --git a/metawatch/metawatchanalog.cpp b/metawatch/metawatchanalog.cpp index 0b867da..60993d4 100644 --- a/metawatch/metawatchanalog.cpp +++ b/metawatch/metawatchanalog.cpp @@ -2,6 +2,10 @@  using namespace sowatch; +// TODO : Figure out what to do with the buttons +// TODO : Figure out how the OLED screen protocol works, including scrolling +// TODO : Idle and Notification screens for the Analog Metawatch +  MetaWatchAnalog::MetaWatchAnalog(const QBluetoothAddress& address, QSettings* settings, QObject *parent) :  	MetaWatch(address, settings, parent)  { diff --git a/metawatch/metawatchdigital.cpp b/metawatch/metawatchdigital.cpp index b91b370..50ce301 100644 --- a/metawatch/metawatchdigital.cpp +++ b/metawatch/metawatchdigital.cpp @@ -333,6 +333,18 @@ QImage MetaWatchDigital::iconForNotification(const Notification *n)  void MetaWatchDigital::handleWatchConnected()  { +	// Grab all of the buttons that are of interest to us +	// We do not grab the D button, as it triggers the LED. +	grabButton(IdleMode, BtnA); +	grabButton(NotificationMode, BtnA); +	grabButton(NotificationMode, BtnB); +	grabButton(NotificationMode, BtnC); +	grabButton(ApplicationMode, BtnA); +	grabButton(ApplicationMode, BtnB); +	grabButton(ApplicationMode, BtnC); +	grabButton(ApplicationMode, BtnE); +	grabButton(ApplicationMode, BtnF); +  	// Configure to show watch-rendered clock in idle screen  	configureLcdIdleSystemArea(false); diff --git a/notificationswatchlet/metawatch-digital.qml b/notificationswatchlet/metawatch-digital.qml index 54f02d2..e5764ec 100644 --- a/notificationswatchlet/metawatch-digital.qml +++ b/notificationswatchlet/metawatch-digital.qml @@ -45,10 +45,6 @@ Rectangle {  		wrapMode: Text.Wrap  	} -	Component.onCompleted: { -		watch.useButton(1); -		watch.useButton(2); -	}  	Connections {  		target: watch  		onButtonPressed : { diff --git a/qmafwwatchlet/metawatch-digital.qml b/qmafwwatchlet/metawatch-digital.qml index 345aab6..7ceda73 100644 --- a/qmafwwatchlet/metawatch-digital.qml +++ b/qmafwwatchlet/metawatch-digital.qml @@ -37,14 +37,11 @@ Rectangle {  			case 2:  				player.volumeDown();  				break; -			case 3: -				player.playPause(); -				break;  			case 4: -				player.next(); +				player.playPause();  				break;  			case 5: -				player.previous(); +				player.next();  				break;  			}  		}  | 
