all repos — mgba @ bb78cc1bd3ccb7caae1e8cbb8f24954eaebfb1bd

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	virtual void focusOutEvent(QFocusEvent*) override;
 90
 91private slots:
 92	void gameStarted(GBAThread*);
 93	void gameStopped();
 94	void gameCrashed(const QString&);
 95	void redoLogo();
 96
 97	void recordFrame();
 98	void showFPS();
 99
100private:
101	static const int FPS_TIMER_INTERVAL = 2000;
102	static const int FRAME_LIST_SIZE = 120;
103
104	void setupMenu(QMenuBar*);
105	void openStateWindow(LoadSave);
106
107	void attachWidget(QWidget* widget);
108	void detachWidget(QWidget* widget);
109
110	void appendMRU(const QString& fname);
111	void updateMRU();
112
113	GameController* m_controller;
114	Display* m_display;
115	QList<QAction*> m_gameActions;
116	LogView* m_logView;
117	LoadSaveState* m_stateWindow;
118	WindowBackground* m_screenWidget;
119	QPixmap m_logo;
120	ConfigController* m_config;
121	InputController m_inputController;
122	QList<QDateTime> m_frameList;
123	QTimer m_fpsTimer;
124	QList<QString> m_mruFiles;
125	QMenu* m_mruMenu;
126
127#ifdef USE_FFMPEG
128	VideoView* m_videoView;
129#endif
130
131#ifdef USE_MAGICK
132	GIFView* m_gifView;
133#endif
134
135#ifdef USE_GDB_STUB
136	GDBController* m_gdbController;
137#endif
138};
139
140class WindowBackground : public QLabel {
141Q_OBJECT
142
143public:
144	WindowBackground(QWidget* parent = 0);
145
146	void setSizeHint(const QSize& size);
147	virtual QSize sizeHint() const override;
148
149private:
150	QSize m_sizeHint;
151};
152
153}
154
155#endif