-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
86 lines (78 loc) · 2.11 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <ShapesDialog.hpp>
#include <QtWidgets/QApplication>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include "getargs.hxx"
#ifdef _WIN32
#include <Windows.h>
#endif
#ifdef TESTBUILD
#include <QtTest/QtTest>
#endif
/**
* @addtogroup demos_iShapes ISO C++ DCPS iShapes Demonstrator Application
* Refer to @ref ishapes_readme for information on building and running
* this demo.
*/
/** @{*/
/** @dir */
/** @file */
namespace demo { namespace ishapes {
class iShapes : public QApplication {
public:
iShapes(int& argc, char ** argv) :
QApplication(argc, argv) { }
virtual ~iShapes() { }
// reimplemented from QApplication so we can throw exceptions in slots
virtual bool notify(QObject * receiver, QEvent * event)
{
try
{
return QApplication::notify(receiver, event);
}
catch(std::exception& e)
{
std::string message = "Exception caught:-\n";
message += e.what();
QString qmessage(message.c_str());
QMessageBox::critical(NULL, "Error", qmessage);
}
return false;
}
};
}}
int main(int argc, char **argv)
{
srand(clock());
demo::ishapes::iShapes app(argc, argv);
#ifdef TESTBUILD
Q_INIT_RESOURCE(ishape_qrc);
#else
Q_INIT_RESOURCE(ishape);
#endif
int retval;
try
{
demo::ishapes::ShapesDialog shapes;
auto &&[config, args] =
ConfigCliArgParser(argc, argv)
.run();
shapes.setConfiguration(std::move(config));
#ifdef _WIN32
FreeConsole();
#endif
shapes.show();
retval = app.exec();
}
catch(zenoh::ZException e)
{
std::string message = "Exception caught:-\n";
//message += e.what();
QString qmessage(message.c_str());
QMessageBox::critical(NULL, "Error", qmessage);
retval = 1;
}
return retval;
}
/** @}*/