homescreenapp/examples/contentpublishclient/src/main.cpp
branchRCL_3
changeset 82 5f0182e07bfb
equal deleted inserted replaced
79:f00a6757af32 82:5f0182e07bfb
       
     1 /*
       
     2 * Copyright (c) 2010 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:  Example of home screen content publishing client
       
    15 *
       
    16 */
       
    17 
       
    18 #include <HbApplication>
       
    19 #include <HbMainWindow>
       
    20 #include <HbView>
       
    21 #include <HbPushButton>
       
    22 #include <QGraphicsLinearLayout>
       
    23 #include <QDir>
       
    24 
       
    25 #include "contentpublishclient.h"
       
    26 
       
    27 int main(int argc, char *argv[])
       
    28 {
       
    29     // Initialization
       
    30     HbApplication app(argc, argv);
       
    31         
       
    32     QServiceManager manager;
       
    33     
       
    34     // Create main window.
       
    35     HbMainWindow mainWindow;
       
    36 
       
    37     // Create content publisher client
       
    38 	ContentPublishClient contentPublishClient(manager);
       
    39 
       
    40     QString buttonString = "Add HelloWorld";
       
    41     bool clientOk = contentPublishClient.load(); 
       
    42     if (!clientOk) {
       
    43         buttonString = "Open failed";
       
    44     }
       
    45 
       
    46     HbWidget *myView = new HbWidget();
       
    47     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
       
    48     
       
    49     HbPushButton* button1 = new HbPushButton(buttonString);
       
    50     layout->addItem(button1);
       
    51     contentPublishClient.connect(button1, SIGNAL(pressed()), SLOT(addHelloworldWidget()));
       
    52     
       
    53     if (clientOk) {
       
    54         HbPushButton* button2 = new HbPushButton("Add Clock widget");
       
    55         HbPushButton* button3 = new HbPushButton("Set wallpaper1");
       
    56         HbPushButton* button4 = new HbPushButton("Set wallpaper2");
       
    57         
       
    58         layout->addItem(button2);
       
    59         layout->addItem(button3);
       
    60         layout->addItem(button4);
       
    61         
       
    62         contentPublishClient.connect(button2, SIGNAL(pressed()), SLOT(addClockWidget()));
       
    63         contentPublishClient.connect(button3, SIGNAL(pressed()), SLOT(setWallpaper1()));
       
    64         contentPublishClient.connect(button4, SIGNAL(pressed()), SLOT(setWallpaper2()));
       
    65     }
       
    66     
       
    67     
       
    68     myView->setLayout(layout);
       
    69 
       
    70 	// Add view
       
    71     mainWindow.addView(myView);
       
    72     
       
    73     // Show main window
       
    74     mainWindow.show();
       
    75 
       
    76     return app.exec();
       
    77 }