src/hbinput/inputwidgets/hbinputscreenshotwidget.cpp
changeset 6 c3690ec91ef8
parent 5 627c4a0fd0e7
child 7 923ff622b8b9
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    20 **
    20 **
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
       
    25 #include "hbinputscreenshotwidget.h"
       
    26 
    25 #include <QPixmap>
    27 #include <QPixmap>
    26 #include <QPainter>
    28 #include <QPainter>
    27 
    29 
    28 #include <hbeffect.h>
    30 #include <hbeffect.h>
    29 #include <hbwidget_p.h>
    31 #include <hbwidget_p.h>
    30 #include <hbinputregioncollector_p.h>
    32 #include <hbinputregioncollector_p.h>
    31 #include "hbframedrawerpool_p.h"
    33 #include "hbframedrawerpool_p.h"
    32 
    34 
    33 
       
    34 #include "hbinputscreenshotwidget.h"
       
    35 #include "hbinputvkbwidget.h"
    35 #include "hbinputvkbwidget.h"
    36 
       
    37 
    36 
    38 /*!
    37 /*!
    39 @proto
    38 @proto
    40 @hbinput
    39 @hbinput
    41 \class HbInputVkbWidget
    40 \class HbInputVkbWidget
    64     qreal mCloseHandleWidth;
    63     qreal mCloseHandleWidth;
    65 
    64 
    66 };
    65 };
    67 
    66 
    68 HbInputScreenshotWidgetPrivate::HbInputScreenshotWidgetPrivate()
    67 HbInputScreenshotWidgetPrivate::HbInputScreenshotWidgetPrivate()
    69  : mIconDrawer(0), mCloseHandleHeight(0), mCloseHandleWidth(0)
    68     : mIconDrawer(0), mCloseHandleHeight(0), mCloseHandleWidth(0)
    70 {
    69 {
    71 }
    70 }
    72 
    71 
    73 HbInputScreenshotWidgetPrivate::~HbInputScreenshotWidgetPrivate()
    72 HbInputScreenshotWidgetPrivate::~HbInputScreenshotWidgetPrivate()
    74 {
    73 {
    79 /// @endcond
    78 /// @endcond
    80 
    79 
    81 /*!
    80 /*!
    82 Costructs the object.
    81 Costructs the object.
    83 */
    82 */
    84 HbInputScreenshotWidget::HbInputScreenshotWidget(QGraphicsItem* parent)
    83 HbInputScreenshotWidget::HbInputScreenshotWidget(QGraphicsItem *parent)
    85     : HbWidget(*new HbInputScreenshotWidgetPrivate, parent)
    84     : HbWidget(*new HbInputScreenshotWidgetPrivate, parent)
    86 {
    85 {
    87     Q_D(HbInputScreenshotWidget);
    86     Q_D(HbInputScreenshotWidget);
    88     d->q_ptr = this;
    87     d->q_ptr = this;
    89     HbInputRegionCollector::instance()->attach(this);
    88     HbInputRegionCollector::instance()->attach(this);
    90 
    89 
    91     setPos(QPointF(0,0));
    90     setPos(QPointF(0, 0));
    92 
    91 
    93 #ifdef HB_EFFECTS
    92 #ifdef HB_EFFECTS
    94     HbEffect::disable(this);
    93     HbEffect::disable(this);
    95 #endif // HB_EFFECTS
    94 #endif // HB_EFFECTS
    96 
    95 
    97 #if QT_VERSION >= 0x040600
       
    98     // Make sure the keypad never steals focus.
    96     // Make sure the keypad never steals focus.
    99     setFlag(QGraphicsItem::ItemIsPanel, true);
    97     setFlag(QGraphicsItem::ItemIsPanel, true);
   100     setActive(false);
    98     setActive(false);
   101 #endif
    99     setFlag(QGraphicsItem::ItemHasNoContents, false);
   102 }
   100 }
   103 
   101 
   104 /*!
   102 /*!
   105 Destructs the object.
   103 Destructs the object.
   106 */
   104 */
   107 HbInputScreenshotWidget::~HbInputScreenshotWidget()
   105 HbInputScreenshotWidget::~HbInputScreenshotWidget()
   108 { 
   106 {
   109 }
   107 }
   110 
   108 
   111 void HbInputScreenshotWidget::setScreenshot(QPixmap &pixmap)
   109 void HbInputScreenshotWidget::setScreenshot(QPixmap &pixmap)
   112 {
   110 {
   113     Q_D(HbInputScreenshotWidget);
   111     Q_D(HbInputScreenshotWidget);
   125 }
   123 }
   126 
   124 
   127 /*!
   125 /*!
   128 handles mouse press event.
   126 handles mouse press event.
   129 */
   127 */
   130 void HbInputScreenshotWidget::mousePressEvent(QGraphicsSceneMouseEvent* event)
   128 void HbInputScreenshotWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
   131 {
   129 {
   132     Q_UNUSED(event);
   130     Q_UNUSED(event);
   133 }
   131 }
   134 
   132 
   135 /*!
   133 /*!
   136 Handles mouse release event.
   134 Handles mouse release event.
   137 */
   135 */
   138 void HbInputScreenshotWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
   136 void HbInputScreenshotWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   139 {
   137 {
   140     Q_UNUSED(event);
   138     Q_UNUSED(event);
   141 }
   139 }
   142 
   140 
   143 /*!
   141 /*!
   144 The paint method. Draws the widget.
   142 The paint method. Draws the widget.
   145 */
   143 */
   146 void HbInputScreenshotWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
   144 void HbInputScreenshotWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
   147 {
   145 {
   148     Q_UNUSED(option);
   146     Q_UNUSED(option);
   149     Q_UNUSED(widget);
   147     Q_UNUSED(widget);
   150 
   148 
   151     Q_D(HbInputScreenshotWidget);
   149     Q_D(HbInputScreenshotWidget);
   152     if (!d->mPixmap.isNull()){
   150     if (!d->mPixmap.isNull()) {
   153         QRectF rect = boundingRect();
   151         QRectF rect = boundingRect();
   154 
   152 
   155         painter->save();
   153         painter->save();
   156         painter->translate(rect.width() / 2 - d->mCloseHandleWidth / 2, 0);
   154         painter->translate(rect.width() / 2 - d->mCloseHandleWidth / 2, 0);
   157         rect.setWidth(d->mCloseHandleWidth);
   155         rect.setWidth(d->mCloseHandleWidth);
   159         d->mIconDrawer->paint(painter, rect);
   157         d->mIconDrawer->paint(painter, rect);
   160         painter->restore();
   158         painter->restore();
   161 
   159 
   162         painter->save();
   160         painter->save();
   163         painter->translate(0, d->mCloseHandleHeight);
   161         painter->translate(0, d->mCloseHandleHeight);
   164     	painter->drawPixmap(0, 0, d->mPixmap);
   162         painter->drawPixmap(0, 0, d->mPixmap);
   165         painter->restore();
   163         painter->restore();
   166     }
   164     }
   167 }
   165 }
   168 
   166 
   169 
   167