homescreenapp/hsutils/src/hstrashbinwidget.cpp
changeset 35 f9ce957a272c
child 36 cdae8c6c3876
equal deleted inserted replaced
5:c743ef5928ba 35:f9ce957a272c
       
     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: Trash bin widget.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QGraphicsLinearLayout>
       
    19 #include <HbIconItem>
       
    20 
       
    21 #include "hstrashbinwidget.h"
       
    22 
       
    23 const char* KTrashBinNormalItemImageName = "qtg_graf_hs_delete_normal";
       
    24 const char* KTrashBinHighlightItemImageName = "qtg_graf_hs_delete_highlight";
       
    25 
       
    26 /*!
       
    27     \internal
       
    28     \class HsTrashBinWidget
       
    29     \ingroup group_hsutils
       
    30     \brief Trash bin widget.
       
    31 */
       
    32 
       
    33 /*!
       
    34     \internal
       
    35     Constructor.
       
    36     
       
    37     \a parent Owner.
       
    38 */
       
    39 HsTrashBinWidget::HsTrashBinWidget(QGraphicsItem *parent)
       
    40     : HbWidget(parent),
       
    41       mIconItem(0),
       
    42       mNormalIcon(0),
       
    43       mHighlightIcon(0),
       
    44       mNormalIconVisible(false)
       
    45 {
       
    46     mIconItem = new HbIconItem(this);
       
    47 
       
    48     mNormalIcon = new HbIcon(KTrashBinNormalItemImageName);
       
    49     mHighlightIcon = new HbIcon(KTrashBinHighlightItemImageName);
       
    50 
       
    51     mIconItem->setIcon(*mNormalIcon);
       
    52     setPreferredSize(80,80); // workaround for icon updating problem when changing theme
       
    53     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal);
       
    54     layout->addItem(mIconItem);
       
    55     setLayout(layout);
       
    56 }
       
    57 
       
    58 /*!
       
    59     \internal
       
    60     Destructor.    
       
    61 */
       
    62 HsTrashBinWidget::~HsTrashBinWidget()
       
    63 {
       
    64 
       
    65 }
       
    66 
       
    67 /*!
       
    68     \internal
       
    69 */
       
    70 void HsTrashBinWidget::activate()
       
    71 {
       
    72     if (mNormalIconVisible) {
       
    73         mIconItem->setIcon(*mHighlightIcon);
       
    74         mNormalIconVisible = false;
       
    75     }
       
    76 }
       
    77 
       
    78 /*!
       
    79     \internal
       
    80 */
       
    81 void HsTrashBinWidget::deactivate()
       
    82 {
       
    83     if (!mNormalIconVisible) {
       
    84         mIconItem->setIcon(*mNormalIcon);
       
    85         mNormalIconVisible = true;
       
    86     }
       
    87 }