From 2f631362b54180252d0daa34f359338860a8782b Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sun, 2 Sep 2012 20:53:05 +0200 Subject: fixing a few warnings --- metawatch/metawatch.cpp | 1 + metawatch/metawatch.h | 3 +- metawatch/metawatchdigitalsimulator.cpp | 14 +- metawatch/metawatchdigitalsimulator.h | 3 + metawatch/metawatchdigitalsimulatorform.cpp | 23 ++- metawatch/metawatchdigitalsimulatorform.h | 10 +- metawatch/metawatchdigitalsimulatorform.ui | 250 ++++++++++++++++------------ 7 files changed, 192 insertions(+), 112 deletions(-) (limited to 'metawatch') 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 +#include + #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 +#include 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 @@ MetaWatchDigitalSimulatorForm - + 0 @@ -13,110 +13,150 @@ MetaWatch Digital Simulator - - - - - - - - 50 - 16777215 - - - - F - - - - - - - - 50 - 16777215 - - - - E - - - - - - - - 50 - 16777215 - - - - D - - - - - - - - - - 0 - 0 - - - - - - - Qt::AlignCenter - - - - - - - - - - 50 - 16777215 - - - - A - - - - - - - - 50 - 16777215 - - - - B - - - - - - - - 50 - 16777215 - - - - C - - - - - - + + + + + + + + + 50 + 16777215 + + + + F + + + + + + + + 50 + 16777215 + + + + E + + + + + + + + 50 + 16777215 + + + + D + + + + + + + + + + 0 + 0 + + + + + + + Qt::AlignCenter + + + + + + + + + + 50 + 16777215 + + + + A + + + + + + + + 50 + 16777215 + + + + B + + + + + + + + 50 + 16777215 + + + + C + + + + + + + + + + + 0 + 0 + 262 + 23 + + + + + &Watch + + + + + + + + + + &Capture screen... + + + Capture the current watch screen + + + Ctrl+C + + + + + &Quit + + + Ctrl+Q + + -- cgit v1.2.3