diff options
author | Munkyu Im <munkyu.im@samsung.com> | 2014-10-27 14:46:28 +0900 |
---|---|---|
committer | Munkyu Im <munkyu.im@samsung.com> | 2014-11-06 14:42:35 +0900 |
commit | 45ad0f859a5fb042d72b2f10d33c82d40a1ee525 (patch) | |
tree | 94ecca5df749e8e10d1112b6b9b257e2280c1c4f | |
parent | 5bc50876a6c5a8be21d70d73b1d9f869636792f4 (diff) | |
download | qemu-45ad0f859a5fb042d72b2f10d33c82d40a1ee525.tar.gz qemu-45ad0f859a5fb042d72b2f10d33c82d40a1ee525.tar.bz2 qemu-45ad0f859a5fb042d72b2f10d33c82d40a1ee525.zip |
screenshot: Remove 800% scaled
pixmap bytes must be less than INT_MAX
This could make overflow on 32bit OS.
Also 800% scaled pixmap data are heavy to load.
Change-Id: Ib003299b167e73366495cdf728c25bd1b5f553f1
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
-rw-r--r-- | tizen/src/ui/menu/screenshot.cpp | 61 | ||||
-rw-r--r-- | tizen/src/ui/menu/screenshot.h | 6 | ||||
-rw-r--r-- | tizen/src/ui/menu/screenshotview.cpp | 11 | ||||
-rw-r--r-- | tizen/src/ui/menu/screenshotview.h | 5 |
4 files changed, 40 insertions, 43 deletions
diff --git a/tizen/src/ui/menu/screenshot.cpp b/tizen/src/ui/menu/screenshot.cpp index 0283e9b3a9..dbefa431ff 100644 --- a/tizen/src/ui/menu/screenshot.cpp +++ b/tizen/src/ui/menu/screenshot.cpp @@ -36,9 +36,6 @@ void Screenshot::setRatio(int level) { case 5: ratio = 4; break; - case 6: - ratio = 8; - break; } ratioStr = QString::number(ratio * 100).append("%"); } @@ -47,11 +44,12 @@ void Screenshot::scaleChanged(int level) { qDebug("scale changed: %d", level); sliderLevel = level; QPixmap pixmap(screenshotPixmap); - setRatio(level); scene->clear(); scene->addPixmap(pixmap.scaled(pixmap.size() * ratio, Qt::KeepAspectRatio, Qt::FastTransformation)); slider->setToolTip(ratioStr); + + updateStatusBar(); } int Screenshot::getSliderLevel() { @@ -63,8 +61,6 @@ void Screenshot::refresh(const QPixmap &pixmap) { screenshotPixmap = pixmap; - ((ScreenshotView*)view)->setWidthHeight(screenshotPixmap.width(), - screenshotPixmap.height()); ratioStr = "100%"; slider->setValue(3); scene->clear(); @@ -73,8 +69,19 @@ void Screenshot::refresh(const QPixmap &pixmap) { } -void Screenshot::setStatusBar(QString messsage) { - statusBar->showMessage(messsage); +void Screenshot::setStatusBar(qreal posX, qreal posY) { + this->posX = QString::number(posX); + this->posY = QString::number(posY); + + statusBar->showMessage("x: " + this->posX + ", y:" + this->posY + + " (Resolution: " + QString::number(screenshotPixmap.width()) + "x" + QString::number(screenshotPixmap.height()) + + ", " + qPrintable(getRatio()) + ")"); +} + +void Screenshot::updateStatusBar() { + statusBar->showMessage("x: " + this->posX + ", y:" + this->posY + + " (Resolution: " + QString::number(screenshotPixmap.width()) + "x" + QString::number(screenshotPixmap.height()) + + ", " + qPrintable(getRatio()) + ")"); } bool Screenshot::save() { @@ -101,7 +108,7 @@ void Screenshot::makeWidgets() { toolbar = new QToolBar(this); slider = new QSlider(Qt::Horizontal, this); - slider->setRange(0, 6); + slider->setRange(0, 5); slider->setValue(3); slider->setFixedWidth(100); slider->setToolTip("100%"); @@ -138,39 +145,39 @@ void Screenshot::setImage() { view = new ScreenshotView(scene, this); ratioStr = "100%"; - ((ScreenshotView*) view)->setWidthHeight(screenshotPixmap.width(), - screenshotPixmap.height()); view->setScene(scene); view->setMouseTracking(true); QScrollArea* area = new QScrollArea(this); area->setFixedSize(screenshotPixmap.width(), screenshotPixmap.height()); view->setCornerWidget(area); + view->verticalScrollBar()->setValue(1); + view->horizontalScrollBar()->setValue(1); } Screenshot::Screenshot(QWidget *parent, const QPixmap &pixmap) : QDialog(parent), screenshotPixmap(pixmap) { - QString vmname = ((MainWindow *) parent->parent())->uiInfo->vmName + " : " - + QString::number(get_device_serial_number()); - MainWindow *mainWindow = (MainWindow *) parent->parent(); - this->resize(mainWindow->uiInfo->getMainSize()); - setWindowTitle("Screen Shot - " + vmname); + QString vmname = ((MainWindow *) parent->parent())->uiInfo->vmName + " : " + + QString::number(get_device_serial_number()); + MainWindow *mainWindow = (MainWindow *) parent->parent(); + this->resize(mainWindow->uiInfo->getMainSize()); + setWindowTitle("Screen Shot - " + vmname); - makeWidgets(); + makeWidgets(); - setImage(); + setImage(); - statusBar = new QStatusBar; + statusBar = new QStatusBar; - toolbar->addAction(saveAct); - toolbar->addAction(copyAct); - toolbar->addAction(refreshAct); - toolbar->addWidget(slider); - gridlayout->addWidget(toolbar, 0, 0); - gridlayout->addWidget(view, 1, 0); - gridlayout->addWidget(statusBar, 2, 0); + toolbar->addAction(saveAct); + toolbar->addAction(copyAct); + toolbar->addAction(refreshAct); + toolbar->addWidget(slider); + gridlayout->addWidget(toolbar, 0, 0); + gridlayout->addWidget(view, 1, 0); + gridlayout->addWidget(statusBar, 2, 0); - this->setLayout(gridlayout); + this->setLayout(gridlayout); } void Screenshot::showEvent(QShowEvent *event) { diff --git a/tizen/src/ui/menu/screenshot.h b/tizen/src/ui/menu/screenshot.h index 50d540d8f0..1fd8288ced 100644 --- a/tizen/src/ui/menu/screenshot.h +++ b/tizen/src/ui/menu/screenshot.h @@ -9,7 +9,7 @@ Q_OBJECT public: explicit Screenshot(QWidget *me, const QPixmap &screenshot); ~Screenshot(); - void setStatusBar(QString message); + void setStatusBar(qreal posX, qreal poxY); int getSliderLevel(); QString getRatio(); @@ -29,7 +29,11 @@ private: void makeWidgets(); void setImage(); void setRatio(int level); + void updateStatusBar(); + + QString posX; + QString posY; QGridLayout *gridlayout; QPixmap pixmap; QGraphicsView* view; diff --git a/tizen/src/ui/menu/screenshotview.cpp b/tizen/src/ui/menu/screenshotview.cpp index 95400516bf..a0605c0303 100644 --- a/tizen/src/ui/menu/screenshotview.cpp +++ b/tizen/src/ui/menu/screenshotview.cpp @@ -3,13 +3,6 @@ ScreenshotView::ScreenshotView(QGraphicsScene *scene, QWidget* parent) : QGraphicsView(scene, parent) { - width = 0; - height = 0; -} - -void ScreenshotView::setWidthHeight(int width, int height) { - this->width = width; - this->height = height; } void ScreenshotView::mouseMoveEvent(QMouseEvent *event) { @@ -18,9 +11,7 @@ void ScreenshotView::mouseMoveEvent(QMouseEvent *event) { QPixmap pixmap = QPixmap(); //QRgb rgbval = pixmap.toImage().pixel(fixedPos.x(), fixedPos.y()); Screenshot *screenshot = ((Screenshot *) this->parent()); - screenshot->setStatusBar("x: " + QString::number(fixedPos.x()) + ", y:" + QString::number(fixedPos.y()) - + " (Resolution: " + QString::number(width) + "x" + QString::number(height) - + ", " + qPrintable(screenshot->getRatio()) + ")"); + screenshot->setStatusBar(fixedPos.x(), fixedPos.y()); } } diff --git a/tizen/src/ui/menu/screenshotview.h b/tizen/src/ui/menu/screenshotview.h index ffb06fd684..2872ddcaea 100644 --- a/tizen/src/ui/menu/screenshotview.h +++ b/tizen/src/ui/menu/screenshotview.h @@ -8,14 +8,9 @@ class ScreenshotView: public QGraphicsView { public: ScreenshotView(QGraphicsScene *scene, QWidget* parent); ~ScreenshotView(); - void setWidthHeight(int width, int height); protected: void mouseMoveEvent(QMouseEvent *event); -private: - int width; - int height; - }; #endif |