|
1 #ifndef _BMSAPP_H |
|
2 #define _BMSAPP_H |
|
3 |
|
4 #include <QApplication> |
|
5 #include <QDateTime> |
|
6 #include <QDebug> |
|
7 #include <QDir> |
|
8 // #include <QDomDocument> |
|
9 #include <QFile> |
|
10 #include <QList> |
|
11 #include <QMenu> |
|
12 #include <QMetaProperty> |
|
13 #include <QObject> |
|
14 #include <QSettings> |
|
15 #include <QString> |
|
16 #include <QTextStream> |
|
17 #include <QTranslator> |
|
18 |
|
19 |
|
20 |
|
21 typedef struct IniMySQL |
|
22 { |
|
23 QString host; ///< MySQL host |
|
24 QString port; ///< MySQL port |
|
25 QString name; ///< MySQL database |
|
26 QString user; ///< MySQL username |
|
27 QString pass; ///< MySQL password |
|
28 QString charset; ///< MySQL character encoding |
|
29 } IniMySQL; |
|
30 |
|
31 static IniMySQL dbProd; |
|
32 static IniMySQL dbDev; |
|
33 |
|
34 class MainWindow; |
|
35 |
|
36 |
|
37 class Bmsapp : public QObject |
|
38 { |
|
39 Q_OBJECT |
|
40 |
|
41 friend class MainWindow; |
|
42 |
|
43 public: |
|
44 Bmsapp(); |
|
45 |
|
46 static QDir getResourceDir(); /* System wide resources */ |
|
47 |
|
48 /** |
|
49 * @brief Blocking call that executes the application. |
|
50 * @return Exit code from the application. |
|
51 */ |
|
52 static int run(); |
|
53 |
|
54 private: |
|
55 static MainWindow* m_mainWindow; |
|
56 |
|
57 /** |
|
58 * @brief Ensure some directories and files exist. |
|
59 * @return true if all is ok. |
|
60 */ |
|
61 static bool ensureDirectoriesExist(); |
|
62 |
|
63 /** |
|
64 * @brief Run before showing MainWindow, does all system setup. |
|
65 * @return false if anything goes awry, true if it's ok to start MainWindow. |
|
66 */ |
|
67 static bool initialize(); |
|
68 |
|
69 /** |
|
70 * @brief Run after QApplication exits to clean up shit, close database, etc. |
|
71 */ |
|
72 static void cleanup(); |
|
73 |
|
74 /** |
|
75 * @brief Read user settings for the MySQL connection. |
|
76 */ |
|
77 static void readsettings(); |
|
78 |
|
79 /** |
|
80 * @brief Write or update the user settings for the MySQL connection. |
|
81 */ |
|
82 static void writesettings(); |
|
83 }; |
|
84 |
|
85 |
|
86 #endif |