diff --git a/src/platform/qt/FrameView.cpp b/src/platform/qt/FrameView.cpp index bb5e23e48..2f1c68a08 100644 --- a/src/platform/qt/FrameView.cpp +++ b/src/platform/qt/FrameView.cpp @@ -13,6 +13,7 @@ #include #include "CoreController.h" +#include "GBAApp.h" #include #include @@ -67,6 +68,7 @@ FrameView::FrameView(std::shared_ptr controller, QWidget* parent QPixmap rendered = m_rendered.scaledToHeight(m_rendered.height() * m_ui.magnification->value()); m_ui.renderedView->setPixmap(rendered); }); + connect(m_ui.exportButton, &QAbstractButton::pressed, this, &FrameView::exportFrame); m_controller->addFrameAction(std::bind(&FrameView::frameCallback, this, m_callbackLocker)); } @@ -328,6 +330,7 @@ void FrameView::invalidateQueue(const QSize& dims) { updateRendered(); composited = m_rendered; } else { + m_ui.exportButton->setEnabled(true); composited.convertFromImage(m_framebuffer); } m_composited = composited.scaled(m_dims * m_ui.magnification->value()); @@ -406,6 +409,12 @@ void FrameView::frameCallback(FrameView* viewer, std::shared_ptr lock) { viewer->m_controller->addFrameAction(std::bind(&FrameView::frameCallback, viewer, lock)); } +void FrameView::exportFrame() { + QString filename = GBAApp::app()->getSaveFileName(this, tr("Export frame"), + tr("Portable Network Graphics (*.png)")); + CoreController::Interrupter interrupter(m_controller); + m_framebuffer.save(filename, "PNG"); +} QString FrameView::LayerId::readable() const { QString typeStr; diff --git a/src/platform/qt/FrameView.h b/src/platform/qt/FrameView.h index f255b62fc..2a2b5f680 100644 --- a/src/platform/qt/FrameView.h +++ b/src/platform/qt/FrameView.h @@ -37,6 +37,7 @@ public: public slots: void selectLayer(const QPointF& coord); void disableLayer(const QPointF& coord); + void exportFrame(); protected: #ifdef M_CORE_GBA