*
* Contact:
* Munkyu Im <munkyu.im@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
* Sangho Park <sangho1206.park@samsung.com>
*
* This program is free software; you can redistribute it and/or
#include <qtoolbutton.h>
-#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;
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:
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");
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)
win->geometry().center().y() - (geometry().size().height() / 2));
}
-Screenshot::~Screenshot()
+ScreenShotDialog::~ScreenShotDialog()
{
qDebug("destroy screenshot dialog");