all repos — mgba @ 091e717133a10f785f02d1d4e880b8271fea8066

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 USE_FFMPEG
 60	void openVideoWindow();
 61#endif
 62
 63#ifdef USE_MAGICK
 64	void openGIFWindow();
 65#endif
 66
 67#ifdef USE_GDB_STUB
 68	void gdbOpen();
 69#endif
 70
 71protected:
 72	virtual void keyPressEvent(QKeyEvent* event) override;
 73	virtual void keyReleaseEvent(QKeyEvent* event) override;
 74	virtual void resizeEvent(QResizeEvent*) override;
 75	virtual void closeEvent(QCloseEvent*) override;
 76
 77private slots:
 78	void gameStarted(GBAThread*);
 79	void gameStopped();
 80	void redoLogo();
 81
 82	void recordFrame();
 83	void showFPS();
 84
 85private:
 86	static const int FPS_TIMER_INTERVAL = 2000;
 87	static const int FRAME_LIST_SIZE = 120;
 88
 89	void setupMenu(QMenuBar*);
 90	void openStateWindow(LoadSave);
 91
 92	void attachWidget(QWidget* widget);
 93	void detachWidget(QWidget* widget);
 94
 95	GameController* m_controller;
 96	Display* m_display;
 97	QList<QAction*> m_gameActions;
 98	LogView* m_logView;
 99	LoadSaveState* m_stateWindow;
100	WindowBackground* m_screenWidget;
101	QPixmap m_logo;
102	ConfigController* m_config;
103	InputController m_inputController;
104	QList<QDateTime> m_frameList;
105	QTimer m_fpsTimer;
106
107#ifdef USE_FFMPEG
108	VideoView* m_videoView;
109#endif
110
111#ifdef USE_MAGICK
112	GIFView* m_gifView;
113#endif
114
115#ifdef USE_GDB_STUB
116	GDBController* m_gdbController;
117#endif
118};
119
120class WindowBackground : public QLabel {
121Q_OBJECT
122
123public:
124	WindowBackground(QWidget* parent = 0);
125
126	void setSizeHint(const QSize& size);
127	virtual QSize sizeHint() const override;
128
129private:
130	QSize m_sizeHint;
131};
132
133}
134
135#endif