src/MainWindow.cpp

Fri, 18 Feb 2022 15:53:02 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 18 Feb 2022 15:53:02 +0100
changeset 19
c94edc758a5b
parent 16
a5d8e783a7b0
child 24
684c6e74cc1b
permissions
-rw-r--r--

Added Inventory Fermentables table.

4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
1 /**
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
2 * MainWindow.cpp is part of bmsapp.
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
3 *
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
5 * it under the terms of the GNU General Public License as published by
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
7 * (at your option) any later version.
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
8 *
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
12 * GNU General Public License for more details.
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
13 *
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
14 * You should have received a copy of the GNU General Public License
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
16 */
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "MainWindow.h"
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
18 #include "AboutDialog.h"
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
19 #include "InventorySuppliers.h"
19
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
20 #include "InventoryFermentables.h"
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
21 #include "Setup.h"
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 #include "../ui/ui_MainWindow.h"
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
23 #include "config.h"
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 #include <QApplication>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 #include <QCloseEvent>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 #include <QDebug>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 #include <QStandardItem>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 #include <QWidget>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 {
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
34 qDebug() << Q_FUNC_INFO;
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
35 ui->setupUi(this);
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
36
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
37 setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 }
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 MainWindow::~MainWindow()
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 {
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
43 qDebug() << Q_FUNC_INFO;
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
44 delete ui;
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 }
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
48 void MainWindow::on_actionExit_triggered()
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
49 {
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
50 qDebug() << Q_FUNC_INFO;
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
51 this->close();
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
52 }
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
54
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
55 void MainWindow::fromInventorySuppliers()
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
56 {
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
57 qDebug() << Q_FUNC_INFO;
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
58 delete InventorySuppliersWindow;
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
59 this->show();
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
60 }
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
61
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
62
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
63 void MainWindow::on_actionSuppliers_triggered()
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
64 {
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
65 qDebug() << Q_FUNC_INFO;
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
66 InventorySuppliersWindow = new InventorySuppliers(this);
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
67 QObject::connect(InventorySuppliersWindow, SIGNAL(firstWindow()), this, SLOT(fromInventorySuppliers()));
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
68 this->hide(); // Close the main window
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
69 InventorySuppliersWindow->show(); // Show a second window
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
70 }
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
71
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
72
19
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
73 void MainWindow::fromInventoryFermentables()
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
74 {
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
75 qDebug() << Q_FUNC_INFO;
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
76 delete InventoryFermentablesWindow;
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
77 this->show();
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
78 }
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
79
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
80
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
81 void MainWindow::on_actionFermentables_triggered()
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
82 {
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
83 qDebug() << Q_FUNC_INFO;
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
84 InventoryFermentablesWindow = new InventoryFermentables(this);
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
85 QObject::connect(InventoryFermentablesWindow, SIGNAL(firstWindow()), this, SLOT(fromInventoryFermentables()));
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
86 this->hide(); // Close the main window
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
87 InventoryFermentablesWindow->show(); // Show a second window
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
88 }
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
89
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
90
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
91 void MainWindow::fromSetup()
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
92 {
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
93 qDebug() << Q_FUNC_INFO;
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
94 delete SetupWindow;
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
95 this->show();
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
96 }
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
97
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
98
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
99 void MainWindow::on_actionSetup_triggered()
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
100 {
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
101 qDebug() << Q_FUNC_INFO;
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
102 SetupWindow = new Setup(this);
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
103 QObject::connect(SetupWindow, SIGNAL(firstWindow()), this, SLOT(fromSetup()));
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
104 this->hide(); // Close the main window
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
105 SetupWindow->show(); // Show a setup window
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
106 }
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
107
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
108
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
109 void MainWindow::on_actionAbout_triggered()
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
110 {
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
111 AboutDialog dialog(this);
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
112 dialog.setModal(true);
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
113 dialog.exec();
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
114 }
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
115
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
116

mercurial