src/MainWindow.cpp

Wed, 16 Feb 2022 22:11:29 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 16 Feb 2022 22:11:29 +0100
changeset 15
c58b82549713
parent 6
f8474f2c5db9
child 16
a5d8e783a7b0
permissions
-rw-r--r--

Started adding the global setup screen.

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"
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
20 #include "Setup.h"
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 #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
22 #include "config.h"
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 #include <QApplication>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 #include <QCloseEvent>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 #include <QDebug>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 #include <QStandardItem>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 #include <QWidget>
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
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 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 {
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
33 qDebug() << Q_FUNC_INFO;
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
34 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
35
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 setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) );
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 }
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 MainWindow::~MainWindow()
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 {
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
42 qDebug() << Q_FUNC_INFO;
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
43 delete ui;
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 }
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
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
47 void MainWindow::on_actionExit_triggered()
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
48 {
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
49 qDebug() << Q_FUNC_INFO;
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
50 this->close();
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
51 }
3
4b95e33ee476 We have a mainscreen!
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
53
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
54 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
55 {
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 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
57 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
58 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
59 }
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 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
63 {
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 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
65 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
66 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
67 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
68 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
69 }
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
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
72 void MainWindow::fromSetup()
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
73 {
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
74 qDebug() << Q_FUNC_INFO;
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
75 delete SetupWindow;
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
76 this->show();
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
77 }
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
78
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
79
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
80 void MainWindow::on_actionSetup_triggered()
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
81 {
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
82 qDebug() << Q_FUNC_INFO;
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
83 SetupWindow = new Setup(this);
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
84 QObject::connect(SetupWindow, SIGNAL(firstWindow()), this, SLOT(fromSetup()));
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
85 this->hide(); // Close the main window
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
86 SetupWindow->show(); // Show a second window
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
87 }
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
88
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
89
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
90 void MainWindow::on_actionAbout_triggered()
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
91 {
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
92 qDebug() << Q_FUNC_INFO;
4
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
93 AboutDialog dialog(this);
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
94 dialog.setModal(true);
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
95 dialog.exec();
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
96 }
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
97
fe106c497b75 Added About dialog
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
98

mercurial