src/MainWindow.cpp

Sat, 12 Feb 2022 21:24:43 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 12 Feb 2022 21:24:43 +0100
changeset 6
f8474f2c5db9
parent 4
fe106c497b75
child 15
c58b82549713
permissions
-rw-r--r--

We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5

/**
 * 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 "InventorySuppliers.h"
#include "../ui/ui_MainWindow.h"
#include "config.h"

#include <QApplication>
#include <QCloseEvent>
#include <QDebug>
#include <QStandardItem>
#include <QWidget>


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::fromInventorySuppliers()
{
    qDebug() << Q_FUNC_INFO;
    delete InventorySuppliersWindow;
    this->show();
}


void MainWindow::on_actionSuppliers_triggered()
{
    qDebug() << Q_FUNC_INFO;
    InventorySuppliersWindow = new InventorySuppliers(this);
    QObject::connect(InventorySuppliersWindow, SIGNAL(firstWindow()), this, SLOT(fromInventorySuppliers()));
    this->hide();    // Close the main window
    InventorySuppliersWindow->show();  // Show a second window
}


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

mercurial