all repos — mgba @ c7b6c4412d772011f4e1b9ee63dd830975e30972

mGBA Game Boy Advance Emulator

Qt: Support export button in frame inspector
Vicki Pfau vi@endrift.com
Sat, 01 Jun 2019 14:57:35 -0700
commit

c7b6c4412d772011f4e1b9ee63dd830975e30972

parent

ef3cc7bd9f28d73fdff912587fc42260948d5b51

2 files changed, 10 insertions(+), 0 deletions(-)

jump to
M src/platform/qt/FrameView.cppsrc/platform/qt/FrameView.cpp

@@ -13,6 +13,7 @@ #include <array>

#include <cmath> #include "CoreController.h" +#include "GBAApp.h" #include <mgba/core/core.h> #include <mgba/feature/video-logger.h>

@@ -67,6 +68,7 @@

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 @@ if (m_framebuffer.isNull()) {

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 @@ viewer->refreshVl();

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;
M src/platform/qt/FrameView.hsrc/platform/qt/FrameView.h

@@ -37,6 +37,7 @@

public slots: void selectLayer(const QPointF& coord); void disableLayer(const QPointF& coord); + void exportFrame(); protected: #ifdef M_CORE_GBA