diff --git a/QtMeshViewer/Header/MainWindow.h b/QtMeshViewer/Header/MainWindow.h index de0e350..94c74e0 100644 --- a/QtMeshViewer/Header/MainWindow.h +++ b/QtMeshViewer/Header/MainWindow.h @@ -20,10 +20,11 @@ private: QByteArray m_fileInfo; -private slots: +private: void openFile(); void aboutFile(); void aboutTool(); + void takeScreenShot(); public slots: void printMessage(QString message, int severity); diff --git a/QtMeshViewer/Resources/Resources.qrc b/QtMeshViewer/Resources/Resources.qrc index c4b92d4..8577612 100644 --- a/QtMeshViewer/Resources/Resources.qrc +++ b/QtMeshViewer/Resources/Resources.qrc @@ -8,6 +8,7 @@ about.txt + stylesheet.txt placeholder.png @@ -17,5 +18,6 @@ X.png Y.png Z.png + screenshot.png diff --git a/QtMeshViewer/Resources/screenshot.png b/QtMeshViewer/Resources/screenshot.png new file mode 100644 index 0000000..8ff5c8e Binary files /dev/null and b/QtMeshViewer/Resources/screenshot.png differ diff --git a/QtMeshViewer/Source/MainWindow.cpp b/QtMeshViewer/Source/MainWindow.cpp index ba7763f..515d677 100644 --- a/QtMeshViewer/Source/MainWindow.cpp +++ b/QtMeshViewer/Source/MainWindow.cpp @@ -54,6 +54,10 @@ void MainWindow::setupWidgets() connect(openFile, &QAction::triggered, this, &MainWindow::openFile); ui->mainToolBar->addAction(openFile); + QAction *screenShot = new QAction(QIcon(":/images/toolbar/screenshot.png"), "Screenshot", this); + connect(screenShot, &QAction::triggered, this, &MainWindow::takeScreenShot); + ui->mainToolBar->addAction(screenShot); + ui->mainToolBar->addSeparator(); QSignalMapper* signalMapper = new QSignalMapper(this); @@ -130,6 +134,15 @@ void MainWindow::aboutTool() delete dialog; } +void MainWindow::takeScreenShot() +{ + QString destination = QFileDialog::getSaveFileName(this, "Save as...", "", "PNG (*.png);; BMP (*.bmp);;TIFF (*.tiff, *.tif);;JPEG (*.jpg *jpeg)"); + + OglViewerWidget* viewer = dynamic_cast(centralWidget()); + if (!destination.isEmpty() && viewer != NULL) + viewer->grab().save(destination); +} + void MainWindow::setFileInfo(QString name, QStringList textures, int vertices, int triangle) { m_fileInfo = QByteArray("Filename: ");