all repos — mgba @ e6ea94d2296eae963a48a18d009217a38d92bf9b

mGBA Game Boy Advance Emulator

src/platform/qt/Window.h (view raw)

  1#ifndef QGBA_WINDOW
  2#define QGBA_WINDOW
  3
  4#include <QAudioOutput>
  5#include <QDateTime>
  6#include <QList>
  7#include <QMainWindow>
  8#include <QTimer>
  9
 10extern "C" {
 11#include "gba.h"
 12}
 13
 14#include "GDBController.h"
 15#include "Display.h"
 16#include "InputController.h"
 17#include "LoadSaveState.h"
 18
 19struct GBAOptions;
 20struct GBAArguments;
 21
 22namespace QGBA {
 23
 24class ConfigController;
 25class GameController;
 26class GIFView;
 27class LogView;
 28class VideoView;
 29class WindowBackground;
 30
 31class Window : public QMainWindow {
 32Q_OBJECT
 33
 34public:
 35	Window(ConfigController* config, QWidget* parent = nullptr);
 36	virtual ~Window();
 37
 38	GameController* controller() { return m_controller; }
 39
 40	void setConfig(ConfigController*);
 41	void argumentsPassed(GBAArguments*);
 42
 43signals:
 44	void startDrawing(const uint32_t*, GBAThread*);
 45	void shutdown();
 46	void audioBufferSamplesChanged(int samples);
 47	void fpsTargetChanged(float target);
 48
 49public slots:
 50	void selectROM();
 51	void selectBIOS();
 52	void selectPatch();
 53	void toggleFullScreen();
 54	void loadConfig();
 55	void saveConfig();
 56
 57	void openKeymapWindow();
 58
 59#ifdef BUILD_SDL
 60	void openGamepadWindow();
 61#endif
 62
 63#ifdef USE_FFMPEG
 64	void openVideoWindow();
 65#endif
 66
 67#ifdef USE_MAGICK
 68	void openGIFWindow();
 69#endif
 70
 71#ifdef USE_GDB_STUB
 72	void gdbOpen();
 73#endif
 74
 75protected:
 76	virtual void keyPressEvent(QKeyEvent* event) override;
 77	virtual void keyReleaseEvent(QKeyEvent* event) override;
 78	virtual void resizeEvent(QResizeEvent*) override;
 79	virtual void closeEvent(QCloseEvent*) override;
 80
 81private slots:
 82	void gameStarted(GBAThread*);
 83	void gameStopped();
 84	void redoLogo();
 85
 86	void recordFrame();
 87	void showFPS();
 88
 89private:
 90	static const int FPS_TIMER_INTERVAL = 2000;
 91	static const int FRAME_LIST_SIZE = 120;
 92
 93	void setupMenu(QMenuBar*);
 94	void openStateWindow(LoadSave);
 95
 96	void attachWidget(QWidget* widget);
 97	void detachWidget(QWidget* widget);
 98
 99	GameController* m_controller;
100	Display* m_display;
101	QList<QAction*> m_gameActions;
102	LogView* m_logView;
103	LoadSaveState* m_stateWindow;
104	WindowBackground* m_screenWidget;
105	QPixmap m_logo;
106	ConfigController* m_config;
107	InputController m_inputController;
108	QList<QDateTime> m_frameList;
109	QTimer m_fpsTimer;
110
111#ifdef USE_FFMPEG
112	VideoView* m_videoView;
113#endif
114
115#ifdef USE_MAGICK
116	GIFView* m_gifView;
117#endif
118
119#ifdef USE_GDB_STUB
120	GDBController* m_gdbController;
121#endif
122};
123
124class WindowBackground : public QLabel {
125Q_OBJECT
126
127public:
128	WindowBackground(QWidget* parent = 0);
129
130	void setSizeHint(const QSize& size);
131	virtual QSize sizeHint() const override;
132
133private:
134	QSize m_sizeHint;
135};
136
137}
138
139#endif