summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsowatch/weathernotification.cpp2
-rw-r--r--metawatch/metawatch.cpp1
-rw-r--r--metawatch/metawatch.h3
-rw-r--r--metawatch/metawatchdigitalsimulator.cpp14
-rw-r--r--metawatch/metawatchdigitalsimulator.h3
-rw-r--r--metawatch/metawatchdigitalsimulatorform.cpp23
-rw-r--r--metawatch/metawatchdigitalsimulatorform.h10
-rw-r--r--metawatch/metawatchdigitalsimulatorform.ui250
-rw-r--r--sowatchd/global.h11
-rw-r--r--sowatchd/main.cpp17
-rw-r--r--sowatchd/sowatchd.pro2
11 files changed, 203 insertions, 133 deletions
diff --git a/libsowatch/weathernotification.cpp b/libsowatch/weathernotification.cpp
index ddfd60b..6d693b2 100644
--- a/libsowatch/weathernotification.cpp
+++ b/libsowatch/weathernotification.cpp
@@ -15,6 +15,8 @@ qreal WeatherNotification::convertTemperature(qreal temp, Unit from, Unit to)
return temp * (9.0f/5.0f) + 32.0f;
} else if (from == Fahrenheit && to == Celsius) {
return (temp - 32.0f) * (5.0f/9.0f);
+ } else {
+ return 0.0f;
}
}
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp
index a4692e5..d02e726 100644
--- a/metawatch/metawatch.cpp
+++ b/metawatch/metawatch.cpp
@@ -368,6 +368,7 @@ uint MetaWatch::nvalSize(NvalValue value)
return 1;
case TimeFormat:
case DateFormat:
+ case DisplaySeconds:
return 1;
}
return 0;
diff --git a/metawatch/metawatch.h b/metawatch/metawatch.h
index 9e62960..8946884 100644
--- a/metawatch/metawatch.h
+++ b/metawatch/metawatch.h
@@ -74,8 +74,7 @@ public:
IdleBufferConfiguration = 0x2,
TimeFormat = 0x2009,
DateFormat = 0x200a,
- DisplaySeconds = 0x200b,
- Language = 0x200c
+ DisplaySeconds = 0x200b
};
enum Mode {
diff --git a/metawatch/metawatchdigitalsimulator.cpp b/metawatch/metawatchdigitalsimulator.cpp
index 5c399bd..e5cd74b 100644
--- a/metawatch/metawatchdigitalsimulator.cpp
+++ b/metawatch/metawatchdigitalsimulator.cpp
@@ -19,10 +19,12 @@ MetaWatchDigitalSimulator::MetaWatchDigitalSimulator(ConfigKey *config, QObject
_form->showNormal();
connect(_form, SIGNAL(buttonPressed(int)), SIGNAL(buttonPressed(int)));
connect(_form, SIGNAL(buttonReleased(int)), SIGNAL(buttonReleased(int)));
+ connect(_form, SIGNAL(destroyed()), SLOT(handleFormDestroyed()));
}
MetaWatchDigitalSimulator::~MetaWatchDigitalSimulator()
{
+ _connected = false;
delete _form;
}
@@ -101,7 +103,7 @@ void MetaWatchDigitalSimulator::vibrate(bool on)
void MetaWatchDigitalSimulator::retryConnect()
{
if (!_connected && _form) {
- qDebug() << "connected";
+ qDebug() << "simulator connected";
_connected = true;
_currentMode = IdleMode;
@@ -118,3 +120,13 @@ void MetaWatchDigitalSimulator::send(const Message &msg)
// Do not send messages
Q_UNUSED(msg);
}
+
+void MetaWatchDigitalSimulator::handleFormDestroyed()
+{
+ if (_connected) {
+ _connected = false;
+ qDebug() << "simulator disconnected";
+ emit disconnected();
+ _form = 0;
+ }
+}
diff --git a/metawatch/metawatchdigitalsimulator.h b/metawatch/metawatchdigitalsimulator.h
index 6f5c130..de2efdd 100644
--- a/metawatch/metawatchdigitalsimulator.h
+++ b/metawatch/metawatchdigitalsimulator.h
@@ -29,6 +29,9 @@ public:
void retryConnect();
void send(const Message& msg);
+private slots:
+ void handleFormDestroyed();
+
private:
MetaWatchDigitalSimulatorForm* _form;
QPixmap _pixmap[3];
diff --git a/metawatch/metawatchdigitalsimulatorform.cpp b/metawatch/metawatchdigitalsimulatorform.cpp
index fc3c890..04d6482 100644
--- a/metawatch/metawatchdigitalsimulatorform.cpp
+++ b/metawatch/metawatchdigitalsimulatorform.cpp
@@ -1,10 +1,13 @@
+#include <QtCore/QDebug>
+#include <QtGui/QFileDialog>
+
#include "metawatchdigitalsimulatorform.h"
#include "ui_metawatchdigitalsimulatorform.h"
using namespace sowatch;
MetaWatchDigitalSimulatorForm::MetaWatchDigitalSimulatorForm(QWidget* parent) :
- QWidget(parent),
+ QMainWindow(parent),
ui(new Ui::MetaWatchDigitalSimulatorForm)
{
ui->setupUi(this);
@@ -80,3 +83,21 @@ void MetaWatchDigitalSimulatorForm::btnFReleased()
{
emit buttonReleased(5);
}
+
+void MetaWatchDigitalSimulatorForm::on_actionCaptureScreen_triggered()
+{
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Save capture"), QString(), tr("Images (*.png)"));
+ if (fileName.isEmpty()) {
+ return;
+ }
+ if (!fileName.endsWith(".png")) {
+ fileName.append(".png");
+ }
+ qDebug() << "Saving to" << fileName;
+ ui->lblDisplay->pixmap()->save(fileName, "PNG");
+}
+
+void MetaWatchDigitalSimulatorForm::on_actionQuit_triggered()
+{
+ QApplication::quit();
+}
diff --git a/metawatch/metawatchdigitalsimulatorform.h b/metawatch/metawatchdigitalsimulatorform.h
index 054a1a8..07f26ea 100644
--- a/metawatch/metawatchdigitalsimulatorform.h
+++ b/metawatch/metawatchdigitalsimulatorform.h
@@ -1,7 +1,7 @@
#ifndef METAWATCHSIMULATORFORM_H
#define METAWATCHSIMULATORFORM_H
-#include <QWidget>
+#include <QtGui/QMainWindow>
namespace Ui {
class MetaWatchDigitalSimulatorForm;
@@ -9,7 +9,7 @@ namespace Ui {
namespace sowatch {
-class MetaWatchDigitalSimulatorForm : public QWidget
+class MetaWatchDigitalSimulatorForm : public QMainWindow
{
Q_OBJECT
@@ -23,7 +23,7 @@ signals:
void buttonPressed(int button);
void buttonReleased(int button);
-protected slots:
+private slots:
void btnAPressed();
void btnAReleased();
void btnBPressed();
@@ -37,6 +37,10 @@ protected slots:
void btnFPressed();
void btnFReleased();
+ void on_actionCaptureScreen_triggered();
+
+ void on_actionQuit_triggered();
+
private:
Ui::MetaWatchDigitalSimulatorForm *ui;
};
diff --git a/metawatch/metawatchdigitalsimulatorform.ui b/metawatch/metawatchdigitalsimulatorform.ui
index 239c342..b1575aa 100644
--- a/metawatch/metawatchdigitalsimulatorform.ui
+++ b/metawatch/metawatchdigitalsimulatorform.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MetaWatchDigitalSimulatorForm</class>
- <widget class="QWidget" name="MetaWatchDigitalSimulatorForm">
+ <widget class="QMainWindow" name="MetaWatchDigitalSimulatorForm">
<property name="geometry">
<rect>
<x>0</x>
@@ -13,110 +13,150 @@
<property name="windowTitle">
<string>MetaWatch Digital Simulator</string>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <layout class="QVBoxLayout" name="btnsLeft">
- <item>
- <widget class="QPushButton" name="btnF">
- <property name="maximumSize">
- <size>
- <width>50</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>F</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnE">
- <property name="maximumSize">
- <size>
- <width>50</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>E</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnD">
- <property name="maximumSize">
- <size>
- <width>50</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>D</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QLabel" name="lblDisplay">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="btnsRight">
- <item>
- <widget class="QPushButton" name="btnA">
- <property name="maximumSize">
- <size>
- <width>50</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>A</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnB">
- <property name="maximumSize">
- <size>
- <width>50</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>B</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnC">
- <property name="maximumSize">
- <size>
- <width>50</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>C</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
+ <widget class="QWidget" name="watch">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="btnsLeft">
+ <item>
+ <widget class="QPushButton" name="btnF">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>F</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnE">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>E</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnD">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>D</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="lblDisplay">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="btnsRight">
+ <item>
+ <widget class="QPushButton" name="btnA">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>A</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnB">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>B</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnC">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>C</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>262</width>
+ <height>23</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuWatch">
+ <property name="title">
+ <string>&amp;Watch</string>
+ </property>
+ <addaction name="actionCaptureScreen"/>
+ <addaction name="separator"/>
+ <addaction name="actionQuit"/>
+ </widget>
+ <addaction name="menuWatch"/>
+ </widget>
+ <action name="actionCaptureScreen">
+ <property name="text">
+ <string>&amp;Capture screen...</string>
+ </property>
+ <property name="toolTip">
+ <string>Capture the current watch screen</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+C</string>
+ </property>
+ </action>
+ <action name="actionQuit">
+ <property name="text">
+ <string>&amp;Quit</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Q</string>
+ </property>
+ </action>
</widget>
<resources/>
<connections>
diff --git a/sowatchd/global.h b/sowatchd/global.h
deleted file mode 100644
index 45c2b13..0000000
--- a/sowatchd/global.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef GLOBAL_H
-#define GLOBAL_H
-
-#include "daemon.h"
-
-namespace sowatch
-{
-extern sowatch::Daemon* daemon;
-}
-
-#endif // GLOBAL_H
diff --git a/sowatchd/main.cpp b/sowatchd/main.cpp
index 1fd1789..6bd502b 100644
--- a/sowatchd/main.cpp
+++ b/sowatchd/main.cpp
@@ -4,14 +4,9 @@
#include <QtDBus/QDBusConnection>
#include <sowatch.h>
-#include "global.h"
+#include "daemon.h"
#include "daemonadaptor.h"
-namespace sowatch
-{
- Daemon* daemon;
-}
-
using namespace sowatch;
static void setupLocalization(QApplication *app)
@@ -48,16 +43,20 @@ int main(int argc, char *argv[])
QApplication::setApplicationName("sowatchd");
QApplication::setQuitOnLastWindowClosed(false);
+ // Load translators
setupLocalization(&app);
- sowatch::daemon = new Daemon(&app);
- new DaemonAdaptor(sowatch::daemon);
+ // Create the daemon object and D-Bus adaptor
+ Daemon daemon;
+ DaemonAdaptor adaptor(&daemon);
+
+ Q_UNUSED(adaptor);
QDBusConnection connection = QDBusConnection::sessionBus();
if (!connection.registerService("com.javispedro.sowatchd")) {
qCritical("Could not register D-Bus service");
}
- if (!connection.registerObject("/com/javispedro/sowatch/daemon", sowatch::daemon)) {
+ if (!connection.registerObject("/com/javispedro/sowatch/daemon", &daemon)) {
qCritical("Could not register daemon object");
}
diff --git a/sowatchd/sowatchd.pro b/sowatchd/sowatchd.pro
index f44acdc..17176fb 100644
--- a/sowatchd/sowatchd.pro
+++ b/sowatchd/sowatchd.pro
@@ -6,7 +6,7 @@ QT += core gui dbus
CONFIG -= app_bundle
SOURCES += main.cpp daemon.cpp daemonadaptor.cpp watchhandler.cpp
-HEADERS += global.h daemon.h daemonadaptor.h watchhandler.h
+HEADERS += daemon.h daemonadaptor.h watchhandler.h
LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch
INCLUDEPATH += $$PWD/../libsowatch