diff options
Diffstat (limited to 'metawatch')
17 files changed, 385 insertions, 267 deletions
| diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp index 6f8edca..6dfdd2f 100644 --- a/metawatch/metawatch.cpp +++ b/metawatch/metawatch.cpp @@ -109,13 +109,14 @@ MetaWatch::MetaWatch(ConfigKey* settings, QObject* parent) :  	_connectTimer->setSingleShot(true);  	_connectAlignedTimer->setSingleShot(true); -	connect(_connectTimer, SIGNAL(timeout()), SLOT(retryConnect())); -	connect(_connectAlignedTimer, SIGNAL(timeout()), SLOT(retryConnect())); +	connect(_connectTimer, SIGNAL(timeout()), SLOT(timedReconnect())); +	connect(_connectAlignedTimer, SIGNAL(timeout()), SLOT(timedReconnect()));  	_sendTimer->setInterval(DelayBetweenMessages);  	connect(_sendTimer, SIGNAL(timeout()), SLOT(timedSend())); -	retryConnect(); +	// Do an initial connection attempt +	_connectTimer->start(100);  }  MetaWatch::~MetaWatch() @@ -249,7 +250,7 @@ void MetaWatch::displayNotification(Notification *notification)  		_idleTimer->stop();  	} else {  		_ringTimer->stop(); -		setVibrateMode(true, RingLength, RingLength, 2); +		// XXX setVibrateMode(true, RingLength, RingLength, 2);  		_idleTimer->start();  	}  } @@ -322,6 +323,22 @@ quint16 MetaWatch::calcCrc(const Message& msg)  	return calcCrc(data, msgSize + 4);  } +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::send(const Message &msg)  {  	_toSend.enqueue(msg); @@ -754,20 +771,9 @@ void MetaWatch::socketState(QBluetoothSocket::SocketState error)  	qDebug() << "socket is in" << error;  } -void MetaWatch::retryConnect() +void MetaWatch::timedReconnect()  { -	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); +	retryConnect();  }  void MetaWatch::timedSend() diff --git a/metawatch/metawatch.h b/metawatch/metawatch.h index 760752b..b25b14d 100644 --- a/metawatch/metawatch.h +++ b/metawatch/metawatch.h @@ -198,8 +198,11 @@ protected:  	static quint16 calcCrc(const QByteArray& data, int size);  	static quint16 calcCrc(const Message& msg); +	/** Attempt a connection to the watch. */ +	virtual void retryConnect(); +  	/** Sends a message to the watch. Does not block. */ -	void send(const Message& msg); +	virtual void send(const Message& msg);  	/** Sends a message to the watch if a message of the same type is not  	 *  already queued. Does not block.  	 */ @@ -237,7 +240,7 @@ private slots:  	void socketData();  	void socketError(QBluetoothSocket::SocketError error);  	void socketState(QBluetoothSocket::SocketState error); -	void retryConnect(); +	void timedReconnect();  	void timedSend();  	void timedRing(); diff --git a/metawatch/metawatch.pro b/metawatch/metawatch.pro index 721380d..536ccee 100644 --- a/metawatch/metawatch.pro +++ b/metawatch/metawatch.pro @@ -12,25 +12,25 @@ maemo5 {  MOBILITY += connectivity systeminfo  SOURCES += metawatchplugin.cpp \ -    metawatchsimulatorform.cpp \ -    metawatchsimulator.cpp \      metawatchpaintengine.cpp \      metawatch.cpp \      metawatchdigital.cpp \      metawatchanalog.cpp \ -    metawatchscanner.cpp +    metawatchscanner.cpp \ +    metawatchdigitalsimulator.cpp \ +    metawatchdigitalsimulatorform.cpp  HEADERS += metawatchplugin.h \ -    metawatchsimulatorform.h \ -    metawatchsimulator.h \      metawatchpaintengine.h \      metawatch.h \      metawatchdigital.h \      metawatchanalog.h \ -    metawatchscanner.h +    metawatchscanner.h \ +    metawatchdigitalsimulator.h \ +    metawatchdigitalsimulatorform.h  FORMS += \ -	metawatchsimulatorform.ui +    metawatchdigitalsimulatorform.ui  res_files.files += res/graphics res/fonts  qml_files.files += qml/com qml/metawatch-digital-config.qml diff --git a/metawatch/metawatchdigitalsimulator.cpp b/metawatch/metawatchdigitalsimulator.cpp new file mode 100644 index 0000000..f12e987 --- /dev/null +++ b/metawatch/metawatchdigitalsimulator.cpp @@ -0,0 +1,119 @@ +#include <QtCore/QDebug> +#include <QtGui/QPainter> + +#include "metawatchdigitalsimulator.h" + +#define SIMULATE_DAMAGES 1 +#define SIMULATE_FRAMERATE 1 + +using namespace sowatch; + +MetaWatchDigitalSimulator::MetaWatchDigitalSimulator(ConfigKey *config, QObject *parent) : +	MetaWatchDigital(config, parent), +	_form(new MetaWatchDigitalSimulatorForm), +	_nextFrame(QTime::currentTime()) +{ +	_pixmap[IdleMode] = QPixmap(screenWidth, screenHeight); +	_pixmap[ApplicationMode] = QPixmap(screenWidth, screenHeight); +	_pixmap[NotificationMode] = QPixmap(screenWidth, screenHeight); +	_form->showNormal(); +	connect(_form, SIGNAL(buttonPressed(int)), SIGNAL(buttonPressed(int))); +	connect(_form, SIGNAL(buttonReleased(int)), SIGNAL(buttonReleased(int))); +} + +MetaWatchDigitalSimulator::~MetaWatchDigitalSimulator() +{ +	delete _form; +} + +bool MetaWatchDigitalSimulator::busy() const +{ +#if SIMULATE_FRAMERATE +	return _nextFrame > QTime::currentTime(); +#else +	return false; +#endif +} + +void MetaWatchDigitalSimulator::displayIdleScreen() +{ +	MetaWatchDigital::displayIdleScreen(); +	_form->refreshScreen(_pixmap[_currentMode]); +} + +void MetaWatchDigitalSimulator::displayNotification(Notification *notification) +{ +	MetaWatchDigital::displayNotification(notification); +	_form->refreshScreen(_pixmap[_currentMode]); +} + +void MetaWatchDigitalSimulator::displayApplication() +{ +	MetaWatchDigital::displayApplication(); +	// No need to refresh. +} + +void MetaWatchDigitalSimulator::clear(Mode mode, bool black) +{ +	_pixmap[mode].fill(black ? Qt::black : Qt::white); +	if (mode == _currentMode) { +		_form->refreshScreen(_pixmap[mode]); +	} +} + +void MetaWatchDigitalSimulator::update(Mode mode, const QList<QRect> &rects) +{ +#if SIMULATE_DAMAGES +	const QRect imageRect = _image[mode].rect(); +	QPainter p; +	QVector<bool> rows(96, false); + +	p.begin(&_pixmap[mode]); +	foreach (const QRect& rect, rects) { +		QRect r = rect.intersect(imageRect); +		for (int i = r.top(); i <= r.bottom(); i++) { +			rows[i] = true; +		} + +		p.drawImage(r, _image[mode], r); +	} +	p.end(); + +	int totalRows = rows.count(true); + +	qDebug() << "updated" << totalRows << "lines"; +	_nextFrame = QTime::currentTime().addMSecs(((totalRows / 2) + 1) * DelayBetweenMessages); +#else +	Q_UNUSED(rects); +	_pixmap[mode] = QPixmap::fromImage(_image[mode]); +	_nextFrame = QTime::currentTime().addMSecs(DelayBetweenMessages); +#endif +	if (mode == _currentMode) { +		_form->refreshScreen(_pixmap[mode]); +	} +} + +void MetaWatchDigitalSimulator::vibrate(bool on) +{ +	qDebug() << "vibrate" << on; +} + +void MetaWatchDigitalSimulator::retryConnect() +{ +	if (!_connected && _form) { +		qDebug() << "connected"; + +		_connected = true; +		_currentMode = IdleMode; +		_paintMode = IdleMode; + +		handleWatchConnected(); + +		emit connected(); +	} +} + +void MetaWatchDigitalSimulator::send(const Message &msg) +{ +	// Do not send messages +} diff --git a/metawatch/metawatchdigitalsimulator.h b/metawatch/metawatchdigitalsimulator.h new file mode 100644 index 0000000..6f5c130 --- /dev/null +++ b/metawatch/metawatchdigitalsimulator.h @@ -0,0 +1,40 @@ +#ifndef METAWATCHSIMULATOR_H +#define METAWATCHSIMULATOR_H + +#include <QtCore/QTime> +#include <QtGui/QPixmap> +#include "metawatchdigital.h" +#include "metawatchdigitalsimulatorform.h" + +namespace sowatch { + +class MetaWatchDigitalSimulator : public MetaWatchDigital +{ +    Q_OBJECT +public: +    explicit MetaWatchDigitalSimulator(ConfigKey *settings, QObject *parent = 0); +	~MetaWatchDigitalSimulator(); + +	bool busy() const; + +	void displayIdleScreen(); +	void displayNotification(Notification *notification); +	void displayApplication(); + +	void clear(Mode mode, bool black); +	void update(Mode mode, const QList<QRect> &rects); + +	void vibrate(bool on); + +	void retryConnect(); +	void send(const Message& msg); + +private: +	MetaWatchDigitalSimulatorForm* _form; +	QPixmap _pixmap[3]; +	QTime _nextFrame; +}; + +} + +#endif // METAWATCHSIMULATOR_H diff --git a/metawatch/metawatchdigitalsimulatorform.cpp b/metawatch/metawatchdigitalsimulatorform.cpp new file mode 100644 index 0000000..fc3c890 --- /dev/null +++ b/metawatch/metawatchdigitalsimulatorform.cpp @@ -0,0 +1,82 @@ +#include "metawatchdigitalsimulatorform.h" +#include "ui_metawatchdigitalsimulatorform.h" + +using namespace sowatch; + +MetaWatchDigitalSimulatorForm::MetaWatchDigitalSimulatorForm(QWidget* parent) : +    QWidget(parent), +    ui(new Ui::MetaWatchDigitalSimulatorForm) +{ +    ui->setupUi(this); +} + +MetaWatchDigitalSimulatorForm::~MetaWatchDigitalSimulatorForm() +{ +    delete ui; +} + +void MetaWatchDigitalSimulatorForm::refreshScreen(const QPixmap& pixmap) +{ +	ui->lblDisplay->setPixmap(pixmap); +	ui->lblDisplay->update(); +} + +void MetaWatchDigitalSimulatorForm::btnAPressed() +{ +	emit buttonPressed(0); +} + +void MetaWatchDigitalSimulatorForm::btnAReleased() +{ +	emit buttonReleased(0); +} + +void MetaWatchDigitalSimulatorForm::btnBPressed() +{ +	emit buttonPressed(1); +} + +void MetaWatchDigitalSimulatorForm::btnBReleased() +{ +	emit buttonReleased(1); +} + +void MetaWatchDigitalSimulatorForm::btnCPressed() +{ +	emit buttonPressed(2); +} + +void MetaWatchDigitalSimulatorForm::btnCReleased() +{ +	emit buttonReleased(2); +} + +void MetaWatchDigitalSimulatorForm::btnDPressed() +{ +	emit buttonPressed(3); +} + +void MetaWatchDigitalSimulatorForm::btnDReleased() +{ +	emit buttonReleased(3); +} + +void MetaWatchDigitalSimulatorForm::btnEPressed() +{ +	emit buttonPressed(4); +} + +void MetaWatchDigitalSimulatorForm::btnEReleased() +{ +	emit buttonReleased(4); +} + +void MetaWatchDigitalSimulatorForm::btnFPressed() +{ +	emit buttonPressed(5); +} + +void MetaWatchDigitalSimulatorForm::btnFReleased() +{ +	emit buttonReleased(5); +} diff --git a/metawatch/metawatchsimulatorform.h b/metawatch/metawatchdigitalsimulatorform.h index 0b45746..054a1a8 100644 --- a/metawatch/metawatchsimulatorform.h +++ b/metawatch/metawatchdigitalsimulatorform.h @@ -4,18 +4,18 @@  #include <QWidget>  namespace Ui { -	class MetaWatchSimulatorForm; +	class MetaWatchDigitalSimulatorForm;  }  namespace sowatch { -class MetaWatchSimulatorForm : public QWidget +class MetaWatchDigitalSimulatorForm : public QWidget  {      Q_OBJECT  public: -    explicit MetaWatchSimulatorForm(QWidget *parent = 0); -    ~MetaWatchSimulatorForm(); +    explicit MetaWatchDigitalSimulatorForm(QWidget *parent = 0); +    ~MetaWatchDigitalSimulatorForm();  	void refreshScreen(const QPixmap& screen); @@ -38,7 +38,7 @@ protected slots:  	void btnFReleased();  private: -    Ui::MetaWatchSimulatorForm *ui; +    Ui::MetaWatchDigitalSimulatorForm *ui;  };  } diff --git a/metawatch/metawatchsimulatorform.ui b/metawatch/metawatchdigitalsimulatorform.ui index 39280b3..239c342 100644 --- a/metawatch/metawatchsimulatorform.ui +++ b/metawatch/metawatchdigitalsimulatorform.ui @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="UTF-8"?>  <ui version="4.0"> - <class>MetaWatchSimulatorForm</class> - <widget class="QWidget" name="MetaWatchSimulatorForm"> + <class>MetaWatchDigitalSimulatorForm</class> + <widget class="QWidget" name="MetaWatchDigitalSimulatorForm">    <property name="geometry">     <rect>      <x>0</x> @@ -11,29 +11,47 @@     </rect>    </property>    <property name="windowTitle"> -   <string>MetaWatch-Digital Simulator</string> +   <string>MetaWatch Digital Simulator</string>    </property>    <layout class="QHBoxLayout" name="horizontalLayout">     <item>      <layout class="QVBoxLayout" name="btnsLeft">       <item> -      <widget class="QPushButton" name="btnA"> +      <widget class="QPushButton" name="btnF"> +       <property name="maximumSize"> +        <size> +         <width>50</width> +         <height>16777215</height> +        </size> +       </property>         <property name="text"> -        <string>A</string> +        <string>F</string>         </property>        </widget>       </item>       <item> -      <widget class="QPushButton" name="btnB"> +      <widget class="QPushButton" name="btnE"> +       <property name="maximumSize"> +        <size> +         <width>50</width> +         <height>16777215</height> +        </size> +       </property>         <property name="text"> -        <string>B</string> +        <string>E</string>         </property>        </widget>       </item>       <item> -      <widget class="QPushButton" name="btnC"> +      <widget class="QPushButton" name="btnD"> +       <property name="maximumSize"> +        <size> +         <width>50</width> +         <height>16777215</height> +        </size> +       </property>         <property name="text"> -        <string>C</string> +        <string>D</string>         </property>        </widget>       </item> @@ -58,23 +76,41 @@     <item>      <layout class="QVBoxLayout" name="btnsRight">       <item> -      <widget class="QPushButton" name="btnD"> +      <widget class="QPushButton" name="btnA"> +       <property name="maximumSize"> +        <size> +         <width>50</width> +         <height>16777215</height> +        </size> +       </property>         <property name="text"> -        <string>D</string> +        <string>A</string>         </property>        </widget>       </item>       <item> -      <widget class="QPushButton" name="btnE"> +      <widget class="QPushButton" name="btnB"> +       <property name="maximumSize"> +        <size> +         <width>50</width> +         <height>16777215</height> +        </size> +       </property>         <property name="text"> -        <string>E</string> +        <string>B</string>         </property>        </widget>       </item>       <item> -      <widget class="QPushButton" name="btnF"> +      <widget class="QPushButton" name="btnC"> +       <property name="maximumSize"> +        <size> +         <width>50</width> +         <height>16777215</height> +        </size> +       </property>         <property name="text"> -        <string>F</string> +        <string>C</string>         </property>        </widget>       </item> @@ -87,7 +123,7 @@    <connection>     <sender>btnA</sender>     <signal>pressed()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnAPressed()</slot>     <hints>      <hint type="sourcelabel"> @@ -103,7 +139,7 @@    <connection>     <sender>btnA</sender>     <signal>released()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnAReleased()</slot>     <hints>      <hint type="sourcelabel"> @@ -119,7 +155,7 @@    <connection>     <sender>btnB</sender>     <signal>pressed()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnBPressed()</slot>     <hints>      <hint type="sourcelabel"> @@ -135,7 +171,7 @@    <connection>     <sender>btnB</sender>     <signal>released()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnBReleased()</slot>     <hints>      <hint type="sourcelabel"> @@ -151,7 +187,7 @@    <connection>     <sender>btnC</sender>     <signal>pressed()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnCPressed()</slot>     <hints>      <hint type="sourcelabel"> @@ -167,7 +203,7 @@    <connection>     <sender>btnC</sender>     <signal>released()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnCReleased()</slot>     <hints>      <hint type="sourcelabel"> @@ -183,7 +219,7 @@    <connection>     <sender>btnD</sender>     <signal>pressed()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnDPressed()</slot>     <hints>      <hint type="sourcelabel"> @@ -199,7 +235,7 @@    <connection>     <sender>btnD</sender>     <signal>released()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnDReleased()</slot>     <hints>      <hint type="sourcelabel"> @@ -215,7 +251,7 @@    <connection>     <sender>btnE</sender>     <signal>pressed()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnEPressed()</slot>     <hints>      <hint type="sourcelabel"> @@ -231,7 +267,7 @@    <connection>     <sender>btnE</sender>     <signal>released()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnEReleased()</slot>     <hints>      <hint type="sourcelabel"> @@ -247,7 +283,7 @@    <connection>     <sender>btnF</sender>     <signal>pressed()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnFPressed()</slot>     <hints>      <hint type="sourcelabel"> @@ -263,7 +299,7 @@    <connection>     <sender>btnF</sender>     <signal>released()</signal> -   <receiver>MetaWatchSimulatorForm</receiver> +   <receiver>MetaWatchDigitalSimulatorForm</receiver>     <slot>btnFReleased()</slot>     <hints>      <hint type="sourcelabel"> diff --git a/metawatch/metawatchplugin.cpp b/metawatch/metawatchplugin.cpp index f73c127..0969ddf 100644 --- a/metawatch/metawatchplugin.cpp +++ b/metawatch/metawatchplugin.cpp @@ -1,8 +1,8 @@  #include <QtGui/QFontDatabase>  #include <QtConnectivity/QBluetoothAddress> -#include "metawatchdigital.h"  #include "metawatchanalog.h" -#include "metawatchsimulator.h" +#include "metawatchdigital.h" +#include "metawatchdigitalsimulator.h"  #include "metawatchscanner.h"  #include "metawatchplugin.h" @@ -30,7 +30,7 @@ MetaWatchPlugin::~MetaWatchPlugin()  QStringList MetaWatchPlugin::drivers()  {  	QStringList d; -	d << "metawatch-digital" << "metawatch-analog"; +	d << "metawatch-analog" << "metawatch-digital" << "metawatch-digital-simulator";  	return d;  } @@ -54,6 +54,8 @@ Watch* MetaWatchPlugin::getWatch(const QString& driver, ConfigKey* settings, QOb  		return new MetaWatchDigital(settings, parent);  	} else if (driver == "metawatch-analog") {  		return new MetaWatchAnalog(settings, parent); +	} else if (driver == "metawatch-digital-simulator") { +		return new MetaWatchDigitalSimulator(settings, parent);  	} else {  		return 0;  	} diff --git a/metawatch/metawatchsimulator.cpp b/metawatch/metawatchsimulator.cpp deleted file mode 100644 index 57a4f0c..0000000 --- a/metawatch/metawatchsimulator.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include <QtCore/QDebug> -#include <QtGui/QPainter> - -#include "metawatchsimulator.h" - -#define SIMULATE_DAMAGES 1 -#define SIMULATE_FRAMERATE 1 - -using namespace sowatch; - -MetaWatchSimulator::MetaWatchSimulator(QObject *parent) : -	WatchSimulator(parent), -	_image(96, 96, QImage::Format_Mono), -	_screen(96, 96), -	_form(new MetaWatchSimulatorForm), -	_nextFrame(QTime::currentTime()) -{ -	_form->showNormal(); -	connect(_form, SIGNAL(destroyed()), SIGNAL(disconnected())); -	connect(_form, SIGNAL(buttonPressed(int)), SIGNAL(buttonPressed(int))); -	connect(_form, SIGNAL(buttonReleased(int)), SIGNAL(buttonReleased(int))); -} - -MetaWatchSimulator::~MetaWatchSimulator() -{ -	delete _form; -} - -QString MetaWatchSimulator::model() const -{ -	return "metawatch-digital"; -} - -bool MetaWatchSimulator::isConnected() const -{ -	return true; -} - -bool MetaWatchSimulator::busy() const -{ -#if SIMULATE_FRAMERATE -	return _nextFrame > QTime::currentTime(); -#else -	return false; -#endif -} - -void MetaWatchSimulator::update(const QList<QRect> &rects) -{ -#if SIMULATE_DAMAGES -	const QRect imageRect = _image.rect(); -	QPainter p; -	QVector<bool> rows(96, false); -	unsigned total = 0, totalRows; - -	p.begin(&_screen); -	foreach (const QRect& rect, rects) { -		QRect r = rect.intersect(imageRect); -		for (int i = r.top(); i <= r.bottom(); i++) { -			rows[i] = true; -		} -		total += r.width() * r.height(); - -		p.drawImage(r, _image, r); -	} -	p.end(); - -	totalRows = rows.count(true); - -	_form->refreshScreen(_screen); - -	qDebug() << "updated " << total << " pixels " << totalRows << " lines"; -	_nextFrame = QTime::currentTime().addMSecs(((totalRows / 2) + 1) * 30); -#else -	_form->refreshScreen(QPixmap::fromImage(_image)); -	_nextFrame = QTime::currentTime().addMSecs(30); -#endif -} - -void MetaWatchSimulator::vibrate(bool on) -{ -	qDebug() << "vibrate" << on; -} diff --git a/metawatch/metawatchsimulator.h b/metawatch/metawatchsimulator.h deleted file mode 100644 index 38391d0..0000000 --- a/metawatch/metawatchsimulator.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef METAWATCHSIMULATOR_H -#define METAWATCHSIMULATOR_H - -#include <QtCore/QTime> -#include "watchsimulator.h" -#include "metawatchsimulatorform.h" - -namespace sowatch { - -class MetaWatchSimulator : public WatchSimulator -{ -    Q_OBJECT -public: -    explicit MetaWatchSimulator(QObject *parent = 0); -	~MetaWatchSimulator(); - -	QString model() const; -	bool isConnected() const; -	bool busy() const; - -	void update(const QList<QRect> &rects); -	void vibrate(bool on); - -protected: -	QImage _image; -	QPixmap _screen; -	MetaWatchSimulatorForm* _form; -	QTime _nextFrame; -}; - -} - -#endif // METAWATCHSIMULATOR_H diff --git a/metawatch/metawatchsimulatorform.cpp b/metawatch/metawatchsimulatorform.cpp deleted file mode 100644 index f2323bd..0000000 --- a/metawatch/metawatchsimulatorform.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "metawatchsimulatorform.h" -#include "ui_metawatchsimulatorform.h" - -using namespace sowatch; - -MetaWatchSimulatorForm::MetaWatchSimulatorForm(QWidget* parent) : -    QWidget(parent), -    ui(new Ui::MetaWatchSimulatorForm) -{ -    ui->setupUi(this); -} - -MetaWatchSimulatorForm::~MetaWatchSimulatorForm() -{ -    delete ui; -} - -void MetaWatchSimulatorForm::refreshScreen(const QPixmap& pixmap) -{ -	ui->lblDisplay->setPixmap(pixmap); -	ui->lblDisplay->update(); -} - -void MetaWatchSimulatorForm::btnAPressed() -{ -	emit buttonPressed(0); -} - -void MetaWatchSimulatorForm::btnAReleased() -{ -	emit buttonReleased(0); -} - -void MetaWatchSimulatorForm::btnBPressed() -{ -	emit buttonPressed(1); -} - -void MetaWatchSimulatorForm::btnBReleased() -{ -	emit buttonReleased(1); -} - -void MetaWatchSimulatorForm::btnCPressed() -{ -	emit buttonPressed(2); -} - -void MetaWatchSimulatorForm::btnCReleased() -{ -	emit buttonReleased(2); -} - -void MetaWatchSimulatorForm::btnDPressed() -{ -	emit buttonPressed(3); -} - -void MetaWatchSimulatorForm::btnDReleased() -{ -	emit buttonReleased(3); -} - -void MetaWatchSimulatorForm::btnEPressed() -{ -	emit buttonPressed(4); -} - -void MetaWatchSimulatorForm::btnEReleased() -{ -	emit buttonReleased(4); -} - -void MetaWatchSimulatorForm::btnFPressed() -{ -	emit buttonPressed(5); -} - -void MetaWatchSimulatorForm::btnFReleased() -{ -	emit buttonReleased(5); -} diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml index d1fe507..3ce64ca 100644 --- a/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml @@ -2,5 +2,5 @@ import Qt 4.7  Text {  	font.family: "MetaWatch Large 16pt" -	font.pixelSize: 16 +	font.pointSize: 10.5  } diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml index b6764b7..37b9093 100644 --- a/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml @@ -4,10 +4,13 @@ ListView {  	id: list  	property bool selectable: true +	property bool indicator: true  	interactive: false  	highlightFollowsCurrentItem: false +	keyNavigationWraps: false  	boundsBehavior: Flickable.StopAtBounds +	flickableDirection: Flickable.VerticalFlick  	property real currentItemTop: currentItem !== null ? currentItem.y - contentY : 0  	property real currentItemBottom: currentItem !== null ? currentItemTop + currentItem.height : 0 @@ -44,8 +47,12 @@ ListView {  				return;  			}  			if (currentIndex >= 0 && currentItemTop > 0) { +				var prevContentY = contentY;  				// If the previous item is visible, highlight it  				decrementCurrentIndex(); +				// ListView will "smoothtly scroll the list" even if hightlightFollowsCurrentItem is false, +				// so we have to add the following ugly workaround: +				contentY = prevContentY;  			}  			if (currentItemTop <= 0) {  				// If the previous item now is still not visible, scroll @@ -59,4 +66,30 @@ ListView {  			}  		}  	} + +	Rectangle { +		id: indicatorContainer +		visible: list.indicator && (list.contentHeight > list.height) +		anchors.top: parent.top +		anchors.right: parent.right +		anchors.bottom: parent.bottom +		width: 4 + +		color: "white" + +		Rectangle { +			id: indicatorRect + +			property int minHeight: 10 + +			anchors.right: parent.right +			anchors.left: parent.left +			anchors.leftMargin: 1 + +			y: (list.contentY / list.contentHeight) * indicatorContainer.height +			height: Math.max(minHeight, (list.height / list.contentHeight) * indicatorContainer.height) + +			color: "black" +		} +	}  } diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWSmallLabel.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWSmallLabel.qml deleted file mode 100644 index d26e058..0000000 --- a/metawatch/qml/com/javispedro/sowatch/metawatch/MWSmallLabel.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt 4.7 - -Text { -	font.family: "MetaWatch Large caps 8pt" -	font.pixelSize: 8 -} diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml index 017d6a1..b87d535 100644 --- a/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml @@ -5,6 +5,7 @@ Rectangle {  	height: 16  	property alias text: label.text +	property alias font: label.font  	property alias icon: image  	Image { @@ -18,5 +19,6 @@ Rectangle {  		anchors.left: image.right  		anchors.leftMargin: 2  		anchors.verticalCenter: parent.verticalCenter +		font.pointSize: 12  	}  } diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir index c6b0714..10ca498 100644 --- a/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir @@ -1,5 +1,4 @@  MWPage 1.0 MWPage.qml  MWLabel 1.0 MWLabel.qml -MWSmallLabel 1.0 MWSmallLabel.qml  MWTitle 1.0 MWTitle.qml  MWListView 1.0 MWListView.qml | 
