diff options
Diffstat (limited to 'metawatch')
18 files changed, 107 insertions, 97 deletions
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp index b5aec49..3845817 100644 --- a/metawatch/metawatch.cpp +++ b/metawatch/metawatch.cpp @@ -269,8 +269,12 @@ void MetaWatch::setupBluetoothWatch() _currentMode = IdleMode; _paintMode = IdleMode; - connect(_socket, SIGNAL(readyRead()), + if (_socket) { + // If we are running under the simulator, there might not be + // a socket. + connect(_socket, SIGNAL(readyRead()), SLOT(dataReceived())); + } // Configure the watch according to user preferences updateWatchProperties(); @@ -468,9 +472,6 @@ void MetaWatch::enableButton(Mode mode, Button button, ButtonPress press) // the pressed button and the event code were. msg.data[4] = 0x80 | ((press << 4) & 0x30) | (button & 0xF); - qDebug() << "enable button" << button << "(" << press << ")" << - "in mode" << mode << "to" << static_cast<unsigned char>(msg.data[4]); - send(msg); } diff --git a/metawatch/metawatchdigital.cpp b/metawatch/metawatchdigital.cpp index e3f8431..0d2a3cf 100644 --- a/metawatch/metawatchdigital.cpp +++ b/metawatch/metawatchdigital.cpp @@ -3,9 +3,7 @@ using namespace sowatch; MetaWatchDigital::MetaWatchDigital(ConfigKey* settings, QObject *parent) : - MetaWatch(settings, parent), - _nMails(0), _nCalls(0), _nIms(0), _nSms(0), _nMms(0), - _wForecast(WeatherNotification::UnknownWeather) + MetaWatch(settings, parent) { QImage baseImage(screenWidth, screenHeight, QImage::Format_MonoLSB); baseImage.setColor(0, QColor(Qt::white).rgb()); @@ -67,6 +65,12 @@ void MetaWatchDigital::displayApplication() MetaWatch::displayApplication(); } +void MetaWatchDigital::clear(Mode mode, bool black) +{ + if (!_connected) return; + loadLcdTemplate(mode, black ? 1 : 0); +} + void MetaWatchDigital::update(Mode mode, const QList<QRect> &rects) { if (!_connected) return; @@ -86,20 +90,32 @@ void MetaWatchDigital::update(Mode mode, const QList<QRect> &rects) } } -void MetaWatchDigital::clear(Mode mode, bool black) -{ - if (!_connected) return; - loadLcdTemplate(mode, black ? 1 : 0); -} - -void MetaWatchDigital::renderIdleScreen() +#if 0 +QUrl MetaWatchDigital::iconForNotification(const Notification *n) { - + switch (n->type()) { + case Notification::CallNotification: + case Notification::MissedCallNotification: + return QUrl::fromLocalFile(SOWATCH_RESOURCES_DIR "/metawatch/graphics/phone.png"); + break; + case Notification::SmsNotification: + case Notification::MmsNotification: + case Notification::ImNotification: + return QUrl::fromLocalFile(SOWATCH_RESOURCES_DIR "/metawatch/graphics/message.png"); + break; + case Notification::EmailNotification: + return QUrl::fromLocalFile(SOWATCH_RESOURCES_DIR "/metawatch/graphics/email.bmp"); + break; + case Notification::CalendarNotification: + return QUrl::fromLocalFile(SOWATCH_RESOURCES_DIR "/metawatch/graphics/timer.bmp"); + break; + default: + return QUrl(); + } } void MetaWatchDigital::renderIdleWeather() { -#if 0 _paintMode = IdleMode; QFont sf("MetaWatch Small caps 8pt"); QFont lf("MetaWatch Large 16pt"); @@ -128,7 +144,6 @@ void MetaWatchDigital::renderIdleWeather() } _paintMode = _currentMode; -#endif } QImage MetaWatchDigital::iconForWeather(WeatherNotification::WeatherType w) @@ -151,67 +166,6 @@ QImage MetaWatchDigital::iconForWeather(WeatherNotification::WeatherType w) } } -void MetaWatchDigital::renderNotification(Notification *n) -{ - _paintMode = NotificationMode; - QPainter p; - QFont sf("MetaWatch Small caps 8pt"); - QFont lf("MetaWatch Large 16pt"); - QFont mf("MetaWatch Large 16pt"); - QImage icon = iconForNotification(n); - - sf.setPixelSize(8); - mf.setPixelSize(14); - lf.setPixelSize(16); - - const int iconW = icon.width(), iconH = icon.height(); - const int margin = 4; - const int x = margin; - const int iconY = margin; - const int titleY = margin*2 + iconH; - const int dateX = x + iconW + margin; - QTextOption option; - QRect rect, titleRect; - QString text; - - p.begin(this); - - p.fillRect(0, 0, screenWidth, screenHeight, Qt::white); - p.drawImage(x, iconY, icon); - - p.setPen(Qt::black); - option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); - option.setAlignment(Qt::AlignRight | Qt::AlignVCenter); - - // Render "N minutes ago" - p.setFont(sf); - rect.setRect(dateX, iconY, (screenWidth - dateX) - margin, iconH); - text = n->displayTime(); - p.drawText(rect, text, option); - - option.setAlignment(Qt::AlignLeft | Qt::AlignTop); - - // Render title - p.setFont(lf); - rect.setRect(x, titleY, screenWidth - x*2, screenHeight - titleY); - text = n->title(); - titleRect = p.boundingRect(rect, text, option).toRect(); - p.drawText(rect, text, option); - - // Do not try to draw body if title was large - int bodyY = titleRect.y() + titleRect.height(); - if (bodyY >= screenHeight) return; - - // Render body - p.setFont(mf); - rect.setRect(x, bodyY, screenWidth - x*2, screenHeight - bodyY); - text = n->body(); - p.drawText(rect, text, option); - - p.end(); - _paintMode = _currentMode; -} - QImage MetaWatchDigital::iconForNotification(const Notification *n) { switch (n->type()) { @@ -234,6 +188,7 @@ QImage MetaWatchDigital::iconForNotification(const Notification *n) return QImage(); } } +#endif void MetaWatchDigital::setupBluetoothWatch() { @@ -256,7 +211,4 @@ void MetaWatchDigital::setupBluetoothWatch() // Configure to show watch-rendered clock in idle screen configureLcdIdleSystemArea(false); - - // Render the idle screen assuming previous contents were lost - renderIdleScreen(); } diff --git a/metawatch/metawatchdigital.h b/metawatch/metawatchdigital.h index 1e1a62b..8baed46 100644 --- a/metawatch/metawatchdigital.h +++ b/metawatch/metawatchdigital.h @@ -29,22 +29,6 @@ public: protected: void setupBluetoothWatch(); - -private: - // Idle screen: notifications unread count - ushort _nMails, _nCalls, _nIms, _nSms, _nMms; - // Idle screen: weather information - WeatherNotification::WeatherType _wForecast; - QString _wBody; - short _wTemperature; - bool _wMetric; - - void renderIdleScreen(); - void renderIdleWeather(); - QImage iconForWeather(WeatherNotification::WeatherType w); - - void renderNotification(Notification *n); - QImage iconForNotification(const Notification *n); }; } diff --git a/metawatch/metawatchdigitalsimulator.cpp b/metawatch/metawatchdigitalsimulator.cpp index f808515..41b924a 100644 --- a/metawatch/metawatchdigitalsimulator.cpp +++ b/metawatch/metawatchdigitalsimulator.cpp @@ -20,6 +20,7 @@ MetaWatchDigitalSimulator::MetaWatchDigitalSimulator(ConfigKey *config, QObject // Connect form signals connect(_form, SIGNAL(buttonPressed(int)), SIGNAL(buttonPressed(int))); connect(_form, SIGNAL(buttonReleased(int)), SIGNAL(buttonReleased(int))); + connect(_form, SIGNAL(buttonPressed(int)), SLOT(handleButtonPressed(int))); connect(_form, SIGNAL(destroyed()), SLOT(handleFormDestroyed())); // Show the form @@ -146,3 +147,10 @@ void MetaWatchDigitalSimulator::handleFormDestroyed() _form = 0; } } + +void MetaWatchDigitalSimulator::handleButtonPressed(int button) +{ + if (button == BtnA) { + emit nextWatchletRequested(); + } +} diff --git a/metawatch/metawatchdigitalsimulator.h b/metawatch/metawatchdigitalsimulator.h index 8b424ec..d9d1295 100644 --- a/metawatch/metawatchdigitalsimulator.h +++ b/metawatch/metawatchdigitalsimulator.h @@ -31,6 +31,7 @@ public: private slots: void handleFormDestroyed(); + void handleButtonPressed(int button); private: MetaWatchDigitalSimulatorForm* _form; diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml new file mode 100644 index 0000000..65952c1 --- /dev/null +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWScrollable.qml @@ -0,0 +1,63 @@ +import Qt 4.7 + +Flickable { + id: flickable + + property bool selectable: true + property bool indicator: true + + interactive: false + boundsBehavior: Flickable.StopAtBounds + flickableDirection: Flickable.VerticalFlick + + function scrollDown() { + var maxY = contentHeight - height; + var newContentY = contentY + 96/3; + + if (newContentY > maxY) { + contentY = maxY; // Never overscroll. + } else { + contentY = newContentY; + } + } + + function scrollUp() { + var newContentY = contentY - 96/3; + + if (newContentY < 0) { + contentY = 0; // Never overscroll. + } else { + contentY = newContentY; + } + } + + function scrollTop() { + contentY = 0; + } + + Rectangle { + id: indicatorCont + visible: flickable.indicator && (flickable.contentHeight > flickable.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: flickable.visibleArea.yPosition * indicatorCont.height + height: Math.max(minHeight, flickable.visibleArea.heightRatio * indicatorCont.height) + + color: "black" + } + } +} diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir index 10ca498..aff7045 100644 --- a/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir @@ -2,3 +2,4 @@ MWPage 1.0 MWPage.qml MWLabel 1.0 MWLabel.qml MWTitle 1.0 MWTitle.qml MWListView 1.0 MWListView.qml +MWScrollable 1.0 MWScrollable.qml diff --git a/metawatch/res/graphics/email.bmp b/metawatch/res/graphics/email.bmp Binary files differdeleted file mode 100644 index 7c895af..0000000 --- a/metawatch/res/graphics/email.bmp +++ /dev/null diff --git a/metawatch/res/graphics/message.bmp b/metawatch/res/graphics/message.bmp Binary files differdeleted file mode 100644 index 53605b8..0000000 --- a/metawatch/res/graphics/message.bmp +++ /dev/null diff --git a/metawatch/res/graphics/phone.bmp b/metawatch/res/graphics/phone.bmp Binary files differdeleted file mode 100644 index a9da9d8..0000000 --- a/metawatch/res/graphics/phone.bmp +++ /dev/null diff --git a/metawatch/res/graphics/play.bmp b/metawatch/res/graphics/play.bmp Binary files differdeleted file mode 100644 index f6f507c..0000000 --- a/metawatch/res/graphics/play.bmp +++ /dev/null diff --git a/metawatch/res/graphics/timer.bmp b/metawatch/res/graphics/timer.bmp Binary files differdeleted file mode 100644 index 20ae04d..0000000 --- a/metawatch/res/graphics/timer.bmp +++ /dev/null diff --git a/metawatch/res/graphics/weather_cloudy.bmp b/metawatch/res/graphics/weather_cloudy.bmp Binary files differdeleted file mode 100644 index 506c24a..0000000 --- a/metawatch/res/graphics/weather_cloudy.bmp +++ /dev/null diff --git a/metawatch/res/graphics/weather_rain.bmp b/metawatch/res/graphics/weather_rain.bmp Binary files differdeleted file mode 100644 index fc12c6e..0000000 --- a/metawatch/res/graphics/weather_rain.bmp +++ /dev/null diff --git a/metawatch/res/graphics/weather_snow.bmp b/metawatch/res/graphics/weather_snow.bmp Binary files differdeleted file mode 100644 index d328105..0000000 --- a/metawatch/res/graphics/weather_snow.bmp +++ /dev/null diff --git a/metawatch/res/graphics/weather_sunny.bmp b/metawatch/res/graphics/weather_sunny.bmp Binary files differdeleted file mode 100644 index df9f774..0000000 --- a/metawatch/res/graphics/weather_sunny.bmp +++ /dev/null diff --git a/metawatch/res/graphics/weather_thunderstorm.bmp b/metawatch/res/graphics/weather_thunderstorm.bmp Binary files differdeleted file mode 100644 index f101610..0000000 --- a/metawatch/res/graphics/weather_thunderstorm.bmp +++ /dev/null diff --git a/metawatch/res/graphics/weather_wind.bmp b/metawatch/res/graphics/weather_wind.bmp Binary files differdeleted file mode 100644 index 59bd81b..0000000 --- a/metawatch/res/graphics/weather_wind.bmp +++ /dev/null |