diff --git a/src/platform/qt/CMakeLists.txt b/src/platform/qt/CMakeLists.txt index 653e45d9a..39b28fad0 100644 --- a/src/platform/qt/CMakeLists.txt +++ b/src/platform/qt/CMakeLists.txt @@ -38,11 +38,13 @@ set(SOURCE_FILES LogView.cpp SavestateButton.cpp Window.cpp - VFileDevice.cpp) + VFileDevice.cpp + VideoView.cpp) qt5_wrap_ui(UI_FILES LoadSaveState.ui - LogView.ui) + LogView.ui + VideoView.ui) if(USE_GDB_STUB) set(SOURCE_FILES ${PLATFORM_SRC} ${SOURCE_FILES} GDBController.cpp GDBWindow.cpp) diff --git a/src/platform/qt/VideoView.cpp b/src/platform/qt/VideoView.cpp new file mode 100644 index 000000000..73b858533 --- /dev/null +++ b/src/platform/qt/VideoView.cpp @@ -0,0 +1,15 @@ +#include "VideoView.h" + +#ifdef USE_FFMPEG + +using namespace QGBA; + +VideoView::VideoView(QWidget* parent) + : QWidget(parent) +{ + m_ui.setupUi(this); + + connect(m_ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); +} + +#endif diff --git a/src/platform/qt/VideoView.h b/src/platform/qt/VideoView.h new file mode 100644 index 000000000..c99325d41 --- /dev/null +++ b/src/platform/qt/VideoView.h @@ -0,0 +1,30 @@ +#ifndef QGBA_VIDEO_VIEW +#define QGBA_VIDEO_VIEW + +#ifdef USE_FFMPEG + +#include + +#include "ui_VideoView.h" + +struct FFmpegEncoder; + +namespace QGBA { + +class VideoView : public QWidget { +Q_OBJECT + +public: + VideoView(QWidget* parent = nullptr); + +private: + Ui::VideoView m_ui; + + FFmpegEncoder* m_encoder; +}; + +} + +#endif + +#endif diff --git a/src/platform/qt/VideoView.ui b/src/platform/qt/VideoView.ui new file mode 100644 index 000000000..862f7b867 --- /dev/null +++ b/src/platform/qt/VideoView.ui @@ -0,0 +1,261 @@ + + + VideoView + + + + 0 + 0 + 462 + 194 + + + + + 0 + 0 + + + + Record Video + + + + QLayout::SetFixedSize + + + + + Format + + + + + + true + + + + MKV + + + + + AVI + + + + + MP4 + + + + + + + + true + + + + PNG + + + + + h.264 + + + + + Xvid + + + + + Uncompressed + + + + + + + + true + + + + FLAC + + + + + Vorbis + + + + + MP3 + + + + + AAC + + + + + Uncompressed + + + + + + + + + + + Bitrate + + + + + + Video + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + vbr + + + + + + + + + + 200 + + + 9999 + + + 800 + + + + + + + Audio + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + abr + + + + + + + 16 + + + 320 + + + 192 + + + + + + + + + + + + false + + + + 0 + 0 + + + + Start + + + + + + + false + + + + 0 + 0 + + + + Stop + + + + + + + + 0 + 0 + + + + Select File + + + + + + + + 1 + 0 + + + + + + + + + + QDialogButtonBox::Close + + + + + + + filename + start + stop + selectFile + container + video + audio + vbr + abr + + + + diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 79b39caf5..d92a57256 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -11,6 +11,7 @@ #include "GDBWindow.h" #include "LoadSaveState.h" #include "LogView.h" +#include "VideoView.h" extern "C" { #include "platform/commandline.h" @@ -24,6 +25,9 @@ Window::Window(QWidget* parent) , m_stateWindow(nullptr) , m_screenWidget(new WindowBackground()) , m_logo(":/res/mgba-1024.png") +#ifdef USE_FFMPEG + , m_videoView(nullptr) +#endif #ifdef USE_GDB_STUB , m_gdbController(nullptr) #endif @@ -57,6 +61,7 @@ Window::Window(QWidget* parent) Window::~Window() { delete m_logView; + delete m_videoView; } GBAKey Window::mapKey(int qtKey) { @@ -139,6 +144,15 @@ void Window::selectPatch() { } } +#ifdef USE_FFMPEG +void Window::openVideoWindow() { + if (!m_videoView) { + m_videoView = new VideoView(); + } + m_videoView->show(); +} +#endif + #ifdef USE_GDB_STUB void Window::gdbOpen() { if (!m_gdbController) { @@ -291,8 +305,11 @@ void Window::setupMenu(QMenuBar* menubar) { quickSaveMenu->addAction(quickSave); } -#ifdef USE_PNG +#if defined(USE_PNG) || defined(USE_FFMPEG) fileMenu->addSeparator(); +#endif + +#ifdef USE_PNG QAction* screenshot = new QAction(tr("Take &screenshot"), fileMenu); screenshot->setShortcut(tr("F12")); connect(screenshot, SIGNAL(triggered()), m_display, SLOT(screenshot())); @@ -300,6 +317,14 @@ void Window::setupMenu(QMenuBar* menubar) { fileMenu->addAction(screenshot); #endif +#ifdef USE_FFMPEG + QAction* recordOutput = new QAction(tr("Record output..."), fileMenu); + recordOutput->setShortcut(tr("F11")); + connect(recordOutput, SIGNAL(triggered()), this, SLOT(openVideoWindow())); + m_gameActions.append(recordOutput); + fileMenu->addAction(recordOutput); +#endif + #ifndef Q_OS_MAC fileMenu->addSeparator(); fileMenu->addAction(tr("E&xit"), this, SLOT(close()), QKeySequence::Quit); diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 3368b590c..2582f5631 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -18,6 +18,7 @@ namespace QGBA { class GameController; class LogView; +class VideoView; class WindowBackground; class Window : public QMainWindow { @@ -45,6 +46,10 @@ public slots: void selectPatch(); void toggleFullScreen(); +#ifdef USE_FFMPEG + void openVideoWindow(); +#endif + #ifdef USE_GDB_STUB void gdbOpen(); #endif @@ -75,6 +80,10 @@ private: WindowBackground* m_screenWidget; QPixmap m_logo; +#ifdef USE_FFMPEG + VideoView* m_videoView; +#endif + #ifdef USE_GDB_STUB GDBController* m_gdbController; #endif