--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/bmsapp.h Mon Feb 07 21:28:26 2022 +0100 @@ -0,0 +1,86 @@ +#ifndef _BMSAPP_H +#define _BMSAPP_H + +#include <QApplication> +#include <QDateTime> +#include <QDebug> +#include <QDir> +// #include <QDomDocument> +#include <QFile> +#include <QList> +#include <QMenu> +#include <QMetaProperty> +#include <QObject> +#include <QSettings> +#include <QString> +#include <QTextStream> +#include <QTranslator> + + + +typedef struct IniMySQL +{ + QString host; ///< MySQL host + QString port; ///< MySQL port + QString name; ///< MySQL database + QString user; ///< MySQL username + QString pass; ///< MySQL password + QString charset; ///< MySQL character encoding +} IniMySQL; + +static IniMySQL dbProd; +static IniMySQL dbDev; + +class MainWindow; + + +class Bmsapp : public QObject +{ + Q_OBJECT + + friend class MainWindow; + +public: + Bmsapp(); + + static QDir getResourceDir(); /* System wide resources */ + + /** + * @brief Blocking call that executes the application. + * @return Exit code from the application. + */ + static int run(); + +private: + static MainWindow* m_mainWindow; + + /** + * @brief Ensure some directories and files exist. + * @return true if all is ok. + */ + static bool ensureDirectoriesExist(); + + /** + * @brief Run before showing MainWindow, does all system setup. + * @return false if anything goes awry, true if it's ok to start MainWindow. + */ + static bool initialize(); + + /** + * @brief Run after QApplication exits to clean up shit, close database, etc. + */ + static void cleanup(); + + /** + * @brief Read user settings for the MySQL connection. + */ + static void readsettings(); + + /** + * @brief Write or update the user settings for the MySQL connection. + */ + static void writesettings(); +}; + + +#endif