equal
deleted
inserted
replaced
15 * |
15 * |
16 */ |
16 */ |
17 #include <QPainter> |
17 #include <QPainter> |
18 #include <QGraphicsSceneMouseEvent> |
18 #include <QGraphicsSceneMouseEvent> |
19 |
19 |
20 #include <hbinstantfeedback.h> |
|
21 |
20 |
22 #include "mpalbumcoverwidget.h" |
21 #include "mpalbumcoverwidget.h" |
|
22 #include "mpreflectioneffect.h" |
23 |
23 |
|
24 /*! |
|
25 \class MpAlbumCoverWidget |
|
26 \brief Album Cover Widget. |
|
27 |
|
28 This widget provides upscaled rendering of images and SVG rendering. |
|
29 Also there is a reflection effect. |
|
30 */ |
|
31 |
|
32 /*! |
|
33 \fn void clicked( ) |
|
34 |
|
35 This signal is emitted when the item is clicked. |
|
36 */ |
24 |
37 |
25 /*! |
38 /*! |
26 Constructs the album cover widget |
39 Constructs the album cover widget |
27 */ |
40 */ |
28 MpAlbumCoverWidget::MpAlbumCoverWidget( QGraphicsItem *parent ) : |
41 MpAlbumCoverWidget::MpAlbumCoverWidget( QGraphicsItem *parent ) : |
29 QGraphicsWidget( parent ) |
42 HbWidget( parent ) |
30 { |
43 { |
|
44 setFlag( QGraphicsItem::ItemHasNoContents, false ); |
31 grabGesture(Qt::TapGesture); |
45 grabGesture(Qt::TapGesture); |
32 grabGesture(Qt::SwipeGesture); |
46 |
|
47 MpReflectionEffect *effect = new MpReflectionEffect(this); |
|
48 setGraphicsEffect(effect); |
|
49 } |
|
50 |
|
51 /*! |
|
52 Destructs the album cover widget. |
|
53 */ |
|
54 MpAlbumCoverWidget::~MpAlbumCoverWidget() |
|
55 { |
33 } |
56 } |
34 |
57 |
35 /*! |
58 /*! |
36 Sets the \a icon as current album cover. |
59 Sets the \a icon as current album cover. |
37 */ |
60 */ |
56 */ |
79 */ |
57 void MpAlbumCoverWidget::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) |
80 void MpAlbumCoverWidget::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) |
58 { |
81 { |
59 Q_UNUSED( widget ) |
82 Q_UNUSED( widget ) |
60 Q_UNUSED( option ) |
83 Q_UNUSED( option ) |
61 //TODO: add a function to set default album art ,and use default when qicon is NULL, |
|
62 if ( !mIcon.isNull() ) { |
84 if ( !mIcon.isNull() ) { |
63 if ( mPixmap.isNull() ) { |
85 if ( mPixmap.isNull() ) { |
64 mPixmap = mIcon.qicon().pixmap( size().toSize() ); |
86 mPixmap = mIcon.qicon().pixmap( size().toSize() ); |
65 } |
87 } |
66 //We paint directly to stretch up/down if necesary. |
88 //We paint directly to stretch up/down if necesary. |
77 \reimp |
99 \reimp |
78 */ |
100 */ |
79 void MpAlbumCoverWidget::mousePressEvent( QGraphicsSceneMouseEvent *event ) |
101 void MpAlbumCoverWidget::mousePressEvent( QGraphicsSceneMouseEvent *event ) |
80 { |
102 { |
81 if ( event->button() == Qt::LeftButton ) { |
103 if ( event->button() == Qt::LeftButton ) { |
82 HbInstantFeedback::play( HbFeedback::Basic ); |
|
83 event->accept(); |
104 event->accept(); |
84 } |
105 } |
85 else { |
106 else { |
86 event->ignore(); |
107 event->ignore(); |
87 } |
108 } |
99 else { |
120 else { |
100 event->ignore(); |
121 event->ignore(); |
101 } |
122 } |
102 } |
123 } |
103 |
124 |
|
125 /*! |
|
126 \reimp |
|
127 */ |
|
128 void MpAlbumCoverWidget::gestureEvent(QGestureEvent *event) |
|
129 { |
|
130 QGesture* gesture = event->gesture(Qt::TapGesture); |
|
131 if (gesture) { |
|
132 event->accept(Qt::TapGesture); |
|
133 } |
|
134 } |
|
135 |
104 //EOF |
136 //EOF |