taskswitcher/testapplications/tsserviceloader/lunchwidget.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "lunchwidget.h"
       
    19 #include <QRect>
       
    20 #include <QPainter>
       
    21 #include <QUrl>
       
    22 #include <hbapplication>
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 #define hbApp qobject_cast<HbApplication*>(qApp)
       
    28 
       
    29 lunchwidget::lunchwidget(QGraphicsItem *parent)
       
    30     : HbWidget(parent)
       
    31 {
       
    32 	mManager = new QServiceManager; 
       
    33     mActivationButton = new HbPushButton("Activity");
       
    34     mProviderButton = new HbPushButton("Provider");
       
    35     mResultLabel = new HbLabel;
       
    36     
       
    37     mGridLayout = new QGraphicsGridLayout();
       
    38     mGridLayout->addItem(mResultLabel, 0, 0, 1, 1);
       
    39     mGridLayout->addItem(mActivationButton, 1, 0, 1, 1);
       
    40     mGridLayout->addItem(mProviderButton, 2, 0, 1, 1);
       
    41     setLayout(mGridLayout);
       
    42 
       
    43 
       
    44     connect(mActivationButton, SIGNAL(released()), this, SLOT(lunchActivation()));
       
    45     connect(mProviderButton, SIGNAL(released()), this, SLOT(lunchProvider()));
       
    46    
       
    47 }
       
    48 
       
    49 lunchwidget::~lunchwidget()
       
    50 {
       
    51 
       
    52 }
       
    53 
       
    54 void lunchwidget::lunchActivation()
       
    55 {
       
    56     bool ok = mManager->addService(":/activityserviceplugin.xml");
       
    57     setError(ok, mManager->error());
       
    58 }
       
    59 
       
    60 void lunchwidget::lunchProvider()
       
    61 {
       
    62     bool ok = mManager->addService(":/tstestmodelplugin.xml");
       
    63     setError(ok, mManager->error());
       
    64 }		
       
    65 
       
    66 
       
    67 void lunchwidget::setError(bool ok, int err)
       
    68 {
       
    69     if (!ok) {
       
    70         QString num;
       
    71         num.setNum(err);
       
    72         mResultLabel->setPlainText(num);
       
    73         }
       
    74     else {
       
    75         mResultLabel->setPlainText("Ok");
       
    76         }
       
    77 }