src/platform/qt/GBAApp.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_APP_H
7#define QGBA_APP_H
8
9#include <QApplication>
10#include <QFileDialog>
11#include <QThread>
12
13#include "ConfigController.h"
14#include "MultiplayerController.h"
15
16struct NoIntroDB;
17
18#include <mgba/core/log.h>
19
20mLOG_DECLARE_CATEGORY(QT);
21
22namespace QGBA {
23
24class GameController;
25class Window;
26
27#ifdef USE_SQLITE3
28class GameDBParser : public QObject {
29Q_OBJECT
30
31public:
32 GameDBParser(NoIntroDB* db, QObject* parent = nullptr);
33
34public slots:
35 void parseNoIntroDB();
36
37private:
38 NoIntroDB* m_db;
39};
40#endif
41
42class GBAApp : public QApplication {
43Q_OBJECT
44
45public:
46 GBAApp(int& argc, char* argv[]);
47 ~GBAApp();
48 static GBAApp* app();
49
50 static QString dataDir();
51
52 Window* newWindow();
53
54 QString getOpenFileName(QWidget* owner, const QString& title, const QString& filter = QString());
55 QString getSaveFileName(QWidget* owner, const QString& title, const QString& filter = QString());
56 QString getOpenDirectoryName(QWidget* owner, const QString& title);
57
58 QFileDialog* getOpenFileDialog(QWidget* owner, const QString& title, const QString& filter = QString());
59 QFileDialog* getSaveFileDialog(QWidget* owner, const QString& title, const QString& filter = QString());
60
61 const NoIntroDB* gameDB() const { return m_db; }
62 bool reloadGameDB();
63
64protected:
65 bool event(QEvent*);
66
67private:
68 class FileDialog : public QFileDialog {
69 public:
70 FileDialog(GBAApp* app, QWidget* parent = nullptr, const QString& caption = QString(),
71 const QString& filter = QString());
72 virtual int exec() override;
73
74 private:
75 GBAApp* m_app;
76 };
77
78 Window* newWindowInternal();
79
80 void pauseAll(QList<Window*>* paused);
81 void continueAll(const QList<Window*>& paused);
82
83 ConfigController m_configController;
84 QList<Window*> m_windows;
85 MultiplayerController m_multiplayer;
86
87 NoIntroDB* m_db;
88#ifdef USE_SQLITE3
89 QThread m_parseThread;
90#endif
91};
92
93}
94
95#endif