From 31fd1a0b77305544fd2272ffa6c5195b415b378e Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Wed, 4 Mar 2015 17:06:00 +0900 Subject: [PATCH] screenshot: delete unnecessary codes Change-Id: I2ffe52e7332bd1f0f285ca45916169d81e5b74c3 Signed-off-by: GiWoong Kim --- tizen/src/ui/menu/contextmenu.cpp | 4 ++ tizen/src/ui/menu/screenshotdialog.cpp | 59 +++++++++++------------- tizen/src/ui/menu/screenshotdialog.h | 9 ++-- tizen/src/ui/menu/screenshotview.cpp | 62 ++------------------------ 4 files changed, 41 insertions(+), 93 deletions(-) diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 5832c43327..0b32324a8d 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -714,6 +714,10 @@ void ContextMenu::slotShowScreenshot(const QPixmap &screenshot) screenshotDialog->slotRefresh(screenshot); screenshotDialog->show(); + +#ifdef CONFIG_LINUX + slotTopMost(parent->getUIState()->isOnTop()); +#endif } void ContextMenu::slotHostKeyboard(bool on) diff --git a/tizen/src/ui/menu/screenshotdialog.cpp b/tizen/src/ui/menu/screenshotdialog.cpp index 2b92156ecd..8fad6d91c8 100644 --- a/tizen/src/ui/menu/screenshotdialog.cpp +++ b/tizen/src/ui/menu/screenshotdialog.cpp @@ -41,6 +41,14 @@ ScreenShotDialog::ScreenShotDialog(QWidget *parent) : this->ratio = 1; this->posX = "0"; this->posY = "0"; + this->ratioList << + 0.25 << + 0.5 << + 0.75 << + 1.0 << + 2.0 << + 3.0 << + 4.0; setWindowTitle("Screen Shot - " + win->uiInfo->vmName + " : " + QString::number(get_device_serial_number())); @@ -95,9 +103,9 @@ void ScreenShotDialog::createItems(QGridLayout *layout) slider = new QSlider(Qt::Horizontal, this); slider->setFixedWidth(100); slider->setTickPosition(QSlider::TicksAbove); - slider->setRange(0, 5); + slider->setRange(0, ratioList.count() - 1); - slider->setValue(3); /* default */ + slider->setValue((ratioList.count() - 1) / 2 ); /* default */ updateRatio(getSliderLevel()); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderChanged(int))); @@ -120,9 +128,14 @@ int ScreenShotDialog::getDisplayAngle() return win->uiInfo->getMainFormDisplayType()->getAngle(); } +float ScreenShotDialog::getRatio() +{ + return ratio; +} + QString ScreenShotDialog::getRatioInfo() { - return QString::number(ratio * 100).append("%"); + return QString::number(getRatio() * 100).append("%"); } QPixmap &ScreenShotDialog::getShotData() @@ -194,32 +207,14 @@ void ScreenShotDialog::slotSliderChanged(int level) /* draw a screenshot */ updateScreenShot(shotData); - - updateStatusBar(); } void ScreenShotDialog::updateRatio(int level) { - // TODO: enum - switch (level) { - case 0: - ratio = 0.125; - break; - case 1: - ratio = 0.25; - break; - case 2: - ratio = 0.50; - break; - case 3: - ratio = 1; - break; - case 4: - ratio = 2; - break; - case 5: - ratio = 4; - break; + ratio = ratioList.at(level); + if (ratio <= 0) { + qWarning() << "invalid screenshot ratio :" << ratio; + return; } slider->setToolTip(getRatioInfo()); @@ -239,12 +234,14 @@ void ScreenShotDialog::updateScreenShot(QPixmap &shotData) /* update */ scene->setSceneRect(0, 0, shotImage.width(), shotImage.height()); scene->addPixmap(shotImage); + + updateStatusBar(); } -void ScreenShotDialog::updateMousePosition(int xx, int yy) +void ScreenShotDialog::updateMousePosition(const QPoint &pos) { - posX = QString::number(xx); - posY = QString::number(yy); + posX = QString::number(pos.x()); + posY = QString::number(pos.y()); updateStatusBar(); } @@ -253,8 +250,8 @@ void ScreenShotDialog::updateStatusBar() { if (statusBar != NULL) { statusBar->showMessage("x: " + posX + ", y:" + posY + - " (" + QString::number(shotData.width()) + - "x" + QString::number(shotData.height()) + + " (" + QString::number(scene->sceneRect().width() / getRatio()) + + "x" + QString::number(scene->sceneRect().height() / getRatio()) + ", " + getRatioInfo() + ")"); } } @@ -263,8 +260,6 @@ void ScreenShotDialog::showEvent(QShowEvent *event) { Q_UNUSED(event) - updateStatusBar(); - // TODO: move(win->geometry().center().x(), win->geometry().center().y() - (geometry().size().height() / 2)); diff --git a/tizen/src/ui/menu/screenshotdialog.h b/tizen/src/ui/menu/screenshotdialog.h index d030fdd172..60b9f45409 100644 --- a/tizen/src/ui/menu/screenshotdialog.h +++ b/tizen/src/ui/menu/screenshotdialog.h @@ -44,11 +44,10 @@ public: ~ScreenShotDialog(); int getDisplayAngle(); + float getRatio(); QString getRatioInfo(); QPixmap &getShotData(); - int getSliderLevel(); - void updateMousePosition(int xx, int yy); - void updateStatusBar(); + void updateMousePosition(const QPoint &pos); public slots: bool slotSave(); @@ -60,14 +59,18 @@ protected: private: void createItems(QGridLayout *layout); + int getSliderLevel(); void updateRatio(int level); void updateScreenShot(QPixmap &shotData); + void updateStatusBar(); MainWindow *win; QGridLayout *dialogLayout; QGraphicsScene *scene; QGraphicsView *view; + QList ratioList; + /* state */ QPixmap shotData; /* framebuffer */ float ratio; diff --git a/tizen/src/ui/menu/screenshotview.cpp b/tizen/src/ui/menu/screenshotview.cpp index 10163f4c2a..ff8262d460 100644 --- a/tizen/src/ui/menu/screenshotview.cpp +++ b/tizen/src/ui/menu/screenshotview.cpp @@ -44,64 +44,10 @@ void ScreenShotView::mouseMoveEvent(QMouseEvent *event) { ScreenShotDialog *screenshot = (ScreenShotDialog *)parent(); - int max_x; - int max_y; - - // TODO: radian - QPointF fixedPos = mapToScene(event->pos()); - int sliderLevel = screenshot->getSliderLevel(); - - switch (screenshot->getDisplayAngle()) { - case 90: - case 270: - max_x = screenshot->getShotData().size().height(); - max_y = screenshot->getShotData().size().width(); - break; - case 0: - case 180: - default: - max_x = screenshot->getShotData().size().width(); - max_y = screenshot->getShotData().size().height(); - break; - } - - 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)) { - screenshot->updateMousePosition(x, y); + QPointF shotPos = mapToScene(event->pos()); + if (scene()->sceneRect().contains(shotPos)) { + screenshot->updateMousePosition( + shotPos.toPoint() / screenshot->getRatio()); } } -- 2.34.1