diff options
| author | Javier S. Pedro <maemo@javispedro.com> | 2011-09-18 04:26:20 +0200 | 
|---|---|---|
| committer | Javier S. Pedro <maemo@javispedro.com> | 2011-09-18 04:26:20 +0200 | 
| commit | c42d5abff1f5f51facc169dd593725d819c4c868 (patch) | |
| tree | 9aa8bdef88bf89561c7726948541a1ba3906b81e /metawatch | |
| parent | f225345d4de3b198a557fe3566f9630163e76d51 (diff) | |
| download | sowatch-c42d5abff1f5f51facc169dd593725d819c4c868.tar.gz sowatch-c42d5abff1f5f51facc169dd593725d819c4c868.zip | |
separation into lib and plugins complete
Diffstat (limited to 'metawatch')
| -rw-r--r-- | metawatch/idle_call.bmp | bin | 0 -> 134 bytes | |||
| -rw-r--r-- | metawatch/idle_gmail.bmp | bin | 0 -> 134 bytes | |||
| -rw-r--r-- | metawatch/idle_sms.bmp | bin | 0 -> 134 bytes | |||
| -rw-r--r-- | metawatch/metawatch.cpp | 261 | ||||
| -rw-r--r-- | metawatch/metawatch.h | 69 | ||||
| -rw-r--r-- | metawatch/metawatch.pro | 32 | ||||
| -rw-r--r-- | metawatch/metawatchpaintengine.cpp | 28 | ||||
| -rw-r--r-- | metawatch/metawatchpaintengine.h | 9 | ||||
| -rw-r--r-- | metawatch/metawatchplugin.cpp | 12 | ||||
| -rw-r--r-- | metawatch/metawatchplugin.h | 4 | ||||
| -rw-r--r-- | metawatch/metawatchsimulator.cpp | 3 | ||||
| -rw-r--r-- | metawatch/metawatchsimulator.h | 1 | ||||
| -rw-r--r-- | metawatch/uires.qrc | 7 | 
13 files changed, 332 insertions, 94 deletions
| diff --git a/metawatch/idle_call.bmp b/metawatch/idle_call.bmpBinary files differ new file mode 100644 index 0000000..2b69eea --- /dev/null +++ b/metawatch/idle_call.bmp diff --git a/metawatch/idle_gmail.bmp b/metawatch/idle_gmail.bmpBinary files differ new file mode 100644 index 0000000..fd129b0 --- /dev/null +++ b/metawatch/idle_gmail.bmp diff --git a/metawatch/idle_sms.bmp b/metawatch/idle_sms.bmpBinary files differ new file mode 100644 index 0000000..095ca62 --- /dev/null +++ b/metawatch/idle_sms.bmp diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp index b968fad..e6d8ea6 100644 --- a/metawatch/metawatch.cpp +++ b/metawatch/metawatch.cpp @@ -9,6 +9,10 @@ QTM_USE_NAMESPACE  #define SINGLE_LINE_UPDATE 0 +const int MetaWatch::connectRetryTimes[] = { +	5, 10, 30, 60, 120, 300 +}; +  const quint8 MetaWatch::bitRevTable[16] = {  	0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15  }; @@ -71,34 +75,77 @@ const quint16 MetaWatch::crcTable[256] = {  #endif  MetaWatch::MetaWatch(const QBluetoothAddress& address, QObject *parent) : -	Watch(QImage(96, 96, QImage::Format_MonoLSB), parent), -	_socket(new QBluetoothSocket(QBluetoothSocket::RfcommSocket)), -	_sendTimer(new QTimer(this)) +	Watch(parent), +	_paintEngine(0), +	_address(address), +	_socket(0), +	_connectRetries(0), +	_connected(false), +	_connectTimer(new QTimer(this)), +	_connectAlignedTimer(new QSystemAlignedTimer(this)), +	_sendTimer(new QTimer(this)), +	_currentMode(IdleMode), +	_paintMode(IdleMode)  { -	connect(_socket, SIGNAL(connected()), SLOT(socketConnected())); -	connect(_socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); -	connect(_socket, SIGNAL(readyRead()), SLOT(socketData())); -	connect(_socket, SIGNAL(error(QBluetoothSocket::SocketError)), -			SLOT(socketError(QBluetoothSocket::SocketError))); -	connect(_socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), -			SLOT(socketState(QBluetoothSocket::SocketState))); +	QImage baseImage(screenWidth, screenHeight, QImage::Format_MonoLSB); +	baseImage.setColor(0, QColor(Qt::white).rgb()); +	baseImage.setColor(1, QColor(Qt::black).rgb()); +	_image[IdleMode] = baseImage; +	_image[ApplicationMode] = baseImage; +	_image[NotificationMode] = baseImage; + +	_connectTimer->setSingleShot(true); +	_connectAlignedTimer->setSingleShot(true); +	connect(_connectTimer, SIGNAL(timeout()), SLOT(retryConnect())); +	connect(_connectAlignedTimer, SIGNAL(timeout()), SLOT(retryConnect()));  	_sendTimer->setInterval(30);  	connect(_sendTimer, SIGNAL(timeout()), SLOT(timedSend())); -	_socket->connectToService(address, 1, QIODevice::ReadWrite | QIODevice::Unbuffered); +	retryConnect(); +} + +MetaWatch::~MetaWatch() +{ +	delete _paintEngine;  }  QPaintEngine* MetaWatch::paintEngine() const  {  	if (!_paintEngine) { -		_paintEngine = new MetaWatchPaintEngine(const_cast<MetaWatch*>(this), -			const_cast<QImage*>(&_image)); +		_paintEngine = new MetaWatchPaintEngine(const_cast<MetaWatch*>(this));  	}  	return _paintEngine;  } +int MetaWatch::metric(PaintDeviceMetric metric) const +{ +	switch (metric) { +	case PdmWidth: +		return screenWidth; +	case PdmHeight: +		return _currentMode == IdleMode ? +			screenHeight - systemAreaHeight: screenHeight; +	case PdmWidthMM: +		return 24; +	case PdmHeightMM: +		return _currentMode == IdleMode ? 16 : 24; +	case PdmNumColors: +		return 2; +	case PdmDepth: +		return 1; +	case PdmDpiX: +	case PdmPhysicalDpiX: +		return 100; +	case PdmDpiY: +	case PdmPhysicalDpiY: +		return 100; +	} + +	return -1; +} +  QString MetaWatch::model() const  {  	return "metawatch-digital"; @@ -106,41 +153,19 @@ QString MetaWatch::model() const  bool MetaWatch::isConnected() const  { -	return _socket->state() == QBluetoothSocket::ConnectedState; +	return _connected;  }  bool MetaWatch::busy() const  { -	return _socket->state() != QBluetoothSocket::ConnectedState || +	return !_connected || +			_socket->state() != QBluetoothSocket::ConnectedState ||  			_toSend.size() > 20;  } -void MetaWatch::update(const QList<QRect> &rects) -{ -	if (_socket->state() != QBluetoothSocket::ConnectedState) return; -	const QRect imageRect = _image.rect(); -	QVector<bool> lines(_image.height(), false); - -	foreach (const QRect& rect, rects) { -		QRect r = rect.intersect(imageRect); -		for (int i = r.top(); i <= r.bottom(); i++) { -			lines[i] = true; -		} -	} - -	updateLines(ApplicationMode, _image, lines); -	updateDisplay(ApplicationMode); -} - -void MetaWatch::clear(bool white) -{qDebug() << "MWclear" << white; -	if (_socket->state() != QBluetoothSocket::ConnectedState) return; -	loadTemplate(ApplicationMode, white ? 1 : 0); -} - -void MetaWatch::vibrate(bool on) +QDateTime MetaWatch::dateTime()  { - +	return QDateTime::currentDateTime(); // TODO  }  void MetaWatch::setDateTime(const QDateTime &dateTime) @@ -149,7 +174,7 @@ void MetaWatch::setDateTime(const QDateTime &dateTime)  	const QDate& date = dateTime.date();  	const QTime& time = dateTime.time(); -	msg.data[0] = date.year() & 0xF00; +	msg.data[0] = (date.year() & 0xF00) >> 8;  	msg.data[1] = date.year() & 0xFF;  	msg.data[2] = date.month();  	msg.data[3] = date.day(); @@ -163,6 +188,81 @@ void MetaWatch::setDateTime(const QDateTime &dateTime)  	send(msg);  } +void MetaWatch::updateNotificationCount(Notification::Type type, int count) +{ +	Q_UNUSED(type); +	Q_UNUSED(count); // TODO +} + +void MetaWatch::vibrate(bool on) +{ +	Q_UNUSED(on); // TODO +} + +void MetaWatch::showNotification(const Notification &n) +{ +	Q_UNUSED(n); // TODO +} + +MetaWatch::Mode MetaWatch::currentMode() const +{ +	return _currentMode; +} + +MetaWatch::Mode MetaWatch::paintTargetMode() const +{ +	return _paintMode; +} + +QImage* MetaWatch::imageFor(Mode mode) +{ +	return &_image[mode]; +} + +void MetaWatch::update(Mode mode, const QList<QRect> &rects) +{ +	if (!_connected) return; +	const QRect clipRect(0, 0, screenWidth, screenHeight); +	QVector<bool> lines(screenHeight, false); + +	foreach (const QRect& rect, rects) { +		QRect r = rect.intersect(clipRect); +		for (int i = r.top(); i <= r.bottom(); i++) { +			lines[i] = true; +		} +	} + +	updateLines(mode, _image[mode], lines); +	if (mode == _currentMode) { +		updateDisplay(mode); +	} +} + +void MetaWatch::clear(Mode mode, bool black) +{ +	if (!_connected) return; +	loadTemplate(mode, black ? 1 : 0); +} + +void MetaWatch::renderIdleScreen() +{ +	_paintMode = IdleMode; +	QPainter p(this); +	p.fillRect(0, 0, screenWidth, screenHeight, Qt::white); +	p.setPen(QPen(Qt::black, 1.0, Qt::DashLine)); +	p.drawLine(0, systemAreaHeight + 2, screenWidth, systemAreaHeight + 2); +	p.drawLine(0, systemAreaHeight * 2 + 3, screenWidth, systemAreaHeight * 2 + 3); +	p.setPen(Qt::black); +	p.drawText(1, systemAreaHeight + 16, "Space Weather!"); +	QImage idle_mail(QString(":/metawatch/idle_gmail.bmp")); +	QImage idle_call(QString(":/metawatch/idle_call.bmp")); +	QImage idle_sms(QString(":/metawatch/idle_sms.bmp")); +	p.drawImage(4, systemAreaHeight * 2 + 6, idle_mail); +	p.drawImage(32 + 4, systemAreaHeight * 2 + 6, idle_call); +	p.drawImage(32 * 2 + 4, systemAreaHeight * 2 + 6, idle_sms); +	p.drawText(14, 93, "Too many!"); +} +  quint16 MetaWatch::calcCrc(const QByteArray &data, int size)  {  	quint16 remainder = 0xFFFF; @@ -277,6 +377,13 @@ void MetaWatch::configureWatchMode(Mode mode, int timeout, bool invert)  	send(msg);  } +void MetaWatch::configureIdleSystemArea(bool entireScreen) +{ +	Message msg(ConfigureIdleBufferSize, QByteArray(26, 0)); +	msg.data[0] = entireScreen ? 1 : 0; +	send(msg); +} +  void MetaWatch::updateDisplay(Mode mode, bool copy)  {  	Message msg(UpdateDisplay, QByteArray(), @@ -305,20 +412,54 @@ void MetaWatch::handleButtonEvent(const Message &msg)  void MetaWatch::socketConnected()  { -	qDebug() << "connected"; -	_partialReceived.type = NoMessage; -	_partialReceived.data.clear(); -	_buttonState = 0; -	setDateTime(QDateTime::currentDateTime()); -	configureWatchMode(ApplicationMode); -	emit connected(); +	if (!_connected) { +		qDebug() << "connected"; + +		_connected = true; +		_connectRetries = 0; +		_partialReceived.type = NoMessage; +		_partialReceived.data.clear(); +		_currentMode = IdleMode; +		_paintMode = IdleMode; +		_buttonState = 0; + +		setDateTime(QDateTime::currentDateTime()); +		configureIdleSystemArea(false); +		configureWatchMode(ApplicationMode, 240); +		configureWatchMode(NotificationMode, 30); + +		renderIdleScreen(); + +		emit connected(); +	}  }  void MetaWatch::socketDisconnected()  { -	_toSend.clear(); -	_sendTimer->stop(); -	emit disconnected(); +	if (_connected) { +		qDebug() << "disconnected"; + +		_connected = false; +		_toSend.clear(); +		_sendTimer->stop(); + +		emit disconnected(); +	} + +	int timeToNextRetry; +	if (_connectRetries >= connectRetryTimesSize) { +		timeToNextRetry = connectRetryTimes[connectRetryTimesSize - 1]; +	} else { +		timeToNextRetry = connectRetryTimes[_connectRetries]; +		_connectRetries++; +	} +	qDebug() << "Backing off for " << timeToNextRetry << "seconds for next retry"; +	_connectAlignedTimer->start(timeToNextRetry / 2, timeToNextRetry * 2); +	if (_connectAlignedTimer->lastError() != QSystemAlignedTimer::NoError) { +		// I would like to know why QtM couldn't _emulate_ here using a QTimer by itself. +		qDebug() << "Note: using plain QTimer for retry"; +		_connectTimer->start(timeToNextRetry * 1000); +	}  }  void MetaWatch::socketData() @@ -377,6 +518,22 @@ void MetaWatch::socketState(QBluetoothSocket::SocketState error)  	qDebug() << "socket is in" << error;  } +void MetaWatch::retryConnect() +{ +	delete _socket; +	_socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket); + +	connect(_socket, SIGNAL(connected()), SLOT(socketConnected())); +	connect(_socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); +	connect(_socket, SIGNAL(readyRead()), SLOT(socketData())); +	connect(_socket, SIGNAL(error(QBluetoothSocket::SocketError)), +			SLOT(socketError(QBluetoothSocket::SocketError))); +	connect(_socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), +			SLOT(socketState(QBluetoothSocket::SocketState))); + +	_socket->connectToService(_address, 1, QIODevice::ReadWrite | QIODevice::Unbuffered); +} +  void MetaWatch::timedSend()  {  	if (_toSend.count() > 0) { @@ -393,6 +550,8 @@ void MetaWatch::realSend(const Message &msg)  	QByteArray data;  	quint16 crc; +	Q_ASSERT(_connected && _socket); +  	data.resize(msgSize + 6);  	data[0] = 0x01;  	data[1] = msgSize + 6; diff --git a/metawatch/metawatch.h b/metawatch/metawatch.h index 80a1894..68e24c3 100644 --- a/metawatch/metawatch.h +++ b/metawatch/metawatch.h @@ -1,18 +1,22 @@  #ifndef METAWATCH_H  #define METAWATCH_H -#include <QtConnectivity/QBluetoothAddress> -#include <QtConnectivity/QBluetoothSocket>  #include <QtCore/QQueue>  #include <QtCore/QTimer> +#include <QtConnectivity/QBluetoothAddress> +#include <QtConnectivity/QBluetoothSocket> +#include <QtSystemInfo/QSystemAlignedTimer>  #include "watch.h"  using QTM_PREPEND_NAMESPACE(QBluetoothSocket);  using QTM_PREPEND_NAMESPACE(QBluetoothAddress); +using QTM_PREPEND_NAMESPACE(QSystemAlignedTimer);  namespace sowatch  { +class MetaWatchPaintEngine; +  class MetaWatch : public Watch  {      Q_OBJECT @@ -20,17 +24,11 @@ class MetaWatch : public Watch  public:  	explicit MetaWatch(const QBluetoothAddress& address, QObject *parent = 0); +	~MetaWatch(); -	QPaintEngine* paintEngine() const; - -	QString model() const; -	bool isConnected() const; -	bool busy() const; -	void update(const QList<QRect>& rects); -	void clear(bool white = false); -	void vibrate(bool on); - -	void setDateTime(const QDateTime& dateTime); +	static const int screenWidth = 96; +	static const int screenHeight = 96; +	static const int systemAreaHeight = 30;  	enum MessageType {  		NoMessage = 0, @@ -64,27 +62,62 @@ public:  	enum Mode {  		IdleMode = 0, -		ApplicationMode = 1 +		ApplicationMode = 1, +		NotificationMode = 2  	}; +	QPaintEngine* paintEngine() const; +	int metric(PaintDeviceMetric metric) const; + +	QString model() const; +	bool isConnected() const; +	bool busy() const; + +	QDateTime dateTime(); +	void setDateTime(const QDateTime& dateTime); + +	void updateNotificationCount(Notification::Type type, int count); + +	void vibrate(bool on); +	void showNotification(const Notification& n); + +	Mode currentMode() const; +	Mode paintTargetMode() const; +	QImage* imageFor(Mode mode); +	void clear(Mode mode, bool black = false); +	void update(Mode mode, const QList<QRect>& rects = QList<QRect>()); + +	void renderIdleScreen(); +  protected: +	mutable MetaWatchPaintEngine* _paintEngine; +	QImage _image[3]; + +	QBluetoothAddress _address;  	QBluetoothSocket* _socket; +	static const int connectRetryTimesSize = 6; +	static const int connectRetryTimes[connectRetryTimesSize]; +	short _connectRetries; +	bool _connected; +	QTimer* _connectTimer; +	QSystemAlignedTimer* _connectAlignedTimer; +  	struct Message {  		MessageType type;  		quint8 options;  		QByteArray data;  		Message(MessageType ntype = NoMessage, QByteArray ndata = QByteArray(), quint8 noptions = 0) :  			type(ntype), options(noptions), data(ndata) -		{ - -		} +		{ }  	};  	QQueue<Message> _toSend;  	QTimer* _sendTimer;  	Message _partialReceived; +	Mode _currentMode; +	Mode _paintMode;  	quint8 _buttonState;  	static const quint8 bitRevTable[16]; @@ -98,7 +131,8 @@ protected:  	void updateLine(Mode mode, const QImage& image, int line);  	void updateLines(Mode mode, const QImage& image, int lineA, int lineB);  	void updateLines(Mode mode, const QImage& image, const QVector<bool>& lines); -	void configureWatchMode(Mode mode, int timeout = 10, bool invert = false); +	void configureWatchMode(Mode mode, int timeout, bool invert = false); +	void configureIdleSystemArea(bool entireScreen);  	void updateDisplay(Mode mode, bool copy = true);  	void loadTemplate(Mode mode, int templ); @@ -111,6 +145,7 @@ protected slots:  	void socketData();  	void socketError(QBluetoothSocket::SocketError error);  	void socketState(QBluetoothSocket::SocketState error); +	void retryConnect();  	void timedSend();  private: diff --git a/metawatch/metawatch.pro b/metawatch/metawatch.pro index d8c63c4..fe04b11 100644 --- a/metawatch/metawatch.pro +++ b/metawatch/metawatch.pro @@ -6,8 +6,9 @@  TARGET = metawatch  TEMPLATE = lib +# CONFIG   += plugin # Stupid Qt creator doesn't want to deploy plugins  CONFIG   += mobility -MOBILITY += connectivity +MOBILITY += connectivity systeminfo  SOURCES += metawatchplugin.cpp \      metawatchsimulatorform.cpp \ @@ -24,6 +25,22 @@ HEADERS += metawatchplugin.h \  FORMS += \  	metawatchsimulatorform.ui +RESOURCES += \ +	uires.qrc + +OTHER_FILES += \ +	idle_sms.bmp \ +	idle_gmail.bmp \ +	idle_call.bmp + +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/release/ -llibsowatch +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/debug/ -llibsowatch +else:symbian: LIBS += -llibsowatch +else:unix: LIBS += -L$$OUT_PWD/../libsowatch/ -llibsowatch + +INCLUDEPATH += $$PWD/../libsowatch +DEPENDPATH += $$PWD/../libsowatch +  symbian {      MMP_RULES += EXPORTUNFROZEN      TARGET.UID3 = 0xE4DC26B0 @@ -36,18 +53,9 @@ symbian {  unix:!symbian {      maemo5 { -        target.path = /opt/usr/lib +		target.path = /opt/sowatch/drivers      } else { -        target.path = /usr/lib +		target.path = /usr/lib/sowatch/drivers      }      INSTALLS += target  } - - -win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/release/ -llibsowatch -else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/debug/ -llibsowatch -else:symbian: LIBS += -llibsowatch -else:unix: LIBS += -L$$OUT_PWD/../libsowatch/ -llibsowatch - -INCLUDEPATH += $$PWD/../libsowatch -DEPENDPATH += $$PWD/../libsowatch diff --git a/metawatch/metawatchpaintengine.cpp b/metawatch/metawatchpaintengine.cpp index 71ad452..58a7b9d 100644 --- a/metawatch/metawatchpaintengine.cpp +++ b/metawatch/metawatchpaintengine.cpp @@ -3,19 +3,37 @@  using namespace sowatch; -MetaWatchPaintEngine::MetaWatchPaintEngine(MetaWatch* watch, QImage* image) : -	WatchPaintEngine(watch, image),	_watch(watch), -	_imageRect(image->rect()) +MetaWatchPaintEngine::MetaWatchPaintEngine(MetaWatch* watch) : +	WatchPaintEngine(watch), _watch(watch), +	_imageRect(0, 0, MetaWatch::screenWidth, MetaWatch::screenHeight)  {  } +bool MetaWatchPaintEngine::begin(QPaintDevice *pdev) +{ +	_damaged = QRegion(); +	_watch = static_cast<MetaWatch*>(pdev); +	_mode = _watch->paintTargetMode(); + +	return _painter.begin(_watch->imageFor(_mode)); +} + +bool MetaWatchPaintEngine::end() +{ +	bool ret = _painter.end(); +	if (ret) { +		_watch->update(_mode, _damaged.rects().toList()); +	} +	return ret; +} +  void MetaWatchPaintEngine::drawRects(const QRectF *rects, int rectCount)  {  	int i;  	for (i = 0; i < rectCount; i++) {  		const QRectF& r = rects[i];  		if (_hasBrush && fillsEntireImage(r.toRect()) && (_isBrushBlack | _isBrushWhite)) { -			_watch->clear(_isBrushWhite); +			_watch->clear(_mode, _isBrushBlack);  			_damaged = QRegion();  			continue;  		} @@ -38,7 +56,7 @@ void MetaWatchPaintEngine::drawRects(const QRect *rects, int rectCount)  	for (i = 0; i < rectCount; i++) {  		const QRect& r = rects[i];  		if (_hasBrush && fillsEntireImage(r) && (_isBrushBlack | _isBrushWhite)) { -			_watch->clear(_isBrushWhite); +			_watch->clear(_mode, _isBrushBlack);  			_damaged = QRegion();  			continue;  		} diff --git a/metawatch/metawatchpaintengine.h b/metawatch/metawatchpaintengine.h index efc3d6e..c3b7466 100644 --- a/metawatch/metawatchpaintengine.h +++ b/metawatch/metawatchpaintengine.h @@ -2,18 +2,20 @@  #define METAWATCHPAINTENGINE_H  #include <QtCore/QRect> +#include "metawatch.h"  #include "watchpaintengine.h"  namespace sowatch  { -class MetaWatch; -  /** This WatchPaintEngine accelerates fillRects by using the MetaWatch's template command. */  class MetaWatchPaintEngine : public WatchPaintEngine  {  public: -	explicit MetaWatchPaintEngine(MetaWatch* watch, QImage* image); +	explicit MetaWatchPaintEngine(MetaWatch* watch); + +	bool begin(QPaintDevice *pdev); +	bool end();  	void drawRects(const QRectF *rects, int rectCount);  	void drawRects(const QRect *rects, int rectCount); @@ -24,6 +26,7 @@ protected:  	bool fillsEntireImage(const QRect& rect);  	MetaWatch* _watch; +	MetaWatch::Mode _mode;  	QRect _imageRect;  	bool _isBrushBlack;  	bool _isBrushWhite; diff --git a/metawatch/metawatchplugin.cpp b/metawatch/metawatchplugin.cpp index e5eaabf..e56d6db 100644 --- a/metawatch/metawatchplugin.cpp +++ b/metawatch/metawatchplugin.cpp @@ -1,8 +1,10 @@ +#include <QtConnectivity/QBluetoothAddress>  #include "metawatch.h"  #include "metawatchsimulator.h"  #include "metawatchplugin.h"  using namespace sowatch; +QTM_USE_NAMESPACE  MetaWatchPlugin::~MetaWatchPlugin()  { @@ -17,13 +19,17 @@ QStringList MetaWatchPlugin::drivers()  	return d;  } -Watch* MetaWatchPlugin::getWatch(const QString& driver, const QString& connId, QObject *parent) +Watch* MetaWatchPlugin::getWatch(const QString& driver, QSettings& settings, QObject *parent)  {  	if (driver == "metawatch-digital") { -		return new MetaWatch(QBluetoothAddress(connId), parent); +		QBluetoothAddress address(settings.value("address").toString()); +		return new MetaWatch(address, parent);  	} else if (driver == "metawatch-digital-sim") { -		return new MetaWatchSimulator(parent); +		//return new MetaWatchSimulator(parent); +		return 0;  	} else {  		return 0;  	}  } + +Q_EXPORT_PLUGIN2(metawatch, MetaWatchPlugin) diff --git a/metawatch/metawatchplugin.h b/metawatch/metawatchplugin.h index d0e7c91..9662ec0 100644 --- a/metawatch/metawatchplugin.h +++ b/metawatch/metawatchplugin.h @@ -8,13 +8,13 @@ namespace sowatch  class MetaWatchPlugin : public QObject, public WatchPluginInterface {  	Q_OBJECT -	Q_INTERFACES(WatchPluginInterface) +	Q_INTERFACES(sowatch::WatchPluginInterface)  public:  	~MetaWatchPlugin();  	virtual QStringList drivers(); -	virtual Watch* getWatch(const QString& driver, const QString& connId, QObject *parent = 0); +	virtual Watch* getWatch(const QString& driver, QSettings& settings, QObject *parent = 0);  };  } diff --git a/metawatch/metawatchsimulator.cpp b/metawatch/metawatchsimulator.cpp index 11b938a..57a4f0c 100644 --- a/metawatch/metawatchsimulator.cpp +++ b/metawatch/metawatchsimulator.cpp @@ -9,7 +9,8 @@  using namespace sowatch;  MetaWatchSimulator::MetaWatchSimulator(QObject *parent) : -	WatchSimulator(QImage(96, 96, QImage::Format_Mono), parent), +	WatchSimulator(parent), +	_image(96, 96, QImage::Format_Mono),  	_screen(96, 96),  	_form(new MetaWatchSimulatorForm),  	_nextFrame(QTime::currentTime()) diff --git a/metawatch/metawatchsimulator.h b/metawatch/metawatchsimulator.h index 674c3c6..38391d0 100644 --- a/metawatch/metawatchsimulator.h +++ b/metawatch/metawatchsimulator.h @@ -22,6 +22,7 @@ public:  	void vibrate(bool on);  protected: +	QImage _image;  	QPixmap _screen;  	MetaWatchSimulatorForm* _form;  	QTime _nextFrame; diff --git a/metawatch/uires.qrc b/metawatch/uires.qrc new file mode 100644 index 0000000..4be7fc8 --- /dev/null +++ b/metawatch/uires.qrc @@ -0,0 +1,7 @@ +<RCC> +    <qresource prefix="/metawatch"> +        <file>idle_call.bmp</file> +        <file>idle_gmail.bmp</file> +        <file>idle_sms.bmp</file> +    </qresource> +</RCC> | 
