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 GameController* m_controller;
108 Display* m_display;
109 QList<QAction*> m_gameActions;
110 LogView* m_logView;
111 LoadSaveState* m_stateWindow;
112 WindowBackground* m_screenWidget;
113 QPixmap m_logo;
114 ConfigController* m_config;
115 InputController m_inputController;
116 QList<QDateTime> m_frameList;
117 QTimer m_fpsTimer;
118
119#ifdef USE_FFMPEG
120 VideoView* m_videoView;
121#endif
122
123#ifdef USE_MAGICK
124 GIFView* m_gifView;
125#endif
126
127#ifdef USE_GDB_STUB
128 GDBController* m_gdbController;
129#endif
130};
131
132class WindowBackground : public QLabel {
133Q_OBJECT
134
135public:
136 WindowBackground(QWidget* parent = 0);
137
138 void setSizeHint(const QSize& size);
139 virtual QSize sizeHint() const override;
140
141private:
142 QSize m_sizeHint;
143};
144
145}
146
147#endif