21 #include <hblabel.h> |
21 #include <hblabel.h> |
22 #include <hbicon.h> |
22 #include <hbicon.h> |
23 #include <hbiconitem.h> |
23 #include <hbiconitem.h> |
24 #include <hbdocumentloader.h> |
24 #include <hbdocumentloader.h> |
25 #include <hbinstance.h> |
25 #include <hbinstance.h> |
|
26 #include <hbcolorscheme.h> |
26 |
27 |
27 #include "mpnowplayingwidget_p.h" |
28 #include "mpnowplayingwidget_p.h" |
28 #include "mpnowplayingwidget.h" |
29 #include "mpnowplayingwidget.h" |
29 #include "mpnowplayingbackend.h" |
30 #include "mpnowplayingbackend.h" |
30 #include "mptrace.h" |
31 #include "mptrace.h" |
55 { |
56 { |
56 TX_ENTRY_ARGS( "Player ID =" << playerId << " Q pointer=" << ( void * )qq ) |
57 TX_ENTRY_ARGS( "Player ID =" << playerId << " Q pointer=" << ( void * )qq ) |
57 QGraphicsWidget *widget; |
58 QGraphicsWidget *widget; |
58 bool widgetsOk = false; |
59 bool widgetsOk = false; |
59 |
60 |
60 |
61 //TODO final color resources should be qtc_multimedia_trans_normal when available |
61 mPlayIcon = new HbIcon( QString(":/icons/play.png")); |
62 QColor normalColor( HbColorScheme::color("foreground") ); |
62 mPauseIcon = new HbIcon( QString(":/icons/pause.png")); |
63 //TODO final color resources should be qtc_multimedia_trans_pressed when available |
|
64 QColor pressedColor( HbColorScheme::color("popupbackground") ); |
|
65 |
|
66 mPlayIconNormal = new HbIcon( QString("qtg_mono_play")); |
|
67 mPlayIconNormal->setColor( normalColor ); |
|
68 mPauseIconNormal = new HbIcon( QString("qtg_mono_pause")); |
|
69 mPauseIconNormal->setColor( normalColor ); |
|
70 |
|
71 mPlayIconPressed = new HbIcon( QString("qtg_mono_play")); |
|
72 mPlayIconPressed->setColor( pressedColor ); |
|
73 mPauseIconPressed = new HbIcon( QString("qtg_mono_pause")); |
|
74 mPauseIconPressed->setColor( pressedColor ); |
63 |
75 |
64 mDocumentLoader = new HbDocumentLoader(); |
76 mDocumentLoader = new HbDocumentLoader(); |
65 if (mDocumentLoader) { |
77 if (mDocumentLoader) { |
66 mDocumentLoader->load( NOW_PLAYING_XML, &widgetsOk); |
78 mDocumentLoader->load( NOW_PLAYING_XML, &widgetsOk); |
67 } |
79 } |
73 HbWidget* container = qobject_cast<HbWidget*>(widget); |
85 HbWidget* container = qobject_cast<HbWidget*>(widget); |
74 container->setParentItem(q_ptr); |
86 container->setParentItem(q_ptr); |
75 |
87 |
76 widget = mDocumentLoader->findWidget(QString("primaryText")); |
88 widget = mDocumentLoader->findWidget(QString("primaryText")); |
77 mPrimaryText = qobject_cast<HbLabel*>(widget); |
89 mPrimaryText = qobject_cast<HbLabel*>(widget); |
|
90 //TODO final color resource should be qtc_multimedia_trans_normal when available |
|
91 mPrimaryText->setTextColor( normalColor ); |
|
92 |
78 |
93 |
79 widget = mDocumentLoader->findWidget(QString("secondaryText")); |
94 widget = mDocumentLoader->findWidget(QString("secondaryText")); |
80 mSecondaryText = qobject_cast<HbLabel*>(widget); |
95 mSecondaryText = qobject_cast<HbLabel*>(widget); |
81 |
96 //TODO final color resource should be qtc_multimedia_trans_normal when available |
|
97 mSecondaryText->setTextColor( normalColor ); |
|
98 |
82 widget = mDocumentLoader->findWidget(QString("playPause")); |
99 widget = mDocumentLoader->findWidget(QString("playPause")); |
83 mIcon = qobject_cast<HbLabel*>(widget); |
100 mIcon = qobject_cast<HbLabel*>(widget); |
84 |
101 |
85 HbStackedLayout *mylayout; |
102 HbStackedLayout *mylayout; |
86 mylayout = new HbStackedLayout(q_ptr); |
103 mylayout = new HbStackedLayout(q_ptr); |
155 else { |
174 else { |
156 return false; |
175 return false; |
157 } |
176 } |
158 } |
177 } |
159 |
178 |
|
179 /*! |
|
180 \internal |
|
181 Changes text and icon color when \a pressed |
|
182 */ |
|
183 void MpNowPlayingWidgetPrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event, bool pressed) |
|
184 { |
|
185 //TODO final color resources should be qtc_multimedia_trans_pressed when available |
|
186 QColor pressedColor( HbColorScheme::color("popupbackground") ); |
|
187 //TODO final color resources should be qtc_multimedia_trans_normal when available |
|
188 QColor normalColor( HbColorScheme::color("foreground") ); |
|
189 |
|
190 if( mIcon->windowFrameGeometry().contains( event->pos() ) && pressed) { |
|
191 if ( mState == Playing ) { |
|
192 mIcon->setIcon( *mPauseIconPressed ); |
|
193 } |
|
194 else { |
|
195 mIcon->setIcon( *mPlayIconPressed ); |
|
196 } |
|
197 } |
|
198 else if( q_ptr->rect().contains( event->pos() ) && pressed ){ |
|
199 mPrimaryText->setTextColor( pressedColor ); |
|
200 mSecondaryText->setTextColor( pressedColor ); |
|
201 } |
|
202 else { |
|
203 mPrimaryText->setTextColor( normalColor ); |
|
204 mSecondaryText->setTextColor( normalColor ); |
|
205 if( mState == Playing){ |
|
206 mIcon->setIcon( *mPauseIconNormal ); |
|
207 } |
|
208 else{ |
|
209 mIcon->setIcon( *mPlayIconNormal ); |
|
210 } |
|
211 } |
|
212 } |
|
213 |
|
214 /*! |
|
215 \internal |
|
216 Handles theme change |
|
217 */ |
|
218 void MpNowPlayingWidgetPrivate::handleThemeChange() |
|
219 { |
|
220 //TODO final color resources should be qtc_multimedia_trans_pressed when available |
|
221 QColor pressedColor( HbColorScheme::color("popupbackground") ); |
|
222 //TODO final color resources should be qtc_multimedia_trans_normal when available |
|
223 QColor normalColor( HbColorScheme::color("foreground") ); |
|
224 |
|
225 mPrimaryText->setTextColor( normalColor ); |
|
226 mSecondaryText->setTextColor( normalColor ); |
|
227 mPauseIconNormal->setColor( normalColor ); |
|
228 mPlayIconNormal->setColor( normalColor ); |
|
229 mPauseIconPressed->setColor( pressedColor ); |
|
230 mPlayIconPressed->setColor( pressedColor ); |
|
231 |
|
232 if( mState == Playing){ |
|
233 mIcon->setIcon( *mPauseIconNormal ); |
|
234 } |
|
235 else{ |
|
236 mIcon->setIcon( *mPlayIconNormal ); |
|
237 } |
|
238 } |
160 |
239 |
161 /*! |
240 /*! |
162 \internal |
241 \internal |
163 Sets the simplified playback \a state. |
242 Sets the simplified playback \a state. |
164 */ |
243 */ |
169 case NotPlaying: |
248 case NotPlaying: |
170 if ( mState != NotPlaying ) |
249 if ( mState != NotPlaying ) |
171 emit q_ptr->playbackAttachmentChanged( false ); |
250 emit q_ptr->playbackAttachmentChanged( false ); |
172 break; |
251 break; |
173 case Playing: |
252 case Playing: |
174 mIcon->setIcon(*mPauseIcon); |
253 mIcon->setIcon(*mPauseIconNormal); |
175 if (mState == NotPlaying) |
254 if (mState == NotPlaying) |
176 emit q_ptr->playbackAttachmentChanged( true ); |
255 emit q_ptr->playbackAttachmentChanged( true ); |
177 break; |
256 break; |
178 case Paused: |
257 case Paused: |
179 mIcon->setIcon(*mPlayIcon); |
258 mIcon->setIcon(*mPlayIconNormal); |
180 if (mState == NotPlaying) |
259 if (mState == NotPlaying) |
181 emit q_ptr->playbackAttachmentChanged( true ); |
260 emit q_ptr->playbackAttachmentChanged( true ); |
182 break; |
261 break; |
183 default: |
262 default: |
184 break; |
263 break; |