|
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: Music Player now playing widget. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QPainter> |
|
19 #include <QGraphicsSceneMouseEvent> |
|
20 |
|
21 #include <hbicon.h> |
|
22 |
|
23 #include "mpnowplayingwidget.h" |
|
24 #include "mpnowplayingwidget_p.h" |
|
25 #include "mptrace.h" |
|
26 |
|
27 /*! |
|
28 \class MpNowPlayingWidget |
|
29 \brief Custom HB widget that displays currently playing song information. |
|
30 |
|
31 This is a composite widget made out of HB widgets, it displays information |
|
32 for the current playing song on the playback engine indicated at |
|
33 construction time. |
|
34 */ |
|
35 |
|
36 /*! |
|
37 \fn MpNowPlayingWidget::clicked() |
|
38 |
|
39 MpNowPlayingWidget emits this signal when there is a mouseReleaseEvent on |
|
40 top of the widget. |
|
41 */ |
|
42 |
|
43 /*! |
|
44 \fn MpNowPlayingWidget::playbackAttachmentChanged(bool attached) |
|
45 |
|
46 MpNowPlayingWidget emits this signal with a true value if the widget is |
|
47 ready to display relevant data for the current playback, it is emmited |
|
48 with false value if there is not playback instance to bind with. It is |
|
49 recommended to use this signal to place and remove the widget from the UI. |
|
50 */ |
|
51 |
|
52 |
|
53 /*! |
|
54 Constructs the now playing widget. |
|
55 */ |
|
56 MpNowPlayingWidget::MpNowPlayingWidget(long int playerId, QGraphicsItem *parent ) |
|
57 : HbWidget(parent), |
|
58 d_ptr ( new MpNowPlayingWidgetPrivate( playerId, this ) ) |
|
59 { |
|
60 TX_ENTRY_ARGS( "Player ID =" << playerId << " Parent=" << (void *)parent ) |
|
61 TX_EXIT |
|
62 } |
|
63 |
|
64 /*! |
|
65 Destructs the now playing widget. |
|
66 */ |
|
67 MpNowPlayingWidget::~MpNowPlayingWidget() |
|
68 { |
|
69 TX_ENTRY |
|
70 delete d_ptr; |
|
71 TX_EXIT |
|
72 } |
|
73 |
|
74 /*! |
|
75 If \a enabled is true, the item is enabled; otherwise, it is disabled. |
|
76 Item is enabled by default. |
|
77 */ |
|
78 void MpNowPlayingWidget::setEnabled( bool enabled ) |
|
79 { |
|
80 d_ptr->setEnabled(enabled); |
|
81 } |
|
82 |
|
83 /*! |
|
84 \reimp |
|
85 */ |
|
86 void MpNowPlayingWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
87 { |
|
88 TX_ENTRY |
|
89 HbWidget::paint(painter, option, widget); |
|
90 QColor color(105,105,105,255); |
|
91 painter->fillRect(rect(), color); |
|
92 TX_EXIT |
|
93 } |
|
94 |
|
95 /*! |
|
96 \reimp |
|
97 */ |
|
98 void MpNowPlayingWidget::mousePressEvent( QGraphicsSceneMouseEvent *event ) |
|
99 { |
|
100 TX_ENTRY |
|
101 if ( event->button() == Qt::LeftButton ) { |
|
102 event->accept(); |
|
103 } |
|
104 else { |
|
105 event->ignore(); |
|
106 } |
|
107 TX_EXIT |
|
108 } |
|
109 |
|
110 /*! |
|
111 \reimp |
|
112 */ |
|
113 void MpNowPlayingWidget::mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) |
|
114 { |
|
115 TX_ENTRY |
|
116 if ( event->button() == Qt::LeftButton ) { |
|
117 if ( !d_ptr->handleClickEvent( event ) && rect().contains( event->pos() ) ) { |
|
118 emit clicked(); |
|
119 } |
|
120 event->accept(); |
|
121 } |
|
122 else { |
|
123 event->ignore(); |
|
124 } |
|
125 TX_EXIT |
|
126 } |
|
127 |