src/MainWindow.h

Tue, 12 Apr 2022 21:03:19 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 12 Apr 2022 21:03:19 +0200
changeset 131
0115b97e8c39
parent 125
2e79e0975e58
child 133
08635b028dcf
permissions
-rw-r--r--

Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.

#ifndef _MAINWINDOW_H
#define _MAINWINDOW_H

#include "RecipesTree.h"
#include "InventorySuppliers.h"
#include "InventoryFermentables.h"
#include "InventoryHops.h"
#include "InventoryYeasts.h"
#include "InventoryMiscs.h"
#include "InventoryWaters.h"
#include "InventoryEquipments.h"
#include "ProfileWaters.h"
#include "ProfileMashs.h"
#include "ProfileStyles.h"
#include "ProfileFerments.h"
#include "Setup.h"

#include <QMainWindow>
#include <QStandardItemModel>
#include <QMenu>
#include <QToolButton>
#include <QApplication>
#include <QDateTime>
#include <QDebug>
#include <QDir>
// #include <QDomDocument>
#include <QFile>
#include <QList>
#include <QMetaProperty>
#include <QObject>
#include <QSettings>
#include <QString>
#include <QTextStream>
#include <QTranslator>
#include <QtSql>
#include <QUuid>
#include <QStyle>
#include <QPlainTextEdit>
#include <QMessageBox>
#include <QLabel>
#include <QImage>
#include <QImageReader>
#include <QImageWriter>
#include <QColorSpace>
#include <QGraphicsView>
#include <QFileDialog>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMap>
#include <QPrinter>
#include <QWidget>
#include <QWebSocket>


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;


typedef struct IniWS
{
    QString host;               ///< MQTT host
    QString port;               ///< MQTT port
} IniWS;

static IniWS wsProd;
static IniWS wsDev;


//struct Acid
//{
//    QString	name;
//    double	pK1;
//    double	pK2;
//    double	pK3;
//    double	MolWt;
//    double	AcidSG;
//    double	AcidPrc;
//};

//static QList<Acid>	my_acids;


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(bool useDevelopOption, bool startConfigOption, QWidget *parent = 0);
    ~MainWindow();

    // Keep pointers to new windows.
    RecipesTree *RecipesTreeWindow;
    InventorySuppliers *InventorySuppliersWindow;
    InventoryFermentables *InventoryFermentablesWindow;
    InventoryHops *InventoryHopsWindow;
    InventoryYeasts *InventoryYeastsWindow;
    InventoryMiscs *InventoryMiscsWindow;
    InventoryWaters *InventoryWatersWindow;
    InventoryEquipments *InventoryEquipmentsWindow;
    ProfileWaters *ProfileWatersWindow;
    ProfileMashs *ProfileMashsWindow;
    ProfileStyles *ProfileStylesWindow;
    ProfileFerments *ProfileFermentsWindow;
    Setup *SetupWindow;

private slots:
    void on_actionExit_triggered();
    void on_actionRecipes_triggered();
    void on_actionSuppliers_triggered();
    void on_actionFermentables_triggered();
    void on_actionHops_triggered();
    void on_actionYeasts_triggered();
    void on_actionMiscs_triggered();
    void on_actionWaters_triggered();
    void on_actionEquipments_triggered();
    void on_actionSupplies_list_triggered();
    void on_actionYeast_bank_triggered();
    void on_actionWater_profiles_triggered();
    void on_actionMash_profiles_triggered();
    void on_actionStyles_profiles_triggered();
    void on_actionFerments_profiles_triggered();
    void on_actionSetup_triggered();
    void on_actionAbout_triggered();

public slots:
    void fromRecipesTree();
    void fromInventorySuppliers();
    void fromInventoryFermentables();
    void fromInventoryHops();
    void fromInventoryYeasts();
    void fromInventoryMiscs();
    void fromInventoryWaters();
    void fromInventoryEquipments();
    void fromProfileWaters();
    void fromProfileMashs();
    void fromProfileStyles();
    void fromProfileFerments();
    void fromSetup();
    void windowTitle(QString);
    void statusMsg(QString);

private:
    Ui::MainWindow *ui;
    QWebSocket *webSocket;

    /**
     * @brief Open Websocket connection.
     * @param develop Is true if connect to develop server, else production.
     * @return Returns true if succes.
     */
    bool openWS(bool develop);

    void wsConnected();

    void wsClosed();

    void wsTextMessageReceived(QString message);

    /**
     * @brief Read user settings for the MySQL connection.
     */
    void readsettings();

    /**
     * @brief Write or update the user settings for the MySQL connection.
     */
    void writesettings();
};

#endif

mercurial