src/MainWindow.h

Thu, 28 Apr 2022 16:47:59 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 28 Apr 2022 16:47:59 +0200
changeset 173
8514932b61aa
parent 133
08635b028dcf
child 213
a167ee979cac
permissions
-rw-r--r--

Added menu entry products in production

#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 "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;


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;
    ProfileWaters *ProfileWatersWindow;
    ProfileMashs *ProfileMashsWindow;
    ProfileStyles *ProfileStylesWindow;
    ProfileFerments *ProfileFermentsWindow;
    Setup *SetupWindow;

private slots:
    void on_actionExit_triggered();
    void on_actionProd_inprod_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 fromProdInprod();
    void fromProfileWaters();
    void fromProfileMashs();
    void fromProfileStyles();
    void fromProfileFerments();
    void fromSetup();
    void windowTitle(QString);
    void statusMsg(QString);

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

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

    /**
     * @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