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