hswidgetplugin/fmradiohswidgetplugin/inc/fmradiohswidget.h
changeset 28 075425b8d9a4
parent 24 6df133bd92e1
equal deleted inserted replaced
24:6df133bd92e1 28:075425b8d9a4
    32 class XQSettingsKey;
    32 class XQSettingsKey;
    33 class FmRadioHsWidgetProcessHandler;
    33 class FmRadioHsWidgetProcessHandler;
    34 class FmRadioHsWidgetProfileReader;
    34 class FmRadioHsWidgetProfileReader;
    35 class QGraphicsLinearLayout;
    35 class QGraphicsLinearLayout;
    36 
    36 
    37 // Defines
    37 // Constants
       
    38 /** Path to docml file */
    38 const QString KDocml = ":/ui/resource/fmradiohswidget.docml";
    39 const QString KDocml = ":/ui/resource/fmradiohswidget.docml";
       
    40 /** Path to css file */
    39 const QString KCss = ":/ui/resource/fmradiohswidgetplugin.css";
    41 const QString KCss = ":/ui/resource/fmradiohswidgetplugin.css";
    40 
       
    41 // Constants
       
    42 /**  Key for radio information hash. */
    42 /**  Key for radio information hash. */
    43 const QString KRadioInformationStationName = "stationName";
    43 const QString KRadioInformationStationName = "stationName";
    44 /**  Key for radio information hash. */
    44 /**  Key for radio information hash. */
    45 const QString KRadioInformationCallSign = "callSign";
       
    46 /**  Key for radio information hash. */
       
    47 const QString KRadioInformationFrequency = "frequency";
    45 const QString KRadioInformationFrequency = "frequency";
    48 /**  Key for radio information hash. */
    46 /**  Key for radio information hash. */
    49 const QString KRadioInformationRt = "rt";
    47 const QString KRadioInformationRt = "rt";
    50 /**  Key for radio information hash. */
    48 /**  Key for radio information hash. */
    51 const QString KRadioInformationDynamicPsName = "dynamicPsName";
    49 const QString KRadioInformationDynamicPsName = "dynamicPsName";
    52 /**  Key for radio information hash. */
    50 /**  Key for radio information hash. */
    53 const QString KRadioInformationPty = "pty";
    51 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 */
    52 /**  DOCML object name for mainLayout */
    65 const QString KDocmlObjectNameMainLayout = "mainLayout";
    53 const QString KDocmlObjectNameMainLayout = "mainLayout";
    66 /**  DOCML object name for radioIconPushButton */
    54 /**  DOCML object name for tunerBackgroundPushButton */
    67 const QString KDocmlObjectNameRadioIconPushButton = "radioIconPushButton";
    55 const QString KDocmlObjectNameTunerBackgroundPushButton = "tunerBackgroundPushButton";
    68 /**  DOCML object name for verticalSeparatorLabel */
    56 /**  DOCML object name for tunerStackedLayout */
    69 const QString KDocmlObjectNameVerticalSeparatorLabel = "verticalSeparatorLabel";
    57 const QString KDocmlObjectNameTunerStackedLayout = "tunerStackedLayout";
    70 /**  DOCML object name for controlAreaLayout */
    58 /**  DOCML object name for tunerInformationStackedLayout */
    71 const QString KDocmlObjectNameControlAreaLayout = "controlAreaLayout";
    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";
    72 /**  DOCML object name for previousPushButton */
    64 /**  DOCML object name for previousPushButton */
    73 const QString KDocmlObjectNamePreviousPushButton = "previousPushButton";
    65 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 */
    66 /**  DOCML object name for nextPushButton */
    81 const QString KDocmlObjectNameNextPushButton = "nextPushButton";
    67 const QString KDocmlObjectNameNextPushButton = "nextPushButton";
    82 /**  DOCML object name for twoRowsLayout */
    68 /**  DOCML object name for twoRowsLayout */
    83 const QString KDocmlObjectNameTwoRowsLayout = "twoRowsLayout";
    69 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 */
    70 /**  DOCML object name for firstRowLabel */
    89 const QString KDocmlObjectNameFirstRowLabel = "firstRowLabel";
    71 const QString KDocmlObjectNameFirstRowLabel = "firstRowLabel";
    90 /**  DOCML object name for secondRowLabel */
    72 /**  DOCML object name for secondRowLabel */
    91 const QString KDocmlObjectNameSecondRowLabel = "secondRowLabel";
    73 const QString KDocmlObjectNameSecondRowLabel = "secondRowLabel";
    92 /**  DOCML object name for lonelyRowLabel */
    74 /**  DOCML object name for lonelyRowLabel */
    93 const QString KDocmlObjectNameLonelyRowLabel = "lonelyRowLabel";
    75 const QString KDocmlObjectNameLonelyRowLabel = "lonelyRowLabel";
    94 /**  DOCML object name for animationIcon */
    76 /**  DOCML object name for animationIcon */
    95 const QString KDocmlObjectNameAnimationIcon = "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;
    96 
    80 
    97 class FmRadioHsWidget : public HbWidget
    81 class FmRadioHsWidget : public HbWidget
    98 {
    82 {
    99     Q_OBJECT
    83     Q_OBJECT
   100 
    84     Q_PROPERTY(QString rootPath READ rootPath WRITE setRootPath)
   101 public:
    85 public:
   102     FmRadioHsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
    86     FmRadioHsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
   103     ~FmRadioHsWidget();
    87     ~FmRadioHsWidget();
   104 
    88 
   105     // enum for commands controlling FM Radio
    89 public:
       
    90     // Enum for commands controlling FM Radio.
   106     enum FmRadioControlCommand
    91     enum FmRadioControlCommand
   107     {
    92     {
   108         Mute,
    93         Mute,
   109         Unmute,
    94         Unmute,
   110         PreviousChannel,
    95         PreviousChannel,
   111         NextChannel
    96         NextChannel
   112     };
    97     };
   113 
    98 
   114     // enum for FM Radio states
    99     // Enum for FM Radio states.
   115     enum FmRadioState
   100     enum FmRadioState
   116     {
   101     {
   117         Undefined,
   102         Undefined,
   118         NotRunning,
   103         NotRunning,
   119         Starting,
   104         Starting,
   120         Running,
   105         Running,
   121         ControllingAudio,
   106         ControllingAudio,
   122         NotControllingAudio,
   107         NotControllingAudio,
   123         Seeking,
   108         Seeking,
   124         AntennaNotConnected
   109         AntennaNotConnected,
   125     };
   110         Closing
   126 
   111     };
   127     // enum for information area layout states
   112 
       
   113     // Enum for information area layout states.
   128     enum InformationAreaLayout
   114     enum InformationAreaLayout
   129     {
   115     {
   130         OneRow,
   116         OneRow,
   131         TwoRows,
   117         TwoRows,
   132         Animation
   118         Animation
   133     };
   119     };
   134 
   120 
   135     // enum for control button states
   121     // Enum for control button position.
   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
   122     enum ControlButtonPosition
   156     {
   123     {
   157         Left,
   124         Left,
   158         Center,
   125         Center,
   159         Right
   126         Right
   160     };
   127     };
       
   128     
       
   129     QString rootPath()const;
       
   130     void setRootPath(const QString &rootPath);
   161 
   131 
   162 public slots:
   132 public slots:
   163     //void onInitialize(); // Can be used in future to get on intialize event.
   133     void onInitialize();
   164     void onShow();
   134     void onShow();
   165     void onHide();
   135     void onHide();
   166     //void onUninitialize(); // Can be used in future to get on unintialize event.
   136     //void onUninitialize(); // Can be used in future to get on unintialize event.
   167 
   137 
   168     bool eventFilter(QObject *target, QEvent *event);
       
   169     
       
   170 private slots:
   138 private slots:
   171     void load(const QString docml);
   139     void load(const QString &docml);
   172     
   140     void closeRadio();
   173     void mute();
       
   174     void unMute();
       
   175     void previousChannel();
   141     void previousChannel();
   176     void nextChannel();
   142     void nextChannel();
   177     void radioToForeground();
   143     void radioToForeground();
   178     void radioToBackground();
   144     void radioToBackground();
   179     bool openUrl(QUrl url);
   145 
   180 
   146     void handleRadioInformationChange(const int notificationId,
   181     void handleRadioInformationChange(int notificationId, QVariant value);
   147         const QVariant &value);
   182     bool updateRadioInformation(const QString informationType, QString information);
   148     bool updateRadioInformation(const QString &informationType,
       
   149         const QString &information);
   183     void radioInformationChanged();
   150     void radioInformationChanged();
   184     void clearRadioInformation();
   151     void clearRadioInformation();
   185     void handleRadioStateChange(QVariant value);
   152     void handleRadioStateChange(const QVariant &value);
   186     
   153     
   187     void changeInformationAreaLayout(InformationAreaLayout layout);
   154     void changeInformationAreaLayout(const InformationAreaLayout layout);
   188     void changeControlButtonState(ControlButtonState buttonState);
   155     void changePowerButtonOn(const bool isPowerOn);
   189     void changePlayButtonState(PlayButtonState buttonState);
   156     void changeStationButtonsEnabledState(const bool enabled);
   190     void changeChannelButtonsEnabledState(bool enabled);
   157     void changeControlButtonFrameBackground(const bool enabled,
   191     void changeControlButtonFrameBackground(bool enabled, ControlButtonPosition position,
   158         const ControlButtonPosition position, HbPushButton *button);
   192         HbPushButton *button);
   159     
       
   160     void cancelRadioStartingState();
       
   161     void stopRadioStartingCancelTimer();
   193     
   162     
   194 private:
   163 private:
   195     // Data
   164     // Data
   196     Q_DISABLE_COPY(FmRadioHsWidget)
   165     Q_DISABLE_COPY(FmRadioHsWidget)
   197     
   166     
       
   167     QString mRootPath;
       
   168     
       
   169     // UI components.
   198     HbPushButton *mRadioPushButton;
   170     HbPushButton *mRadioPushButton;
   199     HbLabel *mVerticalSeparatorLabel;
   171     HbPushButton *mTunerBackgroundPushButton;
       
   172     HbPushButton *mPowerToggleButton;
   200     HbPushButton *mPreviousPushButton;
   173     HbPushButton *mPreviousPushButton;
   201     HbLabel *mVerticalButtonSeparatorLabel1;
       
   202     HbPushButton *mPlayPushButton;
       
   203     HbLabel *mVerticalButtonSeparatorLabel2;
       
   204     HbPushButton *mNextPushButton;
   174     HbPushButton *mNextPushButton;
   205     QGraphicsWidget *mInformationAreaOneRowLayout;
       
   206     QGraphicsWidget *mInformationAreaTwoRowsLayout;
   175     QGraphicsWidget *mInformationAreaTwoRowsLayout;
   207     QGraphicsWidget *mInformationAreaAnimationLayout;
   176     HbLabel *mInformationFirstRowLabel;
   208     HbLabel *mInformationFirstRowLabel; // This should be maybe a HbLineEdit for displaying and receiving click on url's.
   177     HbLabel *mInformationSecondRowLabel;
   209     //HbMarqueeItem *mInformationFirstRowMarquee;
       
   210     HbLabel *mInformationSecondRowLabel;// HbLineEdit may also support marquee/scrolling.
       
   211     //HbMarqueeItem *mInformationSecondRowMarquee;
       
   212     HbLabel *mInformationLonelyRowLabel;
   178     HbLabel *mInformationLonelyRowLabel;
   213     //HbMarqueeItem *mInformationLonelyRowMarquee;
       
   214     HbLabel *mAnimationIcon;
   179     HbLabel *mAnimationIcon;
   215     
   180     
       
   181     // Stores the state of the FM Radio application.
   216     FmRadioState mFmRadioState;
   182     FmRadioState mFmRadioState;
   217     PlayButtonState mPlayButtonState;
   183     // Stores the presence of favorite stations.
   218     bool mIsFavoriteChannels;
   184     bool mFavoriteStations;
   219 
   185 
   220     QHash<QString, QString> mRadioInformation;  // Stores the radio information
   186     // Stores the radio information.
       
   187     QHash<QString, QString> mRadioInformation;
   221     QString mRadioInformationFirstRow;
   188     QString mRadioInformationFirstRow;
   222     QString mRadioInformationSecondRow;
   189     QString mRadioInformationSecondRow;
   223 
   190 
   224     FmRadioHsWidgetProcessHandler *mProcessHandler; // For launching the FM Radio application
   191     // For reading P&S keys.
   225     FmRadioHsWidgetProfileReader *mProfileMonitor;
   192     FmRadioHsWidgetProfileReader *mProfileMonitor;
   226     
   193     
   227     FmRadioHsWidgetRadioServiceClient *mRadioServiceClient; // For communicating with the FM Radio through Qt Highway
   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;
   228     
   199     
   229 };
   200 };
   230 
   201 
   231 #endif // FMRADIOHSWIDGET_H
   202 #endif // FMRADIOHSWIDGET_H