src/MainWindow.cpp

Wed, 23 Mar 2022 22:00:28 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 23 Mar 2022 22:00:28 +0100
changeset 81
562ed7d1b74d
parent 79
e726db72da3c
child 88
64cf5468fd22
permissions
-rw-r--r--

Added start of the Recipes Tree to select a recipe

/**
 * MainWindow.cpp is part of bmsapp.
 *
 * bmsapp is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * bmsapp is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "MainWindow.h"
#include "AboutDialog.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 "PrinterDialog.h"
#include "../ui/ui_MainWindow.h"
#include "config.h"

#include <QApplication>
#include <QCloseEvent>
#include <QDebug>
#include <QStandardItem>
#include <QWidget>
#include <QtWidgets/QTableWidget>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QPushButton>


MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),  ui(new Ui::MainWindow)
{
    qDebug() << Q_FUNC_INFO;
    ui->setupUi(this);

    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
}


MainWindow::~MainWindow()
{
    qDebug() << Q_FUNC_INFO;
    delete ui;
}


void MainWindow::on_actionExit_triggered()
{
    qDebug() << Q_FUNC_INFO;
    this->close();
}


void MainWindow::fromRecipesTree()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(RecipesTreeWindow);
    delete RecipesTreeWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
}


void MainWindow::on_actionRecipes_triggered()
{
    qDebug() << Q_FUNC_INFO;

    RecipesTreeWindow = new RecipesTree(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(RecipesTreeWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle( QString("BMSapp - %1 - Recipes").arg(VERSIONSTRING));
//    ui->menuBar->setVisible(false);
}


void MainWindow::fromInventorySuppliers()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(InventorySuppliersWindow);
    delete InventorySuppliersWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
}


void MainWindow::on_actionSuppliers_triggered()
{
    qDebug() << Q_FUNC_INFO;

    InventorySuppliersWindow = new InventorySuppliers(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(InventorySuppliersWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromInventoryFermentables()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(InventoryFermentablesWindow);
    delete InventoryFermentablesWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionFermentables_triggered()
{
    qDebug() << Q_FUNC_INFO;

    InventoryFermentablesWindow = new InventoryFermentables(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(InventoryFermentablesWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Inventory Fermentables").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromInventoryHops()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(InventoryHopsWindow);
    delete InventoryHopsWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionHops_triggered()
{
    qDebug() << Q_FUNC_INFO;
    InventoryHopsWindow = new InventoryHops(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(InventoryHopsWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Inventory Hops").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromInventoryYeasts()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(InventoryYeastsWindow);
    delete InventoryYeastsWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionYeasts_triggered()
{
    qDebug() << Q_FUNC_INFO;
    InventoryYeastsWindow = new InventoryYeasts(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(InventoryYeastsWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Inventory Yeasts").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromInventoryMiscs()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(InventoryMiscsWindow);
    delete InventoryMiscsWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionMiscs_triggered()
{
    qDebug() << Q_FUNC_INFO;
    InventoryMiscsWindow = new InventoryMiscs(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(InventoryMiscsWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Inventory Miscs").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromInventoryWaters()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(InventoryWatersWindow);
    delete InventoryWatersWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionWaters_triggered()
{
    qDebug() << Q_FUNC_INFO;
    InventoryWatersWindow = new InventoryWaters(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(InventoryWatersWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Inventory Waters").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromInventoryEquipments()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(InventoryEquipmentsWindow);
    delete InventoryEquipmentsWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionEquipments_triggered()
{
    qDebug() << Q_FUNC_INFO;
    InventoryEquipmentsWindow = new InventoryEquipments(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(InventoryEquipmentsWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Inventory Equipments").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::on_actionSupplies_list_triggered()
{
    qDebug() << Q_FUNC_INFO;
    QDialog *printer = new PrinterDialog(PR_SUPPLIES, -1, this);
}


void MainWindow::on_actionYeast_bank_triggered()
{
    qDebug() << Q_FUNC_INFO;
    QDialog *printer = new PrinterDialog(PR_YEASTBANK, -1, this);
}


void MainWindow::fromProfileWaters()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(ProfileWatersWindow);
    delete ProfileWatersWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionWater_profiles_triggered()
{
    qDebug() << Q_FUNC_INFO;
    ProfileWatersWindow = new ProfileWaters(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(ProfileWatersWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Water Profiles").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromProfileMashs()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(ProfileMashsWindow);
    delete ProfileMashsWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionMash_profiles_triggered()
{
    qDebug() << Q_FUNC_INFO;
    ProfileMashsWindow = new ProfileMashs(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(ProfileMashsWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Mash Profiles").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromProfileStyles()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(ProfileStylesWindow);
    delete ProfileStylesWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionStyles_profiles_triggered()
{
    qDebug() << Q_FUNC_INFO;
    ProfileStylesWindow = new ProfileStyles(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(ProfileStylesWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Styles Profiles").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromProfileFerments()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(ProfileFermentsWindow);
    delete ProfileFermentsWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    statusBar()->clearMessage();
}


void MainWindow::on_actionFerments_profiles_triggered()
{
    qDebug() << Q_FUNC_INFO;
    ProfileFermentsWindow = new ProfileFerments(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(ProfileFermentsWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Fermentation Profiles").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromSetup()
{
    qDebug() << Q_FUNC_INFO;
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(SetupWindow);
    delete SetupWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
}


void MainWindow::on_actionSetup_triggered()
{
    qDebug() << Q_FUNC_INFO;
    SetupWindow = new Setup(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(SetupWindow);
    ui->mainStack->setCurrentIndex(index);
    ui->menuBar->setVisible(false);
}


void MainWindow::on_actionAbout_triggered()
{
    AboutDialog dialog(this);
    dialog.setModal(true);
    dialog.exec();
}


void MainWindow::windowTitle(QString msg)
{
    setWindowTitle(QString("BMSapp - %1 - %2").arg(VERSIONSTRING).arg(msg));
}


void MainWindow::statusMsg(QString msg)
{
    statusBar()->showMessage(msg);
}

mercurial