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