src/MainWindow.h

Fri, 20 May 2022 20:43:33 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 20 May 2022 20:43:33 +0200
changeset 225
448e4187cada
parent 213
a167ee979cac
child 228
c859e8efa470
permissions
-rw-r--r--

Implemented the tasting tab. On the generic tab, show the ingredients check or the read only prompt on the same place depending on the product stage. Fixed the yeasts ingredients in stock check. Reordered the tab order of all edit fields. It looks like this module is ready and needs testing.

#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>
#include <QChart>
#include <QValueAxis>
#include <QDateTimeAxis>
#include <QLineSeries>
#include <QChartView>

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