qtinternetradio/ui/src/irplayingbanner.cpp
changeset 14 896e9dbc5f19
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
       
     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 <HbTapGesture>
       
    19 #include <HbEvent>
       
    20 #include <HbLabel>
       
    21 #include <HbMarqueeItem>
       
    22 #include <HbColorScheme>
       
    23 #include <QGraphicsLayout>
       
    24 
       
    25 #include "irplayingbanner.h"
       
    26 #include "iruidefines.h"
       
    27 
       
    28 IRPlayingBanner::IRPlayingBanner() : iStationName(NULL), iArtistSongName(NULL)
       
    29 {
       
    30     grabGesture(Qt::TapGesture);
       
    31 }
       
    32 
       
    33 void IRPlayingBanner::gestureEvent(QGestureEvent *aEvent)
       
    34 {
       
    35     HbTapGesture *tapGesture = qobject_cast<HbTapGesture *>(aEvent->gesture(Qt::TapGesture));
       
    36     if (!tapGesture)
       
    37     {
       
    38         return;
       
    39     }
       
    40     
       
    41     if (Qt::GestureStarted == tapGesture->state())
       
    42     {
       
    43         setPlayingBannerTextColor(KNowPlayingBannerColorPressed);
       
    44     }
       
    45     else if (Qt::GestureFinished == tapGesture->state())
       
    46     {
       
    47         setPlayingBannerTextColor(KNowPlayingBannerColorNormal);
       
    48         emit playingBannerTapFinished();
       
    49     }
       
    50     else if (Qt::GestureCanceled == tapGesture->state())
       
    51     {
       
    52         setPlayingBannerTextColor(KNowPlayingBannerColorNormal);
       
    53     }
       
    54 }
       
    55 
       
    56 void IRPlayingBanner::changeEvent(QEvent *event)
       
    57 {
       
    58     if (HbEvent::ThemeChanged == event->type())
       
    59     {
       
    60         setPlayingBannerTextColor(KNowPlayingBannerColorNormal);
       
    61     }
       
    62     
       
    63     HbWidget::changeEvent(event);
       
    64 }
       
    65 
       
    66 void IRPlayingBanner::setPlayingBannerTextColor(const QString &aColor)
       
    67 {
       
    68     init();
       
    69     QColor color = HbColorScheme::color(aColor);
       
    70     iStationName->setTextColor(color);
       
    71     iArtistSongName->setTextColor(color);
       
    72 }
       
    73 
       
    74 void IRPlayingBanner::init()
       
    75 {
       
    76     if (iStationName && iArtistSongName)
       
    77     {
       
    78         return;
       
    79     }
       
    80 
       
    81     int max = layout()->count();
       
    82     for (int i = 0; i < max; i++)
       
    83     {
       
    84         QObject *obj = dynamic_cast<QObject *>(layout()->itemAt(i));
       
    85         if (obj->objectName() == ABSTRACT_LIST_VIEW_BASE_OBJECT_STATIONNAME)
       
    86         {
       
    87             iStationName =  static_cast<HbLabel *>(obj);
       
    88         }
       
    89         else if (obj->objectName() == ABSTRACT_LIST_VIEW_BASE_OBJECT_ARTISTSONGNAME)
       
    90         {
       
    91             iArtistSongName = static_cast<HbMarqueeItem *>(obj);;
       
    92         }
       
    93     }
       
    94 }