Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions sources/imagearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
#include <QtCore/QDir>
#include <QMessageBox>
#include <QClipboard>
#include <QDesktopWidget>
#include <QScreen>

ImageArea::ImageArea(const bool &isOpen, const QString &filePath, QWidget *parent) :
QWidget(parent), mIsEdited(false), mIsPaint(false), mIsResize(false)
Expand Down Expand Up @@ -636,3 +638,19 @@ void ImageArea::pushUndoCommand(UndoCommand *command)
if(command != 0)
mUndoStack->push(command);
}

void ImageArea::_takeScreenshot()
{
QScreen *screen = QGuiApplication::screens().at(QApplication::desktop()->screenNumber(this));
QPixmap pixmap = screen->grabWindow(0);
QImage image = pixmap.toImage();
mAdditionalTools->resizeCanvas(image.width(), image.height(), false);
this->getImage()->swap(image);
this->topLevelWidget()->showNormal();
}

void ImageArea::takeScreenshot()
{
this->topLevelWidget()->showMinimized();
QTimer::singleShot(1000, this, &ImageArea::_takeScreenshot);
}
11 changes: 11 additions & 0 deletions sources/imagearea.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ class ImageArea : public QWidget
*
*/
void pushUndoCommand(UndoCommand *command);
/**
* @brief Take screenshot of parent screen.
*
*/
void takeScreenshot();

private:
/**
Expand Down Expand Up @@ -192,6 +197,12 @@ class ImageArea : public QWidget
*
*/
void makeFormatsFilters();
/**
* @brief Take screenshot of parent screen.
*
*/
void _takeScreenshot();


QImage *mImage, /**< Main image. */
mImageCopy; /**< Copy of main image, need for events. */ // ?????????????
Expand Down
9 changes: 9 additions & 0 deletions sources/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ void MainWindow::initializeMainMenu()

mToolsMenu->addMenu(zoomMenu);

QAction *screenshotQtAction = new QAction(tr("Screenshot"), this);
connect(screenshotQtAction, SIGNAL(triggered()), this, SLOT(takeScreenshot()));
mToolsMenu->addAction(screenshotQtAction);

QMenu *aboutMenu = menuBar()->addMenu(tr("&About"));

QAction *aboutAction = new QAction(tr("&About EasyPaint"), this);
Expand Down Expand Up @@ -860,3 +864,8 @@ void MainWindow::helpAct()
.arg(tr("version")).arg("0.1.0").arg(tr("Site")).arg(tr("Authors"))
.arg(tr("If you like <b>EasyPaint</b> and you want to share your opinion, or send a bug report, or want to suggest new features, we are waiting for you on our <a href=\"https://github.com/Gr1N/EasyPaint/issues?milestone=&sort=created&direction=desc&state=open\">tracker</a>.")));
}

void MainWindow::takeScreenshot()
{
getCurrentImageArea()->takeScreenshot();
}
1 change: 1 addition & 0 deletions sources/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ private slots:
void clearImageSelection();
void restorePreviousInstrument();
void setInstrument(InstrumentsEnum instrument);
void takeScreenshot();
signals:
void sendInstrumentChecked(InstrumentsEnum);

Expand Down