|
1 | | -/**************************************************************************** |
2 | | - * * |
3 | | - * ATOM ARCHITECT * |
4 | | - * Copyright (C) 2020-2024 Ivo Filot <i.a.w.filot@tue.nl> * |
5 | | - * * |
6 | | - * This program is free software: you can redistribute it and/or modify * |
7 | | - * it under the terms of the GNU Lesser General Public License as * |
8 | | - * published by the Free Software Foundation, either version 3 of the * |
9 | | - * License, or (at your option) any later version. * |
10 | | - * * |
11 | | - * This program is distributed in the hope that it will be useful, * |
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
14 | | - * GNU General Public License for more details. * |
15 | | - * * |
16 | | - * You should have received a copy of the GNU General Public license * |
17 | | - * along with this program. If not, see <https://www.gnu.org/licenses/>. * |
18 | | - * * |
19 | | - ****************************************************************************/ |
20 | | - |
21 | | -#include "atomarchitectapplication.h" |
22 | | - |
23 | | -/** |
24 | | - * @brief Default constructor |
25 | | - * @param argc number of command line argument |
26 | | - * @param argv command line arguments |
27 | | - */ |
28 | | -AtomArchitectApplication::AtomArchitectApplication(int& argc, char** argv) : |
29 | | -QApplication(argc, argv) {} |
30 | | - |
31 | | -/** |
32 | | - * @brief notify |
33 | | - * @param receiver |
34 | | - * @param event |
35 | | - * @return |
36 | | - */ |
37 | | -bool AtomArchitectApplication::notify(QObject* receiver, QEvent* event) { |
38 | | - bool done = true; |
39 | | - try { |
40 | | - done = QApplication::notify(receiver, event); |
41 | | - } catch (const std::exception& e) { |
42 | | - this->throw_message_window(tr("Uncaught exception was thrown."), |
43 | | - tr("An uncaught exception was thrown by the program. This is undiserable behavior and " |
44 | | - "the program will be terminated. Please carefully read the error message " |
45 | | - "and consult the manual or contact one of the developers.\n\nError:\n") + e.what()); |
46 | | - throw(e); |
47 | | - } |
48 | | - return done; |
49 | | -} |
50 | | - |
51 | | - |
52 | | -void AtomArchitectApplication::throw_message_window(const QString& title, const QString& message) { |
53 | | - QMessageBox message_box; |
54 | | - message_box.setText(message); |
55 | | - message_box.setIcon(QMessageBox::Critical); |
56 | | - message_box.setWindowTitle(title); |
57 | | - message_box.setWindowIcon(QIcon(":/assets/icon/atom_architect_256.ico")); |
58 | | - message_box.exec(); |
59 | | -} |
| 1 | +/**************************************************************************** |
| 2 | + * * |
| 3 | + * ATOM ARCHITECT * |
| 4 | + * Copyright (C) 2020-2026 Ivo Filot <i.a.w.filot@tue.nl> * |
| 5 | + * * |
| 6 | + * This program is free software: you can redistribute it and/or modify * |
| 7 | + * it under the terms of the GNU Lesser General Public License as * |
| 8 | + * published by the Free Software Foundation, either version 3 of the * |
| 9 | + * License, or (at your option) any later version. * |
| 10 | + * * |
| 11 | + * This program is distributed in the hope that it will be useful, * |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | + * GNU General Public License for more details. * |
| 15 | + * * |
| 16 | + * You should have received a copy of the GNU General Public license * |
| 17 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. * |
| 18 | + * * |
| 19 | + ****************************************************************************/ |
| 20 | + |
| 21 | +#include "atomarchitectapplication.h" |
| 22 | + |
| 23 | +/** |
| 24 | + * @brief Default constructor |
| 25 | + * @param argc number of command line argument |
| 26 | + * @param argv command line arguments |
| 27 | + */ |
| 28 | +AtomArchitectApplication::AtomArchitectApplication(int& argc, char** argv) : |
| 29 | +QApplication(argc, argv) {} |
| 30 | + |
| 31 | + /** |
| 32 | + * @brief notify |
| 33 | + * @param receiver |
| 34 | + * @param event |
| 35 | + * @return |
| 36 | + */ |
| 37 | +bool AtomArchitectApplication::notify(QObject* receiver, QEvent* event) { |
| 38 | + bool done = true; |
| 39 | + try { |
| 40 | + done = QApplication::notify(receiver, event); |
| 41 | + } catch (const std::exception& e) { |
| 42 | + this->throw_message_window(tr("Uncaught exception was thrown."), |
| 43 | + tr("An uncaught exception was thrown by the program. This is undiserable behavior and " |
| 44 | + "the program will be terminated. Please carefully read the error message " |
| 45 | + "and consult the manual or contact one of the developers.\n\nError:\n") + e.what()); |
| 46 | + throw(e); |
| 47 | + } |
| 48 | + return done; |
| 49 | +} |
| 50 | + |
| 51 | + |
| 52 | +/** |
| 53 | + * @brief throw_message_window. |
| 54 | + * |
| 55 | + * @param title Parameter title. |
| 56 | + * @param message Parameter message. |
| 57 | + */ |
| 58 | +void AtomArchitectApplication::throw_message_window(const QString& title, const QString& message) { |
| 59 | + QMessageBox message_box; |
| 60 | + message_box.setText(message); |
| 61 | + message_box.setIcon(QMessageBox::Critical); |
| 62 | + message_box.setWindowTitle(title); |
| 63 | + message_box.setWindowIcon(QIcon(":/assets/icon/atom_architect_256.ico")); |
| 64 | + message_box.exec(); |
| 65 | +} |
0 commit comments