From e5fb1d32631d378ed78aa32bb4ad49badcccda48 Mon Sep 17 00:00:00 2001 From: Munkyu Im Date: Wed, 5 Nov 2014 13:32:48 +0900 Subject: screenshot: Set the coordinates in accordance with the scale. Adjust the position of x and y on screenshot image. Change-Id: I32040fe1160c1b17d854f0545539ca4ee8b79485 Signed-off-by: Munkyu Im --- tizen/src/ui/menu/screenshot.cpp | 8 +++-- tizen/src/ui/menu/screenshot.h | 5 ++- tizen/src/ui/menu/screenshotview.cpp | 63 +++++++++++++++++++++++++++++++++--- tizen/src/ui/menu/screenshotview.h | 2 +- 4 files changed, 66 insertions(+), 12 deletions(-) diff --git a/tizen/src/ui/menu/screenshot.cpp b/tizen/src/ui/menu/screenshot.cpp index 062d1d1670..6a05f38b6d 100644 --- a/tizen/src/ui/menu/screenshot.cpp +++ b/tizen/src/ui/menu/screenshot.cpp @@ -88,9 +88,10 @@ int Screenshot::getSliderLevel() { void Screenshot::refresh(const QPixmap &pixmap) { qDebug("refresh"); - screenshotPixmap = pixmap; + this->frameBuf = pixmap; ratioStr = "100%"; + sliderLevel = 3; slider->setValue(3); scene->clear(); @@ -148,6 +149,7 @@ void Screenshot::makeWidgets() { slider = new QSlider(Qt::Horizontal, this); slider->setRange(0, 5); slider->setValue(3); + sliderLevel = 3; slider->setFixedWidth(100); slider->setToolTip("100%"); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(scaleChanged(int))); @@ -190,7 +192,7 @@ void Screenshot::setImage() { view->setScene(scene); view->setMouseTracking(true); - QScrollArea* area = new QScrollArea(this); + QScrollArea *area = new QScrollArea(this); area->setFixedSize(screenshotPixmap.width(), screenshotPixmap.height()); view->setCornerWidget(area); view->verticalScrollBar()->setValue(1); @@ -232,5 +234,5 @@ void Screenshot::showEvent(QShowEvent *event) { Screenshot::~Screenshot() { qDebug("distructor"); - ((ContextMenu*)this->parent())->screenshotDialog = NULL; + ((ContextMenu *)this->parent())->screenshotDialog = NULL; } diff --git a/tizen/src/ui/menu/screenshot.h b/tizen/src/ui/menu/screenshot.h index e7f1e2240c..ff111af2f6 100644 --- a/tizen/src/ui/menu/screenshot.h +++ b/tizen/src/ui/menu/screenshot.h @@ -40,7 +40,9 @@ public: ~Screenshot(); void setStatusBar(qreal posX, qreal poxY); int getSliderLevel(); + int getRotateAngle(); QString getRatio(); + QPixmap frameBuf; public slots: void refresh(const QPixmap &); @@ -59,13 +61,10 @@ private: void setImage(); void setRatio(int level); void updateStatusBar(); - int getRotateAngle(); - QString posX; QString posY; QGridLayout *gridlayout; - QPixmap pixmap; QGraphicsView* view; int sliderLevel; QLabel *label; diff --git a/tizen/src/ui/menu/screenshotview.cpp b/tizen/src/ui/menu/screenshotview.cpp index 907d857870..681d1d1d52 100644 --- a/tizen/src/ui/menu/screenshotview.cpp +++ b/tizen/src/ui/menu/screenshotview.cpp @@ -29,18 +29,71 @@ #include "screenshotview.h" #include "screenshot.h" +#include -ScreenshotView::ScreenshotView(QGraphicsScene *scene, QWidget* parent) : +ScreenshotView::ScreenshotView(QGraphicsScene *scene, QWidget *parent) : QGraphicsView(scene, parent) { } void ScreenshotView::mouseMoveEvent(QMouseEvent *event) { + int max_x; + int max_y; + Screenshot *screenshot = (Screenshot *)(this->parent()); QPointF fixedPos = this->mapToScene(event->pos()); + int sliderLevel = screenshot->getSliderLevel(); + + switch (screenshot->getRotateAngle()) { + case 90: + case 270: + max_x = screenshot->frameBuf.size().height(); + max_y = screenshot->frameBuf.size().width(); + break; + case 0: + case 180: + default: + max_x = screenshot->frameBuf.size().width(); + max_y = screenshot->frameBuf.size().height(); + break; + } + + qDebug("sliderLevel: %d", sliderLevel); + int x; + int y; + float expo = 0; + switch (sliderLevel) { + case 0: + expo = 3; + break; + case 1: + expo = 2; + break; + case 2: + expo = 1; + break; + case 3: + expo = 0; + break; + case 4: + expo = -1; + break; + case 5: + expo = -2; + break; + default: + break; + } + + x = (int)(fixedPos.x() * pow(2, expo)); + y = (int)(fixedPos.y() * pow(2, expo)); + if(x > max_x) { + x = max_x; + } + if(y > max_y) { + y = max_y; + } + if (scene()->sceneRect().contains(fixedPos)) { - QPixmap pixmap = QPixmap(); - //QRgb rgbval = pixmap.toImage().pixel(fixedPos.x(), fixedPos.y()); - Screenshot *screenshot = ((Screenshot *) this->parent()); - screenshot->setStatusBar(fixedPos.x(), fixedPos.y()); + screenshot->setStatusBar(x, y); } } diff --git a/tizen/src/ui/menu/screenshotview.h b/tizen/src/ui/menu/screenshotview.h index a500dfbe0d..fda6a0b662 100644 --- a/tizen/src/ui/menu/screenshotview.h +++ b/tizen/src/ui/menu/screenshotview.h @@ -35,7 +35,7 @@ class ScreenshotView: public QGraphicsView { public: - ScreenshotView(QGraphicsScene *scene, QWidget* parent); + ScreenshotView(QGraphicsScene *scene, QWidget *parent); ~ScreenshotView(); protected: -- cgit v1.2.3