all repos — mgba @ 38a4e9988f8c6c210b2fd70790ff1f0f7006515b

mGBA Game Boy Advance Emulator

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

  1/* Copyright (c) 2013-2014 Jeffrey Pfau
  2 *
  3 * This Source Code Form is subject to the terms of the Mozilla Public
  4 * License, v. 2.0. If a copy of the MPL was not distributed with this
  5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6#ifndef QGBA_WINDOW
  7#define QGBA_WINDOW
  8
  9#include <QDateTime>
 10#include <QList>
 11#include <QMainWindow>
 12#include <QTimer>
 13
 14extern "C" {
 15#include "gba.h"
 16}
 17
 18#include "GDBController.h"
 19#include "Display.h"
 20#include "InputController.h"
 21#include "LoadSaveState.h"
 22
 23struct GBAOptions;
 24struct GBAArguments;
 25
 26namespace QGBA {
 27
 28class ConfigController;
 29class GameController;
 30class GIFView;
 31class LogView;
 32class VideoView;
 33class WindowBackground;
 34
 35class Window : public QMainWindow {
 36Q_OBJECT
 37
 38public:
 39	Window(ConfigController* config, QWidget* parent = nullptr);
 40	virtual ~Window();
 41
 42	GameController* controller() { return m_controller; }
 43
 44	void setConfig(ConfigController*);
 45	void argumentsPassed(GBAArguments*);
 46
 47	void resizeFrame(int width, int height);
 48
 49signals:
 50	void startDrawing(const uint32_t*, GBAThread*);
 51	void shutdown();
 52	void audioBufferSamplesChanged(int samples);
 53	void fpsTargetChanged(float target);
 54
 55public slots:
 56	void selectROM();
 57	void selectBIOS();
 58	void selectPatch();
 59	void toggleFullScreen();
 60	void loadConfig();
 61	void saveConfig();
 62
 63	void openKeymapWindow();
 64	void openSettingsWindow();
 65
 66	void openGamePakWindow();
 67
 68#ifdef BUILD_SDL
 69	void openGamepadWindow();
 70#endif
 71
 72#ifdef USE_FFMPEG
 73	void openVideoWindow();
 74#endif
 75
 76#ifdef USE_MAGICK
 77	void openGIFWindow();
 78#endif
 79
 80#ifdef USE_GDB_STUB
 81	void gdbOpen();
 82#endif
 83
 84protected:
 85	virtual void keyPressEvent(QKeyEvent* event) override;
 86	virtual void keyReleaseEvent(QKeyEvent* event) override;
 87	virtual void resizeEvent(QResizeEvent*) override;
 88	virtual void closeEvent(QCloseEvent*) override;
 89
 90private slots:
 91	void gameStarted(GBAThread*);
 92	void gameStopped();
 93	void gameCrashed(const QString&);
 94	void redoLogo();
 95
 96	void recordFrame();
 97	void showFPS();
 98
 99private:
100	static const int FPS_TIMER_INTERVAL = 2000;
101	static const int FRAME_LIST_SIZE = 120;
102
103	void setupMenu(QMenuBar*);
104	void openStateWindow(LoadSave);
105
106	void attachWidget(QWidget* widget);
107	void detachWidget(QWidget* widget);
108
109	void appendMRU(const QString& fname);
110	void updateMRU();
111
112	GameController* m_controller;
113	Display* m_display;
114	QList<QAction*> m_gameActions;
115	LogView* m_logView;
116	LoadSaveState* m_stateWindow;
117	WindowBackground* m_screenWidget;
118	QPixmap m_logo;
119	ConfigController* m_config;
120	InputController m_inputController;
121	QList<QDateTime> m_frameList;
122	QTimer m_fpsTimer;
123	QList<QString> m_mruFiles;
124	QMenu* m_mruMenu;
125
126#ifdef USE_FFMPEG
127	VideoView* m_videoView;
128#endif
129
130#ifdef USE_MAGICK
131	GIFView* m_gifView;
132#endif
133
134#ifdef USE_GDB_STUB
135	GDBController* m_gdbController;
136#endif
137};
138
139class WindowBackground : public QLabel {
140Q_OBJECT
141
142public:
143	WindowBackground(QWidget* parent = 0);
144
145	void setSizeHint(const QSize& size);
146	virtual QSize sizeHint() const override;
147
148private:
149	QSize m_sizeHint;
150};
151
152}
153
154#endif