hswidgetplugin/fmradiohswidgetplugin/inc/fmradiohswidget.h
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 26 6bcf277166c1
parent 33 11b6825f0862
equal deleted inserted replaced
26:6bcf277166c1 37:451b2e1545b2
     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:  FM Radio home screen widget
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef FMRADIOHSWIDGET_H
       
    19 #define FMRADIOHSWIDGET_H
       
    20 
       
    21 // System includes
       
    22 #include <HbWidget>
       
    23 
       
    24 // User includes
       
    25 #include "fmradiohswidgetradioserviceclient.h"
       
    26 
       
    27 // Forward declarations
       
    28 class HbLabel;
       
    29 class HbPushButton;
       
    30 class HbMarqueeItem;
       
    31 class XQSettingsManager;
       
    32 class XQSettingsKey;
       
    33 class FmRadioHsWidgetProcessHandler;
       
    34 class FmRadioHsWidgetProfileReader;
       
    35 class QGraphicsLinearLayout;
       
    36 
       
    37 // Defines
       
    38 const QString KDocml = ":/ui/resource/fmradiohswidget.docml";
       
    39 const QString KCss = ":/ui/resource/fmradiohswidgetplugin.css";
       
    40 
       
    41 // Constants
       
    42 /**  Key for radio information hash. */
       
    43 const QString KRadioInformationStationName = "stationName";
       
    44 /**  Key for radio information hash. */
       
    45 const QString KRadioInformationCallSign = "callSign";
       
    46 /**  Key for radio information hash. */
       
    47 const QString KRadioInformationFrequency = "frequency";
       
    48 /**  Key for radio information hash. */
       
    49 const QString KRadioInformationRt = "rt";
       
    50 /**  Key for radio information hash. */
       
    51 const QString KRadioInformationDynamicPsName = "dynamicPsName";
       
    52 /**  Key for radio information hash. */
       
    53 const QString KRadioInformationPty = "pty";
       
    54 /**  Key for radio information hash. */
       
    55 const QString KRadioInformationHomePage = "homePage";
       
    56 /**  Key for radio information hash. */
       
    57 const QString KRadioInformationSong = "song";
       
    58 /**  Text to display in widget. */
       
    59 const QString KFmRadioText = "FM Radio";
       
    60 /**  Information text to connect headset. */
       
    61 const QString KConnectHeadsetText = "Connect wired headset.";
       
    62 /**  Mhz text. */
       
    63 const QString KMhzText = "Mhz";
       
    64 /**  DOCML object name for mainLayout */
       
    65 const QString KDocmlObjectNameMainLayout = "mainLayout";
       
    66 /**  DOCML object name for radioIconPushButton */
       
    67 const QString KDocmlObjectNameRadioIconPushButton = "radioIconPushButton";
       
    68 /**  DOCML object name for verticalSeparatorLabel */
       
    69 const QString KDocmlObjectNameVerticalSeparatorLabel = "verticalSeparatorLabel";
       
    70 /**  DOCML object name for controlAreaLayout */
       
    71 const QString KDocmlObjectNameControlAreaLayout = "controlAreaLayout";
       
    72 /**  DOCML object name for previousPushButton */
       
    73 const QString KDocmlObjectNamePreviousPushButton = "previousPushButton";
       
    74 /**  DOCML object name for verticalButtonSeparatorLabel1 */
       
    75 const QString KDocmlObjectNameVerticalButtonSeparatorLabel1 = "verticalButtonSeparatorLabel1";
       
    76 /**  DOCML object name for playPushButton */
       
    77 const QString KDocmlObjectNamePlayPushButton = "playPushButton";
       
    78 /**  DOCML object name for verticalButtonSeparatorLabel2 */
       
    79 const QString KDocmlObjectNameVerticalButtonSeparatorLabel2 = "verticalButtonSeparatorLabel2";
       
    80 /**  DOCML object name for nextPushButton */
       
    81 const QString KDocmlObjectNameNextPushButton = "nextPushButton";
       
    82 /**  DOCML object name for twoRowsLayout */
       
    83 const QString KDocmlObjectNameTwoRowsLayout = "twoRowsLayout";
       
    84 /**  DOCML object name for oneRowLayout */
       
    85 const QString KDocmlObjectNameOneRowLayout = "oneRowLayout";
       
    86 /**  DOCML object name for animationLayout */
       
    87 const QString KDocmlObjectNameAnimationLayout = "animationLayout";
       
    88 /**  DOCML object name for firstRowLabel */
       
    89 const QString KDocmlObjectNameFirstRowLabel = "firstRowLabel";
       
    90 /**  DOCML object name for secondRowLabel */
       
    91 const QString KDocmlObjectNameSecondRowLabel = "secondRowLabel";
       
    92 /**  DOCML object name for lonelyRowLabel */
       
    93 const QString KDocmlObjectNameLonelyRowLabel = "lonelyRowLabel";
       
    94 /**  DOCML object name for animationIcon */
       
    95 const QString KDocmlObjectNameAnimationIcon = "animationIcon";
       
    96 
       
    97 class FmRadioHsWidget : public HbWidget
       
    98 {
       
    99     Q_OBJECT
       
   100 
       
   101 public:
       
   102     FmRadioHsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
       
   103     ~FmRadioHsWidget();
       
   104 
       
   105     // enum for commands controlling FM Radio
       
   106     enum FmRadioControlCommand
       
   107     {
       
   108         Mute,
       
   109         Unmute,
       
   110         PreviousChannel,
       
   111         NextChannel
       
   112     };
       
   113 
       
   114     // enum for FM Radio states
       
   115     enum FmRadioState
       
   116     {
       
   117         Undefined,
       
   118         NotRunning,
       
   119         Starting,
       
   120         Running,
       
   121         ControllingAudio,
       
   122         NotControllingAudio,
       
   123         Seeking,
       
   124         AntennaNotConnected
       
   125     };
       
   126 
       
   127     // enum for information area layout states
       
   128     enum InformationAreaLayout
       
   129     {
       
   130         OneRow,
       
   131         TwoRows,
       
   132         Animation
       
   133     };
       
   134 
       
   135     // enum for control button states
       
   136     enum ControlButtonState
       
   137     {
       
   138         AllDisabledPlay,
       
   139         AllDisabledStop,
       
   140         ChannelsDisabledPlay,
       
   141         ChannelsDisabledStop,
       
   142         ChannelsEnabledPlay,
       
   143         ChannelsEnabledStop
       
   144     };
       
   145 
       
   146     // enum for control button states
       
   147     enum PlayButtonState
       
   148     {
       
   149         PlayDisabled,
       
   150         PlayEnabled,
       
   151         StopDisabled,
       
   152         StopEnabled
       
   153     };
       
   154     
       
   155     enum ControlButtonPosition
       
   156     {
       
   157         Left,
       
   158         Center,
       
   159         Right
       
   160     };
       
   161 
       
   162 public slots:
       
   163     //void onInitialize(); // Can be used in future to get on intialize event.
       
   164     void onShow();
       
   165     void onHide();
       
   166     //void onUninitialize(); // Can be used in future to get on unintialize event.
       
   167 
       
   168     bool eventFilter(QObject *target, QEvent *event);
       
   169     
       
   170 private slots:
       
   171     void load(const QString docml);
       
   172     
       
   173     void mute();
       
   174     void unMute();
       
   175     void previousChannel();
       
   176     void nextChannel();
       
   177     void radioToForeground();
       
   178     void radioToBackground();
       
   179     bool openUrl(QUrl url);
       
   180 
       
   181     void handleRadioInformationChange(int notificationId, QVariant value);
       
   182     bool updateRadioInformation(const QString informationType, QString information);
       
   183     void radioInformationChanged();
       
   184     void clearRadioInformation();
       
   185     void handleRadioStateChange(QVariant value);
       
   186     
       
   187     void changeInformationAreaLayout(InformationAreaLayout layout);
       
   188     void changeControlButtonState(ControlButtonState buttonState);
       
   189     void changePlayButtonState(PlayButtonState buttonState);
       
   190     void changeChannelButtonsEnabledState(bool enabled);
       
   191     void changeControlButtonFrameBackground(bool enabled, ControlButtonPosition position,
       
   192         HbPushButton *button);
       
   193     
       
   194 private:
       
   195     // Data
       
   196     Q_DISABLE_COPY(FmRadioHsWidget)
       
   197     
       
   198     HbPushButton *mRadioPushButton;
       
   199     HbLabel *mVerticalSeparatorLabel;
       
   200     HbPushButton *mPreviousPushButton;
       
   201     HbLabel *mVerticalButtonSeparatorLabel1;
       
   202     HbPushButton *mPlayPushButton;
       
   203     HbLabel *mVerticalButtonSeparatorLabel2;
       
   204     HbPushButton *mNextPushButton;
       
   205     QGraphicsWidget *mInformationAreaOneRowLayout;
       
   206     QGraphicsWidget *mInformationAreaTwoRowsLayout;
       
   207     QGraphicsWidget *mInformationAreaAnimationLayout;
       
   208     HbLabel *mInformationFirstRowLabel; // This should be maybe a HbLineEdit for displaying and receiving click on url's.
       
   209     //HbMarqueeItem *mInformationFirstRowMarquee;
       
   210     HbLabel *mInformationSecondRowLabel;// HbLineEdit may also support marquee/scrolling.
       
   211     //HbMarqueeItem *mInformationSecondRowMarquee;
       
   212     HbLabel *mInformationLonelyRowLabel;
       
   213     //HbMarqueeItem *mInformationLonelyRowMarquee;
       
   214     HbLabel *mAnimationIcon;
       
   215     
       
   216     FmRadioState mFmRadioState;
       
   217     PlayButtonState mPlayButtonState;
       
   218     bool mIsFavoriteChannels;
       
   219 
       
   220     QHash<QString, QString> mRadioInformation;  // Stores the radio information
       
   221     QString mRadioInformationFirstRow;
       
   222     QString mRadioInformationSecondRow;
       
   223 
       
   224     FmRadioHsWidgetProcessHandler *mProcessHandler; // For launching the FM Radio application
       
   225     FmRadioHsWidgetProfileReader *mProfileMonitor;
       
   226     
       
   227     FmRadioHsWidgetRadioServiceClient *mRadioServiceClient; // For communicating with the FM Radio through Qt Highway
       
   228     
       
   229 };
       
   230 
       
   231 #endif // FMRADIOHSWIDGET_H