diff --git a/src/nemowallclock.cpp b/src/nemowallclock.cpp index 747f48f..df4fb6e 100644 --- a/src/nemowallclock.cpp +++ b/src/nemowallclock.cpp @@ -39,7 +39,7 @@ extern WallClockPrivate *nemoCreateWallClockPrivate(WallClock *wc); WallClockPrivate::WallClockPrivate(WallClock *wallClock) - : q(wallClock), m_updateFreq(WallClock::Second), m_enabled(true) + : q(wallClock), m_updateFreq(WallClock::Second), m_enabled(true), m_suspended(false) { setLoopCount(-1); update(); @@ -71,6 +71,17 @@ void WallClockPrivate::setEnabled(bool e) emit q->timeChanged(); } +void WallClockPrivate::setSuspended(bool s) +{ + if (m_suspended == s) + return; + + m_suspended = s; + update(); + if (m_enabled && !m_suspended) + emit q->timeChanged(); +} + QDateTime WallClockPrivate::time() const { return QDateTime::currentDateTime(); @@ -87,7 +98,7 @@ QString WallClockPrivate::timezoneAbbreviation() const } void WallClockPrivate::update() { - if (m_enabled) { + if (m_enabled && !m_suspended) { QTime current = QTime::currentTime(); int initDelay = 0; switch (m_updateFreq) { diff --git a/src/nemowallclock_meego.cpp b/src/nemowallclock_meego.cpp index ad35761..c37a53c 100644 --- a/src/nemowallclock_meego.cpp +++ b/src/nemowallclock_meego.cpp @@ -78,6 +78,13 @@ WallClockPrivateMeego::WallClockPrivateMeego(WallClock *wc) this, SLOT(onDisplayStatusChanged(QString)))) qWarning() << "Can't connect to mce"; + + QDBusReply reply = QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE, + MCE_REQUEST_PATH, + MCE_REQUEST_IF, + MCE_DISPLAY_STATUS_GET)); + if (reply.isValid()) + onDisplayStatusChanged(reply.value()); } WallClockPrivateMeego::~WallClockPrivateMeego() @@ -88,10 +95,7 @@ WallClockPrivateMeego::~WallClockPrivateMeego() void WallClockPrivateMeego::onDisplayStatusChanged(const QString &status) { - if (status == MCE_DISPLAY_ON_STRING) { - update(); - timeChanged(); - } + setSuspended(status == MCE_DISPLAY_OFF_STRING); } QString WallClockPrivateMeego::timezone() const diff --git a/src/nemowallclock_p.h b/src/nemowallclock_p.h index 2d4fffb..3603c74 100644 --- a/src/nemowallclock_p.h +++ b/src/nemowallclock_p.h @@ -49,12 +49,15 @@ class WallClockPrivate : public QPauseAnimation bool enabled() const { return m_enabled; } virtual void setEnabled(bool); + bool suspended() const { return m_suspended; } + virtual QDateTime time() const; virtual QString timezone() const; virtual QString timezoneAbbreviation() const; protected: virtual void update(); + virtual void setSuspended(bool); void timezoneChanged(); void timezoneAbbreviationChanged(); void timeChanged(); @@ -66,6 +69,7 @@ class WallClockPrivate : public QPauseAnimation WallClock *q; WallClock::UpdateFrequency m_updateFreq; bool m_enabled; + bool m_suspended; }; #endif // WALLCLOCK_P_H