src/MainWindow.cpp

Mon, 06 Jun 2022 17:15:27 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 06 Jun 2022 17:15:27 +0200
changeset 260
42b88d85fefc
parent 254
b0adda0053c5
child 275
f472f9773782
permissions
-rw-r--r--

Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.

/**
 * 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 "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 "Setup.h"
#include "PrinterDialog.h"
#include "../ui/ui_MainWindow.h"
#include "database/database.h"
#include "config.h"
#include "global.h"

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


MainWindow::MainWindow(bool useDevelopOption, bool startConfigOption, QWidget *parent) : QMainWindow(parent),  ui(new Ui::MainWindow)
{
    qDebug() << Q_FUNC_INFO << useDevelopOption << startConfigOption;
    ui->setupUi(this);
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );

    readsettings();
    db = new DataBase();
    db->openDataBase(useDevelopOption);

    loadSetup();
    openWS(useDevelopOption);

    Acid a;
    a.name_en = "Lactic";
    a.name_nl = "Melkzuur";
    a.pK1 = 3.86;
    a.pK2 = 20.0;
    a.pK3 = 20.0;
    a.MolWt = 90.08;
    a.AcidSG = 1238.0;
    a.AcidPrc = 80.0;
    my_acids.append(a);
    a.name_en = "Hydrochloric";
    a.name_nl = "Zoutzuur";
    a.pK1 = -7.0;
    a.pK2 = 20.0;
    a.pK3 = 20.0;
    a.MolWt = 36.46;
    a.AcidSG = 1497.0;
    a.AcidPrc = 28.0;
    my_acids.append(a);
    a.name_en = "Phosphoric";
    a.name_nl = "Fosforzuur";
    a.pK1 = 2.12;
    a.pK2 = 7.20;
    a.pK3 = 12.44;
    a.MolWt = 98.00;
    a.AcidSG = 1982.0;
    a.AcidPrc = 75.0;
    my_acids.append(a);
    a.name_en = "Sulfuric";
    a.name_nl = "Zwavelzuur";
    a.pK1 = -1.0;
    a.pK2 = 1.92;
    a.pK3 = 20.0;
    a.MolWt = 98.07;
    a.AcidSG = 1884.0;
    a.AcidPrc = 93.0;
    my_acids.append(a);
}


MainWindow::~MainWindow()
{
    writesettings();
    webSocket->close(QWebSocketProtocol::CloseCodeNormal, "");
    db->closeDataBase();
    delete ui;
}



void MainWindow::loadSetup()
{
    /*
     * Load dedaults from the setup.
     */
    QSqlQuery query("SELECT * FROM profile_setup WHERE record='1'");
    query.first();
    my_brewery_name = query.value(1).toString();
    my_logoByteArray = query.value(2).toByteArray();
    my_factor_mashhop = query.value(3).toInt();
    my_factor_fwh = query.value(4).toInt();
    my_factor_pellet = query.value(5).toInt();
    my_factor_plug = query.value(6).toInt();
    my_factor_wethop = query.value(7).toInt();
    my_factor_cryohop = query.value(8).toInt();
    my_ibu_method = query.value(9).toInt();
    my_color_method = query.value(10).toInt();
    my_brix_correction = query.value(11).toDouble();
    my_grain_absorbtion = query.value(12).toDouble();
    my_default_water = query.value(13).toInt();
    my_yeastlab = query.value(14).toString();

    qInfo() << "loadSetup" << my_brewery_name;
}


bool MainWindow::openWS(bool develop)
{
    QString server;
    if (develop)
	server = wsDev.host;
    else
	server = wsProd.host;
    QUrl url(QString("ws://%1/ws").arg(server));
    qInfo() << "Open websocket:" << url;

    webSocket = new QWebSocket;
    QObject::connect(webSocket, &QWebSocket::connected, this, &MainWindow::wsConnected);
    QObject::connect(webSocket, &QWebSocket::disconnected, this, &MainWindow::wsClosed);

    webSocket->open(QUrl(url));
    return true;
}


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

    connect(webSocket, &QWebSocket::textMessageReceived, this, &MainWindow::wsTextMessageReceived);
}


void MainWindow::wsClosed()
{
    qWarning() << Q_FUNC_INFO << webSocket->closeReason();

    // Should triger a periodic timer to try to reconnect.
}


void MainWindow::wsTextMessageReceived(QString message)
{
//    qDebug() << "WS received:" << message;
}


void MainWindow::readsettings()
{
    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "mbse", "bmsapp");

    settings.beginGroup("dbprod");
    dbProd.host = settings.value("host").toString();
    if (dbProd.host.isEmpty()) {
        dbProd.host = "localhost";
        dbProd.port = "3306";
        dbProd.name = "bms_prod";
        dbProd.user = "nobody";
        dbProd.pass = "secret";
        dbProd.charset = "utf8";
        settings.setValue("host", dbProd.host);
        settings.setValue("port", dbProd.port);
        settings.setValue("name", dbProd.name);
        settings.setValue("user", dbProd.user);
        settings.setValue("pass", dbProd.pass);
        settings.setValue("charset", dbProd.charset);
    } else {
        dbProd.port = settings.value("port").toString();
        dbProd.name = settings.value("name").toString();
        dbProd.user = settings.value("user").toString();
        dbProd.pass = settings.value("pass").toString();
        dbProd.charset = settings.value("charset").toString();
    }
    settings.endGroup();
    qDebug() << "MySQL prod" << dbProd.host << dbProd.port << dbProd.name << dbProd.pass;

    settings.beginGroup("dbdev");
    dbDev.host = settings.value("host").toString();
    if (dbDev.host.isEmpty()) {
        dbDev.host = "localhost";
        dbDev.port = "3306";
        dbDev.name = "bms_dev";
        dbDev.user = "nobody";
        dbDev.pass = "secret";
        dbDev.charset = "utf8";
        settings.setValue("host", dbDev.host);
        settings.setValue("port", dbDev.port);
        settings.setValue("name", dbDev.name);
        settings.setValue("user", dbDev.user);
        settings.setValue("pass", dbDev.pass);
        settings.setValue("charset", dbDev.charset);
    } else {
        dbDev.port = settings.value("port").toString();
        dbDev.name = settings.value("name").toString();
        dbDev.user = settings.value("user").toString();
        dbDev.pass = settings.value("pass").toString();
        dbDev.charset = settings.value("charset").toString();
    }
    settings.endGroup();
    qDebug() << "MySQL dev" << dbDev.host << dbDev.port << dbDev.name << dbDev.pass;

    settings.beginGroup("wsprod");
    wsProd.host = settings.value("host").toString();
    if (wsProd.host.isEmpty()) {
        wsProd.host = "localhost";
        settings.setValue("host", wsProd.host);
    }
    settings.endGroup();
    qDebug() << "WS prod" << wsProd.host;

    settings.beginGroup("wsdev");
    wsDev.host = settings.value("host").toString();
    if (wsDev.host.isEmpty()) {
        wsDev.host = "localhost";
        settings.setValue("host", wsDev.host);
    }
    settings.endGroup();
    qDebug() << "WS dev" << wsDev.host;
}


void MainWindow::writesettings()
{
    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "mbse", "bmsapp");

    settings.beginGroup("dbprod");
    settings.setValue("host", dbProd.host);
    settings.setValue("port", dbProd.port);
    settings.setValue("name", dbProd.name);
    settings.setValue("user", dbProd.user);
    settings.setValue("pass", dbProd.pass);
    settings.setValue("charset", dbProd.charset);
    settings.endGroup();

    settings.beginGroup("dbdev");
    settings.setValue("host", dbDev.host);
    settings.setValue("port", dbDev.port);
    settings.setValue("name", dbDev.name);
    settings.setValue("user", dbDev.user);
    settings.setValue("pass", dbDev.pass);
    settings.setValue("charset", dbDev.charset);
    settings.endGroup();

    settings.beginGroup("wsprod");
    settings.setValue("host", wsProd.host);
    settings.endGroup();

    settings.beginGroup("wsdev");
    settings.setValue("host", wsDev.host);
    settings.endGroup();

    qDebug() << "writesettings() done.";
}


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


void MainWindow::fromRecipesTree()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    PrinterDialog(PR_SUPPLIES, -1, this);
}


void MainWindow::on_actionYeast_bank_triggered()
{
    PrinterDialog(PR_YEASTBANK, -1, this);
}


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


void MainWindow::on_actionProd_inprod_triggered()
{
    ProdInprodWindow = new ProdInprod(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(ProdInprodWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Products in production").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


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


void MainWindow::on_actionOn_Name_triggered()
{
    ProdOnNameWindow = new ProdOnName(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(ProdOnNameWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Products archive on name").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


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


void MainWindow::on_actionOn_Code_triggered()
{
    ProdOnCodeWindow = new ProdOnCode(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(ProdOnCodeWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Products archive on code").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


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


void MainWindow::on_actionOn_Date_triggered()
{
    ProdOnDateWindow = new ProdOnDate(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(ProdOnDateWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Products archive on date").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


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


void MainWindow::on_actionOn_Tree_triggered()
{
    ProdOnTreeWindow = new ProdOnTree(this);
    int index = ui->mainStack->count();
    ui->mainStack->addWidget(ProdOnTreeWindow);
    ui->mainStack->setCurrentIndex(index);
    setWindowTitle(QString("BMSapp - %1 - Products archive on beerstyle").arg(VERSIONSTRING));
    ui->menuBar->setVisible(false);
}


void MainWindow::fromProfileWaters()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    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()
{
    ui->mainStack->setCurrentIndex(-1);
    ui->mainStack->removeWidget(SetupWindow);
    delete SetupWindow;
    setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
    ui->menuBar->setVisible(true);
    loadSetup();
}


void MainWindow::on_actionSetup_triggered()
{
    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