src/hbcore/decorators/hbstatusbar.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
equal deleted inserted replaced
28:b7da29130b0e 30:80e4d18b72f5
    35 #include "hbstatusbar_p_p.h"
    35 #include "hbstatusbar_p_p.h"
    36 #include "hbstyleoptionstatusbar_p.h"
    36 #include "hbstyleoptionstatusbar_p.h"
    37 #include "hbsignalindicator_p.h"
    37 #include "hbsignalindicator_p.h"
    38 #include "hbbatteryindicator_p.h"
    38 #include "hbbatteryindicator_p.h"
    39 #include "hbindicatorgroup_p.h"
    39 #include "hbindicatorgroup_p.h"
       
    40 #include "hbdevicedialogserverstatus_p.h"
    40 
    41 
    41 #if defined(Q_OS_SYMBIAN)
    42 #if defined(Q_OS_SYMBIAN)
    42 #include "hbindicatorsym_p.h"
    43 #include "hbindicatorsym_p.h"
    43 #include <bacntf.h>  // CEnvironmentChangeNotifier
    44 #include <bacntf.h>  // CEnvironmentChangeNotifier
    44 #include <coemain.h> // EActivePriorityLogonA
    45 #include <coemain.h> // EActivePriorityLogonA
    45 #else
    46 #else
    46 #include "hbindicatorwin32_p.h"
    47 #include "hbindicatorwin32_p.h"
    47 #endif // defined(Q_OS_SYMBIAN)
    48 #endif // defined(Q_OS_SYMBIAN)
    48 
    49 
    49 const int clockUpdateDelay = 10000; // 10 s
    50 const int clockUpdateDelay = 1000; // 1 s
    50 
    51 
    51 /*
    52 /*
    52     \class HbStatusBar
    53     \class HbStatusBar
    53     \brief HbStatusBar is the class implementing statusbar decorator.
    54     \brief HbStatusBar is the class implementing statusbar decorator.
    54     Statusbar is a container for two indicator groups (left and right),
    55     Statusbar is a container for two indicator groups (left and right),
    63     mBatteryIndicator(0),
    64     mBatteryIndicator(0),
    64     mNotificationIndicatorGroup(0),
    65     mNotificationIndicatorGroup(0),
    65     mSettingsIndicatorGroup(0),
    66     mSettingsIndicatorGroup(0),
    66     mMainWindow(0),
    67     mMainWindow(0),
    67     mPreviousProperties(0),
    68     mPreviousProperties(0),
    68     mIndicatorPrivate(0)
    69     mIndicatorPrivate(0),
       
    70     mServerStatus(0)
    69 {
    71 {
    70 #if defined(Q_OS_SYMBIAN)
    72 #if defined(Q_OS_SYMBIAN)
    71     // Register for system environment changes
    73     // Register for system environment changes
    72     TCallBack envCallback(EnvChangeCallback, this);
    74     TCallBack envCallback(EnvChangeCallback, this);
    73 
    75 
    74     mEnvChangeNotifier =
    76     mEnvChangeNotifier =
    75         CEnvironmentChangeNotifier::NewL(EActivePriorityLogonA, envCallback);
    77         CEnvironmentChangeNotifier::NewL(EActivePriorityLogonA, envCallback);
    76 
    78 
    77     mEnvChangeNotifier->Start();
    79     mEnvChangeNotifier->Start();
    78 #endif
    80 #endif
       
    81     mServerStatus = new HbDeviceDialogServerStatus(false);
    79 }
    82 }
    80 
    83 
    81 HbStatusBarPrivate::~HbStatusBarPrivate()
    84 HbStatusBarPrivate::~HbStatusBarPrivate()
    82 {
    85 {
    83     mIndicatorPrivate->stopListen();     
    86     mIndicatorPrivate->stopListen();     
    89         {
    92         {
    90         mEnvChangeNotifier->Cancel();
    93         mEnvChangeNotifier->Cancel();
    91         delete mEnvChangeNotifier;
    94         delete mEnvChangeNotifier;
    92         }
    95         }
    93 #endif
    96 #endif
       
    97     delete mServerStatus;
    94 }
    98 }
    95 
    99 
    96 void HbStatusBarPrivate::delayedConstruction()
   100 void HbStatusBarPrivate::delayedConstruction()
    97 {
   101 {
    98     Q_Q(HbStatusBar);
   102     Q_Q(HbStatusBar);
   135         q, SLOT(_q_indicatorsChanged()));
   139         q, SLOT(_q_indicatorsChanged()));
   136     q->connect(mIndicatorPrivate, SIGNAL(deactivated(const QList<IndicatorClientInfo> &)),
   140     q->connect(mIndicatorPrivate, SIGNAL(deactivated(const QList<IndicatorClientInfo> &)),
   137         q, SLOT(_q_indicatorsChanged()));
   141         q, SLOT(_q_indicatorsChanged()));
   138 
   142 
   139     q->connect(mMainWindow, SIGNAL(currentViewChanged(HbView*)), q, SLOT(currentViewChanged(HbView*)));
   143     q->connect(mMainWindow, SIGNAL(currentViewChanged(HbView*)), q, SLOT(currentViewChanged(HbView*)));
       
   144 
       
   145     q->connect(mMainWindow, SIGNAL(revealed()), q, SLOT(startClockTimer()));
       
   146     q->connect(mMainWindow, SIGNAL(obscured()), q, SLOT(startClockTimer()));
   140 
   147 
   141     mClockTimerId = q->startTimer(clockUpdateDelay);
   148     mClockTimerId = q->startTimer(clockUpdateDelay);
   142     mIndicatorPrivate->startListen();
   149     mIndicatorPrivate->startListen();
   143 
   150 
   144     q->grabGesture(Qt::TapGesture);
   151     q->grabGesture(Qt::TapGesture);
   250     if (mTimeText != oldTimeText) {
   257     if (mTimeText != oldTimeText) {
   251         emit q->contentChanged(HbStatusBar::TimeChanged);
   258         emit q->contentChanged(HbStatusBar::TimeChanged);
   252     }
   259     }
   253 }
   260 }
   254 
   261 
       
   262 void HbStatusBarPrivate::startClockTimer()
       
   263 {
       
   264     Q_Q(HbStatusBar);
       
   265     updateTime();
       
   266     mClockTimerId = q->startTimer(clockUpdateDelay);
       
   267 }
       
   268 
       
   269 void HbStatusBarPrivate::killClockTimer()
       
   270 {
       
   271     Q_Q(HbStatusBar);
       
   272     if (mClockTimerId != 0) {
       
   273         q->killTimer(mClockTimerId);
       
   274         mClockTimerId = 0;
       
   275     }
       
   276 }
       
   277 
   255 #if defined(Q_OS_SYMBIAN)
   278 #if defined(Q_OS_SYMBIAN)
   256 TInt HbStatusBarPrivate::EnvChangeCallback(TAny *aObject)
   279 TInt HbStatusBarPrivate::EnvChangeCallback(TAny *aObject)
   257 {
   280 {
   258     // Return value for functions used as TCallBack objects should be EFalse
   281     // Return value for functions used as TCallBack objects should be EFalse
   259     // unless the function is intended to be called again from a timer.
   282     // unless the function is intended to be called again from a timer.
   282     d->q_ptr = this;
   305     d->q_ptr = this;
   283     d->mMainWindow = mainWindow;
   306     d->mMainWindow = mainWindow;
   284     d->init();
   307     d->init();
   285     setFlag(QGraphicsItem::ItemHasNoContents, true);
   308     setFlag(QGraphicsItem::ItemHasNoContents, true);
   286     createPrimitives();
   309     createPrimitives();
       
   310     qApp->installEventFilter(this);
   287 }
   311 }
   288 
   312 
   289 /*
   313 /*
   290     Destructor.
   314     Destructor.
   291  */
   315  */
   427 */
   451 */
   428 bool HbStatusBar::event(QEvent *e)
   452 bool HbStatusBar::event(QEvent *e)
   429 {
   453 {
   430     Q_D(HbStatusBar);
   454     Q_D(HbStatusBar);
   431     if (e->type() == HbEvent::SleepModeEnter) {
   455     if (e->type() == HbEvent::SleepModeEnter) {
   432         if (d->mClockTimerId != 0) {
   456         d->killClockTimer();
   433             killTimer(d->mClockTimerId);
       
   434             d->mClockTimerId = 0;
       
   435         }
       
   436     } else if (e->type() == HbEvent::SleepModeExit) {
   457     } else if (e->type() == HbEvent::SleepModeExit) {
   437         d->updateTime();
   458         d->startClockTimer();
   438         d->mClockTimerId = startTimer(clockUpdateDelay);
       
   439     }
   459     }
   440     return HbWidget::event(e);
   460     return HbWidget::event(e);
   441 }
   461 }
   442 
   462 
       
   463 bool HbStatusBar::eventFilter(QObject *obj, QEvent *event)
       
   464 {
       
   465     Q_D(HbStatusBar);
       
   466     if (event->type() == QEvent::ApplicationActivate) {
       
   467         d->startClockTimer();
       
   468         d->mBatteryIndicator->chargingEvent(true);
       
   469     } else if (event->type() == QEvent::ApplicationDeactivate) {
       
   470         HbDeviceDialogServerStatus::StatusFlags flags = d->mServerStatus->status();
       
   471         if (flags != HbDeviceDialogServerStatus::ShowingDialog) {
       
   472             d->killClockTimer();
       
   473             d->mBatteryIndicator->chargingEvent(false);
       
   474         }
       
   475     }
       
   476     return HbWidget::eventFilter(obj, event);
       
   477 }
       
   478 
       
   479 void HbStatusBar::startClockTimer()
       
   480 {
       
   481     Q_D(HbStatusBar);
       
   482     d->startClockTimer();
       
   483 }
       
   484 
   443 #include "moc_hbstatusbar_p.cpp"
   485 #include "moc_hbstatusbar_p.cpp"