hswidgetplugin/fmradiohswidgetplugin/inc/fmradiohswidget.h
changeset 32 189d20c34778
parent 28 075425b8d9a4
child 33 11b6825f0862
equal deleted inserted replaced
28:075425b8d9a4 32:189d20c34778
     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 // Constants
       
    38 /** Path to docml file */
       
    39 const QString KDocml = ":/ui/resource/fmradiohswidget.docml";
       
    40 /** Path to css file */
       
    41 const QString KCss = ":/ui/resource/fmradiohswidgetplugin.css";
       
    42 /**  Key for radio information hash. */
       
    43 const QString KRadioInformationStationName = "stationName";
       
    44 /**  Key for radio information hash. */
       
    45 const QString KRadioInformationFrequency = "frequency";
       
    46 /**  Key for radio information hash. */
       
    47 const QString KRadioInformationRt = "rt";
       
    48 /**  Key for radio information hash. */
       
    49 const QString KRadioInformationDynamicPsName = "dynamicPsName";
       
    50 /**  Key for radio information hash. */
       
    51 const QString KRadioInformationPty = "pty";
       
    52 /**  DOCML object name for mainLayout */
       
    53 const QString KDocmlObjectNameMainLayout = "mainLayout";
       
    54 /**  DOCML object name for tunerBackgroundPushButton */
       
    55 const QString KDocmlObjectNameTunerBackgroundPushButton = "tunerBackgroundPushButton";
       
    56 /**  DOCML object name for tunerStackedLayout */
       
    57 const QString KDocmlObjectNameTunerStackedLayout = "tunerStackedLayout";
       
    58 /**  DOCML object name for tunerInformationStackedLayout */
       
    59 const QString KDocmlObjectNameTunerInformationStackedLayout = "tunerInformationStackedLayout";
       
    60 /**  DOCML object name for controlButtons */
       
    61 const QString KDocmlObjectNameContolButtonsLayout = "controlButtons";
       
    62 /**  DOCML object name for powerToggleButton */
       
    63 const QString KDocmlObjectNameowerToggleButton = "powerToggleButton";
       
    64 /**  DOCML object name for previousPushButton */
       
    65 const QString KDocmlObjectNamePreviousPushButton = "previousPushButton";
       
    66 /**  DOCML object name for nextPushButton */
       
    67 const QString KDocmlObjectNameNextPushButton = "nextPushButton";
       
    68 /**  DOCML object name for twoRowsLayout */
       
    69 const QString KDocmlObjectNameTwoRowsLayout = "twoRowsLayout";
       
    70 /**  DOCML object name for firstRowLabel */
       
    71 const QString KDocmlObjectNameFirstRowLabel = "firstRowLabel";
       
    72 /**  DOCML object name for secondRowLabel */
       
    73 const QString KDocmlObjectNameSecondRowLabel = "secondRowLabel";
       
    74 /**  DOCML object name for lonelyRowLabel */
       
    75 const QString KDocmlObjectNameLonelyRowLabel = "lonelyRowLabel";
       
    76 /**  DOCML object name for animationIcon */
       
    77 const QString KDocmlObjectNameAnimationIcon = "animationIcon";
       
    78 /** Delay which after the widget returns to the state where radio is not running. */
       
    79 const int KRadioStartingStateCancelDelay = 10000;
       
    80 
       
    81 class FmRadioHsWidget : public HbWidget
       
    82 {
       
    83     Q_OBJECT
       
    84     Q_PROPERTY(QString rootPath READ rootPath WRITE setRootPath)
       
    85 public:
       
    86     FmRadioHsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
       
    87     ~FmRadioHsWidget();
       
    88 
       
    89 public:
       
    90     // Enum for commands controlling FM Radio.
       
    91     enum FmRadioControlCommand
       
    92     {
       
    93         Mute,
       
    94         Unmute,
       
    95         PreviousChannel,
       
    96         NextChannel
       
    97     };
       
    98 
       
    99     // Enum for FM Radio states.
       
   100     enum FmRadioState
       
   101     {
       
   102         Undefined,
       
   103         NotRunning,
       
   104         Starting,
       
   105         Running,
       
   106         ControllingAudio,
       
   107         NotControllingAudio,
       
   108         Seeking,
       
   109         AntennaNotConnected,
       
   110         Closing
       
   111     };
       
   112 
       
   113     // Enum for information area layout states.
       
   114     enum InformationAreaLayout
       
   115     {
       
   116         OneRow,
       
   117         TwoRows,
       
   118         Animation
       
   119     };
       
   120 
       
   121     // Enum for control button position.
       
   122     enum ControlButtonPosition
       
   123     {
       
   124         Left,
       
   125         Center,
       
   126         Right
       
   127     };
       
   128     
       
   129     QString rootPath()const;
       
   130     void setRootPath(const QString &rootPath);
       
   131 
       
   132 public slots:
       
   133     void onInitialize();
       
   134     void onShow();
       
   135     void onHide();
       
   136     //void onUninitialize(); // Can be used in future to get on unintialize event.
       
   137 
       
   138 private slots:
       
   139     void load(const QString &docml);
       
   140     void closeRadio();
       
   141     void previousChannel();
       
   142     void nextChannel();
       
   143     void radioToForeground();
       
   144     void radioToBackground();
       
   145 
       
   146     void handleRadioInformationChange(const int notificationId,
       
   147         const QVariant &value);
       
   148     bool updateRadioInformation(const QString &informationType,
       
   149         const QString &information);
       
   150     void radioInformationChanged();
       
   151     void clearRadioInformation();
       
   152     void handleRadioStateChange(const QVariant &value);
       
   153     
       
   154     void changeInformationAreaLayout(const InformationAreaLayout layout);
       
   155     void changePowerButtonOn(const bool isPowerOn);
       
   156     void changeStationButtonsEnabledState(const bool enabled);
       
   157     void changeControlButtonFrameBackground(const bool enabled,
       
   158         const ControlButtonPosition position, HbPushButton *button);
       
   159     
       
   160     void cancelRadioStartingState();
       
   161     void stopRadioStartingCancelTimer();
       
   162     
       
   163 private:
       
   164     // Data
       
   165     Q_DISABLE_COPY(FmRadioHsWidget)
       
   166     
       
   167     QString mRootPath;
       
   168     
       
   169     // UI components.
       
   170     HbPushButton *mRadioPushButton;
       
   171     HbPushButton *mTunerBackgroundPushButton;
       
   172     HbPushButton *mPowerToggleButton;
       
   173     HbPushButton *mPreviousPushButton;
       
   174     HbPushButton *mNextPushButton;
       
   175     QGraphicsWidget *mInformationAreaTwoRowsLayout;
       
   176     HbLabel *mInformationFirstRowLabel;
       
   177     HbLabel *mInformationSecondRowLabel;
       
   178     HbLabel *mInformationLonelyRowLabel;
       
   179     HbLabel *mAnimationIcon;
       
   180     
       
   181     // Stores the state of the FM Radio application.
       
   182     FmRadioState mFmRadioState;
       
   183     // Stores the presence of favorite stations.
       
   184     bool mFavoriteStations;
       
   185 
       
   186     // Stores the radio information.
       
   187     QHash<QString, QString> mRadioInformation;
       
   188     QString mRadioInformationFirstRow;
       
   189     QString mRadioInformationSecondRow;
       
   190 
       
   191     // For reading P&S keys.
       
   192     FmRadioHsWidgetProfileReader *mProfileMonitor;
       
   193     
       
   194     // For communicating with the FM Radio through Qt Highway.
       
   195     FmRadioHsWidgetRadioServiceClient *mRadioServiceClient;
       
   196     
       
   197     // For cancelinf the starting state after a delay.
       
   198     QTimer *mRadioStartingCancelTimer;
       
   199     
       
   200 };
       
   201 
       
   202 #endif // FMRADIOHSWIDGET_H