src/MainWindow.h

Mon, 18 Jul 2022 17:04:02 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 18 Jul 2022 17:04:02 +0200
changeset 359
dfbb012c631c
parent 323
d053ffbbf3e9
child 386
2e30c9c20d22
permissions
-rw-r--r--

Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.

#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 "ProdInprod.h"
#include "ProdOnName.h"
#include "ProdOnCode.h"
#include "ProdOnDate.h"
#include "ProdOnTree.h"
#include "ProfileWaters.h"
#include "ProfileMashs.h"
#include "ProfileStyles.h"
#include "ProfileFerments.h"
#include "MonNodes.h"
#include "MonFermenters.h"
#include "MonCO2meters.h"
#include "MoniSpindels.h"
#include "ImportXML.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>
#include <QChart>
#include <QValueAxis>
#include <QDateTimeAxis>
#include <QLineSeries>
#include <QSplineSeries>
#include <QChartView>
#include <QAreaSeries>


using namespace QtCharts;

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;


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;
    ProdInprod *ProdInprodWindow;
    ProdOnName *ProdOnNameWindow;
    ProdOnCode *ProdOnCodeWindow;
    ProdOnDate *ProdOnDateWindow;
    ProdOnTree *ProdOnTreeWindow;
    ProfileWaters *ProfileWatersWindow;
    ProfileMashs *ProfileMashsWindow;
    ProfileStyles *ProfileStylesWindow;
    ProfileFerments *ProfileFermentsWindow;
    MonNodes *MonNodesWindow;
    MonFermenters *MonFermentersWindow;
    MonCO2meters *MonCO2metersWindow;
    MoniSpindels *MoniSpindelsWindow;
    ImportXML *ImportXMLWindow;
    Setup *SetupWindow;

signals:
    void updateNodes(QString);
    void updateFermenters(QString);
    void updateCO2meters(QString);
    void updateiSpindels(QString);

private slots:
    void on_actionImport_XML_triggered();
    void on_actionExit_triggered();
    void on_actionMon_Nodes_triggered();
    void on_actionMon_Fermenters_triggered();
    void on_actionMon_CO2meters_triggered();
    void on_actionMon_iSpindels_triggered();
    void on_actionProd_inprod_triggered();
    void on_actionOn_Name_triggered();
    void on_actionOn_Code_triggered();
    void on_actionOn_Date_triggered();
    void on_actionOn_Tree_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 fromImportXML();
    void fromMonNodes();
    void fromMonFermenters();
    void fromMonCO2meters();
    void fromMoniSpindels();
    void fromRecipesTree();
    void fromInventorySuppliers();
    void fromInventoryFermentables();
    void fromInventoryHops();
    void fromInventoryYeasts();
    void fromInventoryMiscs();
    void fromInventoryWaters();
    void fromInventoryEquipments();
    void fromProdInprod();
    void fromProdOnName();
    void fromProdOnCode();
    void fromProdOnDate();
    void fromProdOnTree();
    void fromProfileWaters();
    void fromProfileMashs();
    void fromProfileStyles();
    void fromProfileFerments();
    void fromSetup();
    void windowTitle(QString);
    void statusMsg(QString);

private:
    Ui::MainWindow *ui;

    /**
     * @brief Load profile_setup record and set global variables.
     */
    void loadSetup();

    /**
     * @brief Do database maintenance.
     */
    void maintDataBase();

    /**
     * @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.
     *        Settings in $HOME/.config/mbse/bmsapp.ini
     */
    void readsettings();

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

#endif

mercurial