diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2012-04-26 01:36:20 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2012-04-26 01:36:20 +0200 |
commit | 93f3acd128d6b349efe14e97b12c2703ca4f81f3 (patch) | |
tree | 937f3de2307444f0c28d6d21f26f1580e789b074 /metawatch/metawatch.cpp | |
parent | 1375a26b135547fdd8e07db62acf8116a8482560 (diff) | |
download | sowatch-93f3acd128d6b349efe14e97b12c2703ca4f81f3.tar.gz sowatch-93f3acd128d6b349efe14e97b12c2703ca4f81f3.zip |
Moved the core framework to GConf & D-Bus
Diffstat (limited to 'metawatch/metawatch.cpp')
-rw-r--r-- | metawatch/metawatch.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp index a9718ec..fe080e4 100644 --- a/metawatch/metawatch.cpp +++ b/metawatch/metawatch.cpp @@ -78,8 +78,9 @@ const quint16 MetaWatch::crcTable[256] = { } #endif -MetaWatch::MetaWatch(const QBluetoothAddress& address, QSettings* settings, QObject* parent) : - Watch(parent), +MetaWatch::MetaWatch(ConfigKey* settings, QObject* parent) : + Watch(parent), + _settings(settings->getSubkey(QString(), this)), _idleTimer(new QTimer(this)), _ringTimer(new QTimer(this)), _watchTime(), _watchBattery(0), _watchBatteryAverage(0), _watchCharging(false), _currentMode(IdleMode), _paintMode(IdleMode), @@ -87,14 +88,15 @@ MetaWatch::MetaWatch(const QBluetoothAddress& address, QSettings* settings, QObj _connectRetries(0), _connected(false), _connectTimer(new QTimer(this)), _connectAlignedTimer(new QSystemAlignedTimer(this)), - _address(address), _socket(0), + _socket(0), _sendTimer(new QTimer(this)) { - if (settings) { - _notificationTimeout = settings->value("NotificationTimeout", 15).toInt(); - _24hMode = settings->value("24hMode", false).toBool(); - _dayMonthOrder = settings->value("DayMonthOrder", false).toBool(); - } + connect(_settings, SIGNAL(subkeyChanged(QString)), SLOT(settingChanged(QString))); + + _address = QBluetoothAddress(settings->value("address").toString()); + _notificationTimeout = settings->value("notification-timeout", 15).toInt(); + _24hMode = settings->value("24h-mode", false).toBool(); + _dayMonthOrder = settings->value("day-month-order", false).toBool(); _buttonNames << "A" << "B" << "C" << "D" << "E" << "F"; @@ -656,6 +658,27 @@ void MetaWatch::handleBatteryVoltageMessage(const Message &msg) emit batteryLevelChanged(); } +void MetaWatch::settingChanged(const QString &key) +{ + qDebug() << "Metawatch setting changed:" << key; + + if (key == "address") { + _address = QBluetoothAddress(_settings->value(key).toString()); + } else if (key == "notification-timeout") { + _notificationTimeout = _settings->value(key, 15).toInt(); + } else if (key == "day-month-order") { + _dayMonthOrder = _settings->value(key, false).toBool(); + if (isConnected()) { + nvalWrite(DateFormat, _dayMonthOrder ? 1 : 0); + } + } else if (key == "24h-mode") { + _24hMode = _settings->value(key, false).toBool(); + if (isConnected()) { + nvalWrite(TimeFormat, _24hMode ? 1 : 0); + } + } +} + void MetaWatch::socketConnected() { if (!_connected) { |