src/hbcore/decorators/hbstatusbar.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
--- a/src/hbcore/decorators/hbstatusbar.cpp	Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbcore/decorators/hbstatusbar.cpp	Mon Oct 04 00:38:12 2010 +0300
@@ -37,6 +37,7 @@
 #include "hbsignalindicator_p.h"
 #include "hbbatteryindicator_p.h"
 #include "hbindicatorgroup_p.h"
+#include "hbdevicedialogserverstatus_p.h"
 
 #if defined(Q_OS_SYMBIAN)
 #include "hbindicatorsym_p.h"
@@ -46,7 +47,7 @@
 #include "hbindicatorwin32_p.h"
 #endif // defined(Q_OS_SYMBIAN)
 
-const int clockUpdateDelay = 10000; // 10 s
+const int clockUpdateDelay = 1000; // 1 s
 
 /*
     \class HbStatusBar
@@ -65,7 +66,8 @@
     mSettingsIndicatorGroup(0),
     mMainWindow(0),
     mPreviousProperties(0),
-    mIndicatorPrivate(0)
+    mIndicatorPrivate(0),
+    mServerStatus(0)
 {
 #if defined(Q_OS_SYMBIAN)
     // Register for system environment changes
@@ -76,6 +78,7 @@
 
     mEnvChangeNotifier->Start();
 #endif
+    mServerStatus = new HbDeviceDialogServerStatus(false);
 }
 
 HbStatusBarPrivate::~HbStatusBarPrivate()
@@ -91,6 +94,7 @@
         delete mEnvChangeNotifier;
         }
 #endif
+    delete mServerStatus;
 }
 
 void HbStatusBarPrivate::delayedConstruction()
@@ -138,6 +142,9 @@
 
     q->connect(mMainWindow, SIGNAL(currentViewChanged(HbView*)), q, SLOT(currentViewChanged(HbView*)));
 
+    q->connect(mMainWindow, SIGNAL(revealed()), q, SLOT(startClockTimer()));
+    q->connect(mMainWindow, SIGNAL(obscured()), q, SLOT(startClockTimer()));
+
     mClockTimerId = q->startTimer(clockUpdateDelay);
     mIndicatorPrivate->startListen();
 
@@ -252,6 +259,22 @@
     }
 }
 
+void HbStatusBarPrivate::startClockTimer()
+{
+    Q_Q(HbStatusBar);
+    updateTime();
+    mClockTimerId = q->startTimer(clockUpdateDelay);
+}
+
+void HbStatusBarPrivate::killClockTimer()
+{
+    Q_Q(HbStatusBar);
+    if (mClockTimerId != 0) {
+        q->killTimer(mClockTimerId);
+        mClockTimerId = 0;
+    }
+}
+
 #if defined(Q_OS_SYMBIAN)
 TInt HbStatusBarPrivate::EnvChangeCallback(TAny *aObject)
 {
@@ -284,6 +307,7 @@
     d->init();
     setFlag(QGraphicsItem::ItemHasNoContents, true);
     createPrimitives();
+    qApp->installEventFilter(this);
 }
 
 /*
@@ -429,15 +453,33 @@
 {
     Q_D(HbStatusBar);
     if (e->type() == HbEvent::SleepModeEnter) {
-        if (d->mClockTimerId != 0) {
-            killTimer(d->mClockTimerId);
-            d->mClockTimerId = 0;
-        }
+        d->killClockTimer();
     } else if (e->type() == HbEvent::SleepModeExit) {
-        d->updateTime();
-        d->mClockTimerId = startTimer(clockUpdateDelay);
+        d->startClockTimer();
     }
     return HbWidget::event(e);
 }
 
+bool HbStatusBar::eventFilter(QObject *obj, QEvent *event)
+{
+    Q_D(HbStatusBar);
+    if (event->type() == QEvent::ApplicationActivate) {
+        d->startClockTimer();
+        d->mBatteryIndicator->chargingEvent(true);
+    } else if (event->type() == QEvent::ApplicationDeactivate) {
+        HbDeviceDialogServerStatus::StatusFlags flags = d->mServerStatus->status();
+        if (flags != HbDeviceDialogServerStatus::ShowingDialog) {
+            d->killClockTimer();
+            d->mBatteryIndicator->chargingEvent(false);
+        }
+    }
+    return HbWidget::eventFilter(obj, event);
+}
+
+void HbStatusBar::startClockTimer()
+{
+    Q_D(HbStatusBar);
+    d->startClockTimer();
+}
+
 #include "moc_hbstatusbar_p.cpp"