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
47signals:
48 void startDrawing(const uint32_t*, GBAThread*);
49 void shutdown();
50 void audioBufferSamplesChanged(int samples);
51 void fpsTargetChanged(float target);
52
53public slots:
54 void selectROM();
55 void selectBIOS();
56 void selectPatch();
57 void toggleFullScreen();
58 void loadConfig();
59 void saveConfig();
60
61 void openKeymapWindow();
62
63#ifdef BUILD_SDL
64 void openGamepadWindow();
65#endif
66
67#ifdef USE_FFMPEG
68 void openVideoWindow();
69#endif
70
71#ifdef USE_MAGICK
72 void openGIFWindow();
73#endif
74
75#ifdef USE_GDB_STUB
76 void gdbOpen();
77#endif
78
79protected:
80 virtual void keyPressEvent(QKeyEvent* event) override;
81 virtual void keyReleaseEvent(QKeyEvent* event) override;
82 virtual void resizeEvent(QResizeEvent*) override;
83 virtual void closeEvent(QCloseEvent*) override;
84
85private slots:
86 void gameStarted(GBAThread*);
87 void gameStopped();
88 void redoLogo();
89
90 void recordFrame();
91 void showFPS();
92
93private:
94 static const int FPS_TIMER_INTERVAL = 2000;
95 static const int FRAME_LIST_SIZE = 120;
96
97 void setupMenu(QMenuBar*);
98 void openStateWindow(LoadSave);
99
100 void attachWidget(QWidget* widget);
101 void detachWidget(QWidget* widget);
102
103 GameController* m_controller;
104 Display* m_display;
105 QList<QAction*> m_gameActions;
106 LogView* m_logView;
107 LoadSaveState* m_stateWindow;
108 WindowBackground* m_screenWidget;
109 QPixmap m_logo;
110 ConfigController* m_config;
111 InputController m_inputController;
112 QList<QDateTime> m_frameList;
113 QTimer m_fpsTimer;
114
115#ifdef USE_FFMPEG
116 VideoView* m_videoView;
117#endif
118
119#ifdef USE_MAGICK
120 GIFView* m_gifView;
121#endif
122
123#ifdef USE_GDB_STUB
124 GDBController* m_gdbController;
125#endif
126};
127
128class WindowBackground : public QLabel {
129Q_OBJECT
130
131public:
132 WindowBackground(QWidget* parent = 0);
133
134 void setSizeHint(const QSize& size);
135 virtual QSize sizeHint() const override;
136
137private:
138 QSize m_sizeHint;
139};
140
141}
142
143#endif