src/hbcore/decorators/hbindicatorbutton.cpp
changeset 28 b7da29130b0e
parent 21 4633027730f5
child 30 80e4d18b72f5
--- a/src/hbcore/decorators/hbindicatorbutton.cpp	Thu Sep 02 20:44:51 2010 +0300
+++ b/src/hbcore/decorators/hbindicatorbutton.cpp	Fri Sep 17 08:32:10 2010 +0300
@@ -37,13 +37,68 @@
 #include "hbstyleoptionindicatorbutton_p.h"
 
 #if defined(Q_OS_SYMBIAN)
+#include <e32property.h>
 #include "hbindicatorsym_p.h"
+#include "hbdevicedialogsym_p.h"
+const TUid PropertyCategoryUid = {0x20022FC5};
+const TUint EventKey = 'nEvt';
 #else
 #include "hbindicatorwin32_p.h"
 #endif // defined(Q_OS_SYMBIAN)
 
 static const char noteIndicatorType[] = {"com.nokia.hb.indicatormenu/1.0"};
 
+#if defined(Q_OS_SYMBIAN)
+
+class HbIndicatorButtonStatusPrivate  : public CActive
+{
+public:
+    HbIndicatorButtonStatusPrivate(HbIndicatorButtonPrivate* indicatorButtonPrivate);
+    ~HbIndicatorButtonStatusPrivate();
+
+public: // from CActive
+    void RunL();
+    void DoCancel();
+
+private:
+    HbIndicatorButtonPrivate* mIndicatorButtonPrivate;
+    RProperty mProperty;
+};
+
+HbIndicatorButtonStatusPrivate::HbIndicatorButtonStatusPrivate(
+    HbIndicatorButtonPrivate* indicatorButtonPrivate) : CActive(CActive::EPriorityStandard),
+    mIndicatorButtonPrivate(indicatorButtonPrivate)
+{
+    CActiveScheduler::Add(this);
+    iStatus = KRequestPending;
+    mProperty.Attach(PropertyCategoryUid, EventKey);
+    mProperty.Subscribe(iStatus);
+    SetActive();
+}
+
+HbIndicatorButtonStatusPrivate::~HbIndicatorButtonStatusPrivate()
+{
+    Cancel();
+    mProperty.Close();
+}
+
+void HbIndicatorButtonStatusPrivate::RunL()
+{
+    int newValue(0);
+    if (mProperty.Get(newValue) == KErrNone) {
+        mIndicatorButtonPrivate->setNewEvent(newValue == 0 ? false : true);
+    }
+    mProperty.Subscribe(iStatus);
+    SetActive();
+}
+
+void HbIndicatorButtonStatusPrivate::DoCancel()
+{
+    mProperty.Cancel();
+}
+
+#endif // defined(Q_OS_SYMBIAN)
+
 HbIndicatorButtonPrivate::HbIndicatorButtonPrivate() :
     mHandleIcon(0), mDefaultAction(0), mNewEventAction(0), mProgressAction(0), mDeviceDialog(0), 
     mProgressAnimationFound(false), mNewEventIcon(0), mNewEvent(false), mStyle(0), mIndicatorMenuOpen(false),
@@ -55,6 +110,10 @@
 HbIndicatorButtonPrivate::~HbIndicatorButtonPrivate()
 {
     delete mDeviceDialog;
+
+#if defined(Q_OS_SYMBIAN)    
+    delete mIndicatorButtonStatusPrivate;
+#endif // defined(Q_OS_SYMBIAN)
 }
 
 void HbIndicatorButtonPrivate::init()
@@ -65,8 +124,8 @@
         "qtg_anim_mono_loading.axml");
     
     // add default actions
-    mDefaultAction = new HbAction(HbIcon("qtg_mono_options_menu"), "IndicatorMenu", q);
-    mNewEventAction = new HbAction(HbIcon("qtg_mono_new_event"), "IndicatorMenu", q);
+    mDefaultAction = new HbAction(HbIcon("qtg_mono_options_menu"), "", q);
+    mNewEventAction = new HbAction(HbIcon("qtg_mono_new_event"), "", q);
 
     QString iconName("qtg_anim_mono_loading_1");
     if (mProgressAnimationFound) {
@@ -74,7 +133,7 @@
     }
     HbIcon icon(iconName);
     icon.setFlags(HbIcon::Colorized);
-    mProgressAction = new HbAction(icon, "IndicatorMenu", q);
+    mProgressAction = new HbAction(icon, "", q);
 }
 
 void HbIndicatorButtonPrivate::showIndicatorMenu()
@@ -88,6 +147,10 @@
     mIndicatorMenuOpen = true;
 
     updateIcon();
+   
+#if defined(Q_OS_SYMBIAN) 
+    RProperty::Set(PropertyCategoryUid, EventKey, 0);
+#endif // defined(Q_OS_SYMBIAN)
 }
 
 void HbIndicatorButtonPrivate::addIndicators(const QList<IndicatorClientInfo> &clientInfo)
@@ -183,6 +246,12 @@
     }
 }
 
+void HbIndicatorButtonPrivate::setNewEvent(bool newEvent)
+{
+    mNewEvent = newEvent;
+    updateIcon();
+}
+
 HbIndicatorButton::HbIndicatorButton(QGraphicsItem *parent) 
     : HbToolButton(*new HbIndicatorButtonPrivate, parent)
 {
@@ -206,13 +275,21 @@
 
     connect(this, SIGNAL(pressed()), this, SLOT(handlePress()));
     connect(this, SIGNAL(released()), this, SLOT(handleRelease()));
-
-    d->mDeviceDialog = new HbDeviceDialog(HbDeviceDialog::ImmediateResourceReservationFlag);
+    
+    
+    d->mDeviceDialog = new HbDeviceDialog();
+#if defined(Q_OS_SYMBIAN)
+    ((HbDeviceDialogPrivate*)HbDeviceDialogPrivate::d_ptr(d->mDeviceDialog))->connect();
+#endif
     connect(d->mDeviceDialog, SIGNAL(deviceDialogClosed()), this, SLOT(resetBackground()));
 
     connect(d->mDefaultAction, SIGNAL(triggered()), this, SLOT(showIndicatorMenu()));
     connect(d->mNewEventAction, SIGNAL(triggered()), this, SLOT(showIndicatorMenu()));
     connect(d->mProgressAction, SIGNAL(triggered()), this, SLOT(showIndicatorMenu()));
+   
+#if defined(Q_OS_SYMBIAN)
+    d->mIndicatorButtonStatusPrivate = new HbIndicatorButtonStatusPrivate(d);
+#endif // defined(Q_OS_SYMBIAN)
 }
 
 void HbIndicatorButton::showHandleIndication(bool show)