homescreenapp/hsutils/src/hsspinnerdialog.cpp
changeset 62 341166945d65
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
       
     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:
       
    15 *    Spinner dialog shown when setting new background image
       
    16 *
       
    17 */
       
    18 
       
    19 #include <HbIconItem>
       
    20 #include <HbDialog>
       
    21 #include <HbInstance>
       
    22 #include <HbDeviceProfile>
       
    23 
       
    24 #include "hsspinnerdialog.h"
       
    25 
       
    26 /*!
       
    27     \internal
       
    28     \class HsSpinnerDialog
       
    29     \ingroup group_hsutils
       
    30     \brief Spinner dialog, used when background image is changed. By default dialog is created with Qt::WA_DeleteOnClose attribute so dialog
       
    31     is automatically deleted when closed.    
       
    32     
       
    33 */
       
    34 
       
    35 /*!
       
    36     \internal
       
    37     Constructor.
       
    38     
       
    39     \a parent Owner.
       
    40 */
       
    41 HsSpinnerDialog::HsSpinnerDialog(QGraphicsItem *parent)
       
    42 : HbDialog(parent)
       
    43 {
       
    44     setAttribute(Qt::WA_DeleteOnClose);
       
    45     setModal(true);
       
    46     setBackgroundFaded(true);
       
    47     setTimeout(HbPopup::NoTimeout);
       
    48     setBackgroundItem(0);
       
    49     setDismissPolicy(HbPopup::NoDismiss);
       
    50     HbIconItem* spinnerAnimation = new HbIconItem("qtg_anim_loading");
       
    51     HbDeviceProfile profile;
       
    52     qreal factor = profile.unitValue();
       
    53     spinnerAnimation->setPreferredSize(factor*10,factor*10);
       
    54     spinnerAnimation->setParentItem(this);
       
    55     setContentWidget(spinnerAnimation);
       
    56 }
       
    57 
       
    58 /*!
       
    59     \internal
       
    60     Destructor.    
       
    61 */
       
    62 HsSpinnerDialog::~HsSpinnerDialog()
       
    63 {
       
    64 }
       
    65 
       
    66 /*!
       
    67     \internal
       
    68     Starts spinner animation.
       
    69 */
       
    70 void HsSpinnerDialog::start()
       
    71 {
       
    72     HbInstance::instance()->allMainWindows().first()->setInteractive(false);
       
    73     show();
       
    74 }
       
    75 
       
    76 /*!
       
    77     \internal
       
    78     Stops spinner animation, dialog is deleted after it is closed.
       
    79 */
       
    80 void HsSpinnerDialog::stop()
       
    81 {
       
    82     HbInstance::instance()->allMainWindows().first()->setInteractive(true);
       
    83     close();
       
    84 }
       
    85