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 --- libsowatch/weathernotification.cpp | 2 + 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 ++++++++++++++++------------ sowatchd/global.h | 11 -- sowatchd/main.cpp | 17 +- sowatchd/sowatchd.pro | 2 +- 11 files changed, 203 insertions(+), 133 deletions(-) delete mode 100644 sowatchd/global.h 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 +#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 + + 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 #include -#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 -- cgit v1.2.3