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