all repos — mgba @ 2dc710feeb0e36fc2179ec7c5f90b3d0430dd00c

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