qtinternetradio/irhswidgetplugin/src/irhswidgettitlerow.cpp
changeset 15 065198191975
parent 14 896e9dbc5f19
equal deleted inserted replaced
14:896e9dbc5f19 15:065198191975
    26 
    26 
    27 // User includes
    27 // User includes
    28 #include "irhswidgettitlerow.h"
    28 #include "irhswidgettitlerow.h"
    29 #include "irservicedef.h"
    29 #include "irservicedef.h"
    30 #include "irhswidgetuiloader.h"
    30 #include "irhswidgetuiloader.h"
       
    31 #include "irqlogger.h"
    31 
    32 
    32 // Constants
    33 // Constants
    33 static const QString KIrHsWidgetTitleRowDocML       = ":/resource/irhswidgettitlerow.docml";
    34 static const QString KIrHsWidgetTitleRowDocML       = ":/resource/irhswidgettitlerow.docml";
    34 static const QString KIrHsWidgetTitleRowContainer   = "titlerow_layout";
    35 static const QString KIrHsWidgetTitleRowContainer   = "titlerow_layout";
    35 static const QString KIrHsWidgetStationLogo         = "station_logo";
    36 static const QString KIrHsWidgetStationLogo         = "station_logo";
    44 IrHsWidgetTitleRow::IrHsWidgetTitleRow(QGraphicsItem *aParent, Qt::WindowFlags aFlags) :
    45 IrHsWidgetTitleRow::IrHsWidgetTitleRow(QGraphicsItem *aParent, Qt::WindowFlags aFlags) :
    45     HbWidget(aParent, aFlags), 
    46     HbWidget(aParent, aFlags), 
    46     mStationLogo(NULL), 
    47     mStationLogo(NULL), 
    47     mStationName(NULL)
    48     mStationName(NULL)
    48 {
    49 {
       
    50     LOG_METHOD;
    49     loadUi();
    51     loadUi();
    50     grabGesture(Qt::TapGesture);
    52     grabGesture(Qt::TapGesture);
    51 }
    53 }
    52 
    54 
    53 IrHsWidgetTitleRow::~IrHsWidgetTitleRow()
    55 IrHsWidgetTitleRow::~IrHsWidgetTitleRow()
    54 {
    56 {
       
    57     LOG_METHOD;
    55 }
    58 }
    56 
    59 
    57 void IrHsWidgetTitleRow::loadUi()
    60 void IrHsWidgetTitleRow::loadUi()
    58 {
    61 {
       
    62     LOG_METHOD;
    59     IRHsWidgetUiLoader loader;
    63     IRHsWidgetUiLoader loader;
    60     loader.load(KIrHsWidgetTitleRowDocML);
    64     loader.load(KIrHsWidgetTitleRowDocML);
    61 
    65 
    62     //Create layout
    66     //Create layout
    63     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
    67     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
    75     mStationName->setTextColor(HbColorScheme::color(KStationNameColor));         
    79     mStationName->setTextColor(HbColorScheme::color(KStationNameColor));         
    76 }
    80 }
    77 
    81 
    78 void IrHsWidgetTitleRow::setDefaultTitle()
    82 void IrHsWidgetTitleRow::setDefaultTitle()
    79 {
    83 {
       
    84     LOG_METHOD;
    80 #ifdef SUBTITLE_STR_BY_LOCID 
    85 #ifdef SUBTITLE_STR_BY_LOCID 
    81     mStationName->setPlainText(hbTrId("txt_ir_list_internet_radio"));
    86     mStationName->setPlainText(hbTrId("txt_ir_list_internet_radio"));
    82 #else
    87 #else
    83     mStationName->setPlainText(hbTrId("Internet Radio"));    
    88     mStationName->setPlainText(hbTrId("Internet Radio"));    
    84 #endif
    89 #endif
    85 }
    90 }
    86 
    91 
    87 void IrHsWidgetTitleRow::setStationName(const QString& aStationName)
    92 void IrHsWidgetTitleRow::setStationName(const QString& aStationName)
    88 {
    93 {
       
    94     LOG_METHOD;
       
    95     LOG_FORMAT("aStationName = %s", STRING2CHAR(aStationName));
    89     if (mStationName->plainText() != aStationName)
    96     if (mStationName->plainText() != aStationName)
    90     {
    97     {
    91         mStationName->setPlainText(aStationName);
    98         mStationName->setPlainText(aStationName);
    92     }   
    99     }   
    93 }
   100 }
    94     
   101     
    95 void IrHsWidgetTitleRow::loadStationLogo()
   102 void IrHsWidgetTitleRow::loadStationLogo()
    96 {
   103 {
       
   104     LOG_METHOD;
    97     QSettings settings(KIrSettingOrganization, KIrSettingApplication);
   105     QSettings settings(KIrSettingOrganization, KIrSettingApplication);
    98     if (settings.value(KIrSettingStationLogo).canConvert<QPixmap>())
   106     if (settings.value(KIrSettingStationLogo).canConvert<QPixmap>())
    99     {
   107     {
   100         QPixmap logoPixmap = settings.value(KIrSettingStationLogo).value<QPixmap>();
   108         QPixmap logoPixmap = settings.value(KIrSettingStationLogo).value<QPixmap>();
   101         QPixmap newLogoPixmap = 
   109         QPixmap newLogoPixmap = 
   102              logoPixmap.scaled(QSize(KIrHsWidgetLogoSize,KIrHsWidgetLogoSize),Qt::KeepAspectRatio);
   110              logoPixmap.scaled(QSize(KIrHsWidgetLogoSize,KIrHsWidgetLogoSize),Qt::KeepAspectRatio);
   103         QIcon logoQIcon(newLogoPixmap);
   111         QIcon logoQIcon(newLogoPixmap);
   104         HbIcon logoHbIcon(logoQIcon);            
   112         HbIcon logoHbIcon(logoQIcon); 
       
   113         LOG("station logo loaded succesfully");
   105         mStationLogo->setIcon(logoHbIcon);
   114         mStationLogo->setIcon(logoHbIcon);
   106     }  
   115     }  
   107 }
   116 }
   108 
   117 
   109 void IrHsWidgetTitleRow::setDefaultLogo()
   118 void IrHsWidgetTitleRow::setDefaultLogo()
   110 {
   119 {
       
   120     LOG_METHOD;
   111     mStationLogo->setIcon(KDefaultStationLogo);
   121     mStationLogo->setIcon(KDefaultStationLogo);
   112 }
   122 }
   113 
   123 
   114 void IrHsWidgetTitleRow::gestureEvent(QGestureEvent *aEvent)
   124 void IrHsWidgetTitleRow::gestureEvent(QGestureEvent *aEvent)
   115 {
   125 {
       
   126     LOG_METHOD;
   116     HbTapGesture *tapGesture = qobject_cast<HbTapGesture *>(aEvent->gesture(Qt::TapGesture));
   127     HbTapGesture *tapGesture = qobject_cast<HbTapGesture *>(aEvent->gesture(Qt::TapGesture));
   117     if (!tapGesture)
   128     if (!tapGesture)
   118     {
   129     {
   119         return;
   130         return;
   120     }
   131     }
   121     
   132     
   122     if (Qt::GestureFinished == tapGesture->state()
   133     if (Qt::GestureFinished == tapGesture->state()
   123         && HbTapGesture::Tap == tapGesture->tapStyleHint())
   134         && HbTapGesture::Tap == tapGesture->tapStyleHint())
   124     {
   135     {
       
   136         LOG("emit titleRowClicked()");
   125         emit titleRowClicked();
   137         emit titleRowClicked();
   126     }
   138     }
   127 }
   139 }
   128 
   140 
   129 //Implemented to receive theme change event
   141 //Implemented to receive theme change event
   130 //@param QEvent, The change events to be received  
   142 //@param QEvent, The change events to be received  
   131 //
   143 //
   132 void IrHsWidgetTitleRow::changeEvent(QEvent *event)
   144 void IrHsWidgetTitleRow::changeEvent(QEvent *event)
   133 {
   145 {
       
   146     LOG_METHOD;
   134     if (HbEvent::ThemeChanged == event->type())
   147     if (HbEvent::ThemeChanged == event->type())
   135     {
   148     {
   136         // get the text color from theme and 
   149         // get the text color from theme and 
   137         // set it to station name label
   150         // set it to station name label
   138         mStationName->setTextColor(HbColorScheme::color(KStationNameColor));
   151         mStationName->setTextColor(HbColorScheme::color(KStationNameColor));