controlpanelui/src/cpapplication/src/cpmainwindow.cpp
changeset 40 593f946f4fec
parent 22 a5692c68d772
equal deleted inserted replaced
22:a5692c68d772 40:593f946f4fec
    19 #include "cpmainview.h"
    19 #include "cpmainview.h"
    20 #include <cpplugininterface.h>
    20 #include <cpplugininterface.h>
    21 #include <cpcategorysettingformitemdata.h>
    21 #include <cpcategorysettingformitemdata.h>
    22 #include <hbapplication.h>
    22 #include <hbapplication.h>
    23 #include <cpevent.h>
    23 #include <cpevent.h>
    24 
    24 #include <QTimer>
    25 //CpMainWindow implementation
    25 //CpMainWindow implementation
    26 CpMainWindow::CpMainWindow(QWidget *parent /*= 0*/, Hb::WindowFlags windowFlags /*= Hb::WindowFlagNone*/)
    26 CpMainWindow::CpMainWindow(QWidget *parent /*= 0*/, Hb::WindowFlags windowFlags /*= Hb::WindowFlagNone*/)
    27 : HbMainWindow(parent,windowFlags)
    27 : HbMainWindow(parent,windowFlags),mStartupTimer(0)
    28 {
    28 {
       
    29     // start a zero interval timer to identify the startup of control panel is finished.
       
    30     mStartupTimer = new QTimer(this);         
       
    31     connect(mStartupTimer, SIGNAL(timeout()), this, SLOT(onStartupFininshed()));
       
    32     mStartupTimer->start();
    29 }
    33 }
    30 
    34 
    31 CpMainWindow::~CpMainWindow()
    35 CpMainWindow::~CpMainWindow()
    32 {
    36 {
    33     
    37     CpMainView *mainView = qobject_cast<CpMainView *>(views().first());
       
    38     if(mainView != 0) {
       
    39         mainView->saveActivity();
       
    40     }
       
    41     if(mStartupTimer != 0) {
       
    42         delete mStartupTimer;
       
    43     } 
    34 }
    44 }
    35 
    45 
    36 bool CpMainWindow::event(QEvent *e)
    46 bool CpMainWindow::event(QEvent *e)
    37 {
    47 {
    38     if (e->type() == (QEvent::Type)(CpCreatePluginItemDataEvent::CreatePluginItemData)) {
    48     if (e->type() == (QEvent::Type)(CpCreatePluginItemDataEvent::CreatePluginItemData)) {
    41         e->accept();
    51         e->accept();
    42     }
    52     }
    43     return HbMainWindow::event(e);
    53     return HbMainWindow::event(e);
    44 }
    54 }
    45 
    55 
       
    56 /**
       
    57  * Emit applicationReady signal when start up process is finished.
       
    58  */
       
    59 void CpMainWindow::onStartupFininshed()
       
    60 {
       
    61     // emit applicationReady signal when the all initilizing event has been deal with.
       
    62     // only emit it once
       
    63     emit applicationReady();
       
    64     if (mStartupTimer != 0) {
       
    65         mStartupTimer->stop();
       
    66         delete mStartupTimer;
       
    67         mStartupTimer = 0;
       
    68     }    
       
    69 }
    46 //End of File
    70 //End of File
    47 
    71 
    48 
    72