all repos — mgba @ a1480e269807f977f523712856137a3408718bd3

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 ShortcutController;
 33class VideoView;
 34class WindowBackground;
 35
 36class Window : public QMainWindow {
 37Q_OBJECT
 38
 39public:
 40	Window(ConfigController* config, QWidget* parent = nullptr);
 41	virtual ~Window();
 42
 43	GameController* controller() { return m_controller; }
 44
 45	void setConfig(ConfigController*);
 46	void argumentsPassed(GBAArguments*);
 47
 48	void resizeFrame(int width, int height);
 49
 50signals:
 51	void startDrawing(const uint32_t*, GBAThread*);
 52	void shutdown();
 53	void audioBufferSamplesChanged(int samples);
 54	void fpsTargetChanged(float target);
 55
 56public slots:
 57	void selectROM();
 58	void selectBIOS();
 59	void selectPatch();
 60	void toggleFullScreen();
 61	void loadConfig();
 62	void saveConfig();
 63
 64	void openKeymapWindow();
 65	void openSettingsWindow();
 66	void openShortcutWindow();
 67
 68	void openGamePakWindow();
 69
 70#ifdef BUILD_SDL
 71	void openGamepadWindow();
 72#endif
 73
 74#ifdef USE_FFMPEG
 75	void openVideoWindow();
 76#endif
 77
 78#ifdef USE_MAGICK
 79	void openGIFWindow();
 80#endif
 81
 82#ifdef USE_GDB_STUB
 83	void gdbOpen();
 84#endif
 85
 86protected:
 87	virtual void keyPressEvent(QKeyEvent* event) override;
 88	virtual void keyReleaseEvent(QKeyEvent* event) override;
 89	virtual void resizeEvent(QResizeEvent*) override;
 90	virtual void closeEvent(QCloseEvent*) override;
 91	virtual void focusOutEvent(QFocusEvent*) override;
 92
 93private slots:
 94	void gameStarted(GBAThread*);
 95	void gameStopped();
 96	void gameCrashed(const QString&);
 97	void redoLogo();
 98
 99	void recordFrame();
100	void showFPS();
101
102private:
103	static const int FPS_TIMER_INTERVAL = 2000;
104	static const int FRAME_LIST_SIZE = 120;
105
106	void setupMenu(QMenuBar*);
107	void openStateWindow(LoadSave);
108
109	void attachWidget(QWidget* widget);
110	void detachWidget(QWidget* widget);
111
112	void appendMRU(const QString& fname);
113	void updateMRU();
114
115	QAction* addControlledAction(QMenu* menu, QAction* action, const QString& name);
116
117	GameController* m_controller;
118	Display* m_display;
119	QList<QAction*> m_gameActions;
120	LogView* m_logView;
121	LoadSaveState* m_stateWindow;
122	WindowBackground* m_screenWidget;
123	QPixmap m_logo;
124	ConfigController* m_config;
125	InputController m_inputController;
126	QList<QDateTime> m_frameList;
127	QTimer m_fpsTimer;
128	QList<QString> m_mruFiles;
129	QMenu* m_mruMenu;
130	ShortcutController* m_shortcutController;
131
132#ifdef USE_FFMPEG
133	VideoView* m_videoView;
134#endif
135
136#ifdef USE_MAGICK
137	GIFView* m_gifView;
138#endif
139
140#ifdef USE_GDB_STUB
141	GDBController* m_gdbController;
142#endif
143};
144
145class WindowBackground : public QLabel {
146Q_OBJECT
147
148public:
149	WindowBackground(QWidget* parent = 0);
150
151	void setSizeHint(const QSize& size);
152	virtual QSize sizeHint() const override;
153
154private:
155	QSize m_sizeHint;
156};
157
158}
159
160#endif