all repos — mgba @ 6cc889022666683f20f9614fd65392ab8e5af4c1

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