From 23592af3cc861229ff96d5fb7e2cdbdf0aa91da7 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 18 Oct 2014 16:37:05 -0700 Subject: [PATCH] Add screenshot support --- src/platform/qt/Display.cpp | 8 ++++++++ src/platform/qt/Display.h | 3 +++ src/platform/qt/Window.cpp | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/platform/qt/Display.cpp b/src/platform/qt/Display.cpp index 8d0402933..aa2cbac38 100644 --- a/src/platform/qt/Display.cpp +++ b/src/platform/qt/Display.cpp @@ -64,6 +64,14 @@ void Display::forceDraw() { } } +#ifdef USE_PNG +void Display::screenshot() { + GBAThreadInterrupt(m_context); + GBAThreadTakeScreenshot(m_context); + GBAThreadContinue(m_context); +} +#endif + void Display::initializeGL() { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); diff --git a/src/platform/qt/Display.h b/src/platform/qt/Display.h index 15929ce5e..7e38c08fc 100644 --- a/src/platform/qt/Display.h +++ b/src/platform/qt/Display.h @@ -20,6 +20,9 @@ public slots: void startDrawing(const uint32_t* buffer, GBAThread* context); void stopDrawing(); void forceDraw(); +#ifdef USE_PNG + void screenshot(); +#endif protected: virtual void initializeGL() override; diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index b9066d78b..4edad8d44 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -241,6 +241,16 @@ void Window::setupMenu(QMenuBar* menubar) { menubar->clear(); QMenu* fileMenu = menubar->addMenu(tr("&File")); fileMenu->addAction(tr("Load &ROM..."), this, SLOT(selectROM()), QKeySequence::Open); + fileMenu->addSeparator(); + +#ifdef USE_PNG + QAction* screenshot = new QAction(tr("Take &screenshot"), fileMenu); + screenshot->setShortcut(tr("F12")); + connect(screenshot, SIGNAL(triggered()), m_display, SLOT(screenshot())); + m_gameActions.append(screenshot); + fileMenu->addAction(screenshot); +#endif + #ifndef Q_OS_MAC fileMenu->addSeparator(); fileMenu->addAction(tr("E&xit"), this, SLOT(close()), QKeySequence::Quit);