From a1c9b8a8fab423c0666cdd6a51c14db265fec364 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Tue, 3 Mar 2015 11:49:00 +0900 Subject: [PATCH] menu: modified screenshot class name Screenshot -> ScreenShotDialog Change-Id: I516cfffbf5973a4c5abe140498e66332a587b63f Signed-off-by: GiWoong Kim --- tizen/src/ui/menu/Makefile.objs | 6 +- tizen/src/ui/menu/contextmenu.cpp | 2 +- tizen/src/ui/menu/contextmenu.h | 4 +- .../{screenshot.cpp => screenshotdialog.cpp} | 233 +++++++++--------- .../menu/{screenshot.h => screenshotdialog.h} | 20 +- tizen/src/ui/menu/screenshotview.cpp | 10 +- tizen/src/ui/menu/screenshotview.h | 6 +- 7 files changed, 142 insertions(+), 139 deletions(-) rename tizen/src/ui/menu/{screenshot.cpp => screenshotdialog.cpp} (87%) rename tizen/src/ui/menu/{screenshot.h => screenshotdialog.h} (89%) diff --git a/tizen/src/ui/menu/Makefile.objs b/tizen/src/ui/menu/Makefile.objs index 087c0405f4..bb9a371fed 100644 --- a/tizen/src/ui/menu/Makefile.objs +++ b/tizen/src/ui/menu/Makefile.objs @@ -1,5 +1,5 @@ obj-$(CONFIG_QT) += aboutdialog.o moc_aboutdialog.o -obj-$(CONFIG_QT) += screenshot.o moc_screenshot.o +obj-$(CONFIG_QT) += screenshotdialog.o moc_screenshotdialog.o obj-$(CONFIG_QT) += detailedinfodialog.o moc_detailedinfodialog.o obj-$(CONFIG_QT) += contextmenu.o moc_contextmenu.o obj-$(CONFIG_QT) += menuitem.o @@ -16,6 +16,6 @@ $(obj)/moc_detailedinfodialog.cpp: $(obj)/detailedinfodialog.h $(obj)/moc_contextmenu.o: $(obj)/moc_contextmenu.cpp $(obj)/moc_contextmenu.cpp: $(obj)/contextmenu.h moc $< -o $@ -$(obj)/moc_screenshot.o: $(obj)/moc_screenshot.cpp -$(obj)/moc_screenshot.cpp: $(obj)/screenshot.h +$(obj)/moc_screenshotdialog.o: $(obj)/moc_screenshotdialog.cpp +$(obj)/moc_screenshotdialog.cpp: $(obj)/screenshotdialog.h moc $< -o $@ diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index ec22e1f115..7426ebc51e 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -733,7 +733,7 @@ void ContextMenu::slotShowScreenshot(const QPixmap &screenshot) qDebug("show screenshot"); if (screenshotDialog == NULL) { - screenshotDialog = new Screenshot(parent, screenshot); + screenshotDialog = new ScreenShotDialog(parent, screenshot); } screenshotDialog->slotRefresh(screenshot); diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index bc6896904e..7d48f21c2c 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -35,7 +35,7 @@ #include "detailedinfodialog.h" #include "aboutdialog.h" -#include "screenshot.h" +#include "screenshotdialog.h" #include "menu/menuitem.h" class MainWindow; @@ -60,7 +60,7 @@ public: QSignalMapper *getScaleMapper(); QSignalMapper *getControllerMapper(); - Screenshot *screenshotDialog; + ScreenShotDialog *screenshotDialog; signals: diff --git a/tizen/src/ui/menu/screenshot.cpp b/tizen/src/ui/menu/screenshotdialog.cpp similarity index 87% rename from tizen/src/ui/menu/screenshot.cpp rename to tizen/src/ui/menu/screenshotdialog.cpp index 9ca468ebf8..0fb1c811fa 100644 --- a/tizen/src/ui/menu/screenshot.cpp +++ b/tizen/src/ui/menu/screenshotdialog.cpp @@ -5,6 +5,7 @@ * * Contact: * Munkyu Im + * GiWoong Kim * Sangho Park * * This program is free software; you can redistribute it and/or @@ -29,11 +30,11 @@ #include -#include "screenshot.h" +#include "screenshotdialog.h" #include "screenshotview.h" #include "mainwindow.h" -Screenshot::Screenshot(QWidget *parent, const QPixmap &pixmap) : +ScreenShotDialog::ScreenShotDialog(QWidget *parent, const QPixmap &pixmap) : QDialog(parent), screenshotPixmap(pixmap) { this->win = (MainWindow *)parent; @@ -60,22 +61,77 @@ Screenshot::Screenshot(QWidget *parent, const QPixmap &pixmap) : resize(win->uiInfo->getMainSize()); } -void Screenshot::slotCopy() +void ScreenShotDialog::createItems() { - qDebug("copy to clipboard"); + statusBar = new QStatusBar(this); + toolbar = new QToolBar(this); - QClipboard* clipboard = QApplication::clipboard(); - QPixmap pixmap(screenshotPixmap); - clipboard->clear(); - clipboard->setPixmap(pixmap); + slider = new QSlider(Qt::Horizontal, this); + slider->setTickPosition(QSlider::TicksAbove); + slider->setRange(0, 5); + slider->setValue(3); + sliderLevel = 3; + slider->setFixedWidth(100); + slider->setToolTip("100%"); + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slotScaleChanged(int))); + + gridlayout = new QGridLayout(this); + gridlayout->setContentsMargins(0, 0, 0, 0); + + saveAct = new QAction(tr("&Save"), this); + saveAct->setShortcuts(QKeySequence::Save); + saveAct->setIcon(QIcon(":/icons/save_screenshot_dialog.png")); + saveAct->setToolTip("Save to file"); + connect(saveAct, SIGNAL(triggered()), this, SLOT(slotSave())); + + copyAct = new QAction(tr("&Copy"), this); + copyAct->setShortcuts(QKeySequence::Copy); + copyAct->setIcon(QIcon(":/icons/copy_screenshot_dialog.png")); + copyAct->setToolTip("Copy to clipboard"); + connect(copyAct, SIGNAL(triggered()), this, SLOT(slotCopy())); + + refreshAct = new QAction(tr("&Refresh"), this); + refreshAct->setShortcuts(QKeySequence::Refresh); + refreshAct->setIcon(QIcon(":/icons/refresh_screenshot_dialog.png")); + refreshAct->setToolTip("Refresh Image"); + connect(refreshAct, SIGNAL(triggered()), + win->getPopupMenu(), SLOT(slotRequestScreenshot())); } -QString Screenshot::getRatio() +void ScreenShotDialog::setImage() +{ + scene = new QGraphicsScene(this); + + qDebug() << screenshotPixmap; + + QMatrix rm; + rm.rotate(getRotateAngle()); + screenshotPixmap = screenshotPixmap.transformed(rm); + scene->addPixmap(screenshotPixmap); + + view = new ScreenShotView(scene, this); + ratioStr = "100%"; + 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); +} + +int ScreenShotDialog::getRotateAngle() +{ + return win->uiInfo->getMainFormDisplayType()->getAngle(); +} + +QString ScreenShotDialog::getRatio() { return ratioStr; } -void Screenshot::setRatio(int level) +void ScreenShotDialog::setRatio(int level) { switch (level) { case 0: @@ -100,62 +156,12 @@ void Screenshot::setRatio(int level) ratioStr = QString::number(ratio * 100).append("%"); } -void Screenshot::slotScaleChanged(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() +int ScreenShotDialog::getSliderLevel() { return sliderLevel; } -void Screenshot::slotRefresh(const QPixmap &pixmap) -{ - qDebug("refresh"); - - this->frameBuf = pixmap; - - ratioStr = "100%"; - sliderLevel = 3; - slider->setValue(3); - scene->clear(); - - // TODO: once - QMatrix rm; - rm.rotate(getRotateAngle()); - screenshotPixmap = screenshotPixmap.transformed(rm); - scene->addPixmap(screenshotPixmap); - slider->setToolTip(ratioStr); -} - -void Screenshot::setStatusBar(qreal xx, qreal yy) -{ - posX = QString::number(xx); - posY = QString::number(yy); - - updateStatusBar(); -} - -void Screenshot::updateStatusBar() -{ - statusBar->showMessage("x: " + posX + ", y:" + posY + - " (" + QString::number(screenshotPixmap.width()) + - "x" + QString::number(screenshotPixmap.height()) + - ", " + qPrintable(getRatio()) + ")"); -} - -bool Screenshot::slotSave() +bool ScreenShotDialog::slotSave() { qDebug("save"); @@ -170,81 +176,76 @@ bool Screenshot::slotSave() if (filename.isEmpty()) { qDebug("can not have file"); return false; - } else { - QPixmap pixmap(screenshotPixmap); - qDebug() << filename; - pixmap.save(filename); } + QPixmap pixmap(screenshotPixmap); + qDebug() << filename; + pixmap.save(filename); + return true; } -int Screenshot::getRotateAngle() +void ScreenShotDialog::slotCopy() { - return win->uiInfo->getMainFormDisplayType()->getAngle(); + qDebug("copy to clipboard"); + + QClipboard* clipboard = QApplication::clipboard(); + QPixmap pixmap(screenshotPixmap); + clipboard->clear(); + clipboard->setPixmap(pixmap); } -void Screenshot::createItems() +void ScreenShotDialog::slotRefresh(const QPixmap &pixmap) { - statusBar = new QStatusBar(this); - toolbar = new QToolBar(this); + qDebug("refresh"); - slider = new QSlider(Qt::Horizontal, this); - slider->setTickPosition(QSlider::TicksAbove); - slider->setRange(0, 5); - slider->setValue(3); + frameBuf = pixmap; + + ratioStr = "100%"; sliderLevel = 3; - slider->setFixedWidth(100); - slider->setToolTip("100%"); - connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slotScaleChanged(int))); + slider->setValue(3); + scene->clear(); - gridlayout = new QGridLayout(this); - gridlayout->setContentsMargins(0, 0, 0, 0); + // TODO: once + QMatrix rm; + rm.rotate(getRotateAngle()); + screenshotPixmap = screenshotPixmap.transformed(rm); + scene->addPixmap(screenshotPixmap); + slider->setToolTip(ratioStr); +} - saveAct = new QAction(tr("&Save"), this); - saveAct->setShortcuts(QKeySequence::Save); - saveAct->setIcon(QIcon(":/icons/save_screenshot_dialog.png")); - saveAct->setToolTip("Save to file"); - connect(saveAct, SIGNAL(triggered()), this, SLOT(slotSave())); +void ScreenShotDialog::slotScaleChanged(int level) +{ + qDebug("scale changed: %d", level); - copyAct = new QAction(tr("&Copy"), this); - copyAct->setShortcuts(QKeySequence::Copy); - copyAct->setIcon(QIcon(":/icons/copy_screenshot_dialog.png")); - copyAct->setToolTip("Copy to clipboard"); - connect(copyAct, SIGNAL(triggered()), this, SLOT(slotCopy())); + sliderLevel = level; + QPixmap pixmap(screenshotPixmap); + setRatio(level); + scene->clear(); + scene->addPixmap(pixmap.scaled(pixmap.size() * ratio, + Qt::KeepAspectRatio, Qt::FastTransformation)); + slider->setToolTip(ratioStr); - refreshAct = new QAction(tr("&Refresh"), this); - refreshAct->setShortcuts(QKeySequence::Refresh); - refreshAct->setIcon(QIcon(":/icons/refresh_screenshot_dialog.png")); - refreshAct->setToolTip("Refresh Image"); - connect(refreshAct, SIGNAL(triggered()), - win->getPopupMenu(), SLOT(slotRequestScreenshot())); + updateStatusBar(); } -void Screenshot::setImage() +void ScreenShotDialog::setStatusBar(qreal xx, qreal yy) { - scene = new QGraphicsScene(this); - - qDebug() << screenshotPixmap; - - QMatrix rm; - rm.rotate(getRotateAngle()); - screenshotPixmap = screenshotPixmap.transformed(rm); - scene->addPixmap(screenshotPixmap); + posX = QString::number(xx); + posY = QString::number(yy); - view = new ScreenshotView(scene, this); - ratioStr = "100%"; - view->setScene(scene); - view->setMouseTracking(true); + updateStatusBar(); +} - QScrollArea *area = new QScrollArea(this); - area->setFixedSize(screenshotPixmap.width(), screenshotPixmap.height()); - view->setCornerWidget(area); - view->verticalScrollBar()->setValue(1); - view->horizontalScrollBar()->setValue(1); +void ScreenShotDialog::updateStatusBar() +{ + statusBar->showMessage("x: " + posX + ", y:" + posY + + " (" + QString::number(screenshotPixmap.width()) + + "x" + QString::number(screenshotPixmap.height()) + + ", " + qPrintable(getRatio()) + ")"); } -void Screenshot::showEvent(QShowEvent *event) +void ScreenShotDialog::showEvent(QShowEvent *event) { Q_UNUSED(event) @@ -253,7 +254,7 @@ void Screenshot::showEvent(QShowEvent *event) win->geometry().center().y() - (geometry().size().height() / 2)); } -Screenshot::~Screenshot() +ScreenShotDialog::~ScreenShotDialog() { qDebug("destroy screenshot dialog"); diff --git a/tizen/src/ui/menu/screenshot.h b/tizen/src/ui/menu/screenshotdialog.h similarity index 89% rename from tizen/src/ui/menu/screenshot.h rename to tizen/src/ui/menu/screenshotdialog.h index bd1c0ff45b..87bd1570d6 100644 --- a/tizen/src/ui/menu/screenshot.h +++ b/tizen/src/ui/menu/screenshotdialog.h @@ -5,6 +5,7 @@ * * Contact: * Munkyu Im + * GiWoong Kim * Sangho Park * * This program is free software; you can redistribute it and/or @@ -34,27 +35,30 @@ class MainWindow; -class Screenshot : public QDialog +class ScreenShotDialog : public QDialog { Q_OBJECT public: - explicit Screenshot(QWidget *parent, const QPixmap &screenshot); - ~Screenshot(); + explicit ScreenShotDialog(QWidget *parent, const QPixmap &screenshot); + ~ScreenShotDialog(); - void setStatusBar(qreal xx, qreal yy); - int getSliderLevel(); int getRotateAngle(); QString getRatio(); + int getSliderLevel(); + void setStatusBar(qreal xx, qreal yy); QPixmap frameBuf; public slots: + bool slotSave(); + void slotCopy(); void slotRefresh(const QPixmap &); protected: void showEvent(QShowEvent *event); - QGraphicsScene* scene; + + QGraphicsScene *scene; private: void createItems(); @@ -66,7 +70,7 @@ private: QString posX; QString posY; QGridLayout *gridlayout; - QGraphicsView* view; + QGraphicsView *view; int sliderLevel; QLabel *label; QSlider *slider; @@ -85,8 +89,6 @@ private: QAction *refreshAct; private slots: - bool slotSave(); - void slotCopy(); void slotScaleChanged(int level); }; diff --git a/tizen/src/ui/menu/screenshotview.cpp b/tizen/src/ui/menu/screenshotview.cpp index 8c70088f5a..987744462e 100644 --- a/tizen/src/ui/menu/screenshotview.cpp +++ b/tizen/src/ui/menu/screenshotview.cpp @@ -30,19 +30,19 @@ #include #include "screenshotview.h" -#include "screenshot.h" +#include "screenshotdialog.h" -ScreenshotView::ScreenshotView(QGraphicsScene *scene, QWidget *parent) : +ScreenShotView::ScreenShotView(QGraphicsScene *scene, QWidget *parent) : QGraphicsView(scene, parent) { setBackgroundRole(QPalette::Dark); } -void ScreenshotView::mouseMoveEvent(QMouseEvent *event) +void ScreenShotView::mouseMoveEvent(QMouseEvent *event) { int max_x; int max_y; - Screenshot *screenshot = (Screenshot *)(this->parent()); + ScreenShotDialog *screenshot = (ScreenShotDialog *)(this->parent()); QPointF fixedPos = this->mapToScene(event->pos()); int sliderLevel = screenshot->getSliderLevel(); @@ -103,7 +103,7 @@ void ScreenshotView::mouseMoveEvent(QMouseEvent *event) } } -ScreenshotView::~ScreenshotView() +ScreenShotView::~ScreenShotView() { /* do nothing */ } diff --git a/tizen/src/ui/menu/screenshotview.h b/tizen/src/ui/menu/screenshotview.h index 94e43bae93..a112e6662a 100644 --- a/tizen/src/ui/menu/screenshotview.h +++ b/tizen/src/ui/menu/screenshotview.h @@ -32,11 +32,11 @@ #include -class ScreenshotView: public QGraphicsView +class ScreenShotView: public QGraphicsView { public: - ScreenshotView(QGraphicsScene *scene, QWidget *parent); - ~ScreenshotView(); + ScreenShotView(QGraphicsScene *scene, QWidget *parent); + ~ScreenShotView(); protected: void mouseMoveEvent(QMouseEvent *event); -- 2.34.1