Line |
Branch |
Exec |
Source |
1 |
|
|
#include "gepetto/gui/fwd.hh" |
2 |
|
|
|
3 |
|
|
#include <QApplication> |
4 |
|
|
#include <QSettings> |
5 |
|
|
#include <QStyleFactory> |
6 |
|
|
#include <QProcessEnvironment> |
7 |
|
|
#include <QSplashScreen> |
8 |
|
|
#include <QIcon> |
9 |
|
|
#include <QtGlobal> |
10 |
|
|
|
11 |
|
|
#include <QItemSelection> |
12 |
|
|
|
13 |
|
|
#include "gepetto/gui/safeapplication.hh" |
14 |
|
|
#include "gepetto/gui/mainwindow.hh" |
15 |
|
|
#include "gepetto/gui/dialog/pluginmanagerdialog.hh" |
16 |
|
|
#include "gepetto/gui/settings.hh" |
17 |
|
|
|
18 |
|
|
using namespace gepetto::gui; |
19 |
|
|
|
20 |
|
|
// TODO check what version exactly already includes the metatype declaration. |
21 |
|
|
// It is not in 5.2.1 and it is in 5.5.1 |
22 |
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5,5,1)) |
23 |
|
|
Q_DECLARE_METATYPE(QItemSelection) |
24 |
|
|
#endif |
25 |
|
|
|
26 |
|
✗ |
void setupApplication () |
27 |
|
|
{ |
28 |
|
✗ |
QCoreApplication::setOrganizationName("gepetto-gui"); |
29 |
|
✗ |
QCoreApplication::setOrganizationDomain("https://github.com/Gepetto/gepetto-viewer"); |
30 |
|
✗ |
QCoreApplication::setApplicationName("gepetto-gui"); |
31 |
|
✗ |
QCoreApplication::setApplicationVersion("6.0.0"); |
32 |
|
|
|
33 |
|
✗ |
QStringList theme_paths = QIcon::themeSearchPaths(); |
34 |
|
✗ |
if (!theme_paths.contains("/usr/local/share/icons/")) { |
35 |
|
✗ |
theme_paths.prepend("/usr/local/share/icons/"); |
36 |
|
✗ |
QIcon::setThemeSearchPaths(theme_paths); |
37 |
|
|
} |
38 |
|
✗ |
QIcon::setThemeName("oxygen"); |
39 |
|
|
|
40 |
|
✗ |
qRegisterMetaType<std::string>("std::string"); |
41 |
|
✗ |
qRegisterMetaType<QItemSelection>("QItemSelection"); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
✗ |
int main(int argc, char *argv[]) |
45 |
|
|
{ |
46 |
|
✗ |
QApplication::setAttribute(Qt::AA_X11InitThreads); |
47 |
|
|
|
48 |
|
✗ |
SafeApplication a(argc, argv); |
49 |
|
|
|
50 |
|
✗ |
setupApplication(); |
51 |
|
|
|
52 |
|
|
// Set numeric locale to C so as not to disturb other libraries (like collada |
53 |
|
|
// dom) relying on sscanf (locale dependant) to convert string to double. |
54 |
|
✗ |
setlocale(LC_NUMERIC, "C"); |
55 |
|
|
|
56 |
|
✗ |
Settings settings ("/opt/openrobots"); |
57 |
|
✗ |
settings.setupPaths (); |
58 |
|
✗ |
switch (settings.initSettings (argc, argv)) { |
59 |
|
✗ |
case 0: |
60 |
|
✗ |
break; |
61 |
|
✗ |
case 1: |
62 |
|
✗ |
return 0; |
63 |
|
✗ |
case 2: |
64 |
|
✗ |
return 1; |
65 |
|
✗ |
default: |
66 |
|
✗ |
qDebug () << "Settings.fromArgv returned unknow error code"; |
67 |
|
✗ |
break; |
68 |
|
|
} |
69 |
|
|
|
70 |
|
✗ |
QStyle* style = QStyleFactory::create (settings.appStyle); |
71 |
|
✗ |
if (style==NULL) |
72 |
|
✗ |
qDebug() << "invalid style" << settings.appStyle; |
73 |
|
|
else |
74 |
|
✗ |
a.setStyle(style); |
75 |
|
|
|
76 |
|
✗ |
QPixmap pixmap(":/img/gepetto.png"); |
77 |
|
✗ |
a.setWindowIcon(pixmap); |
78 |
|
|
|
79 |
|
|
|
80 |
|
✗ |
QSplashScreen splash(pixmap); |
81 |
|
✗ |
splash.show(); |
82 |
|
✗ |
a.processEvents (); |
83 |
|
|
|
84 |
|
✗ |
MainWindow w (&settings); |
85 |
|
✗ |
w.setWindowIcon (pixmap); |
86 |
|
✗ |
settings.setMainWindow (&w); |
87 |
|
✗ |
settings.initPlugins (); |
88 |
|
✗ |
settings.restoreState (); |
89 |
|
✗ |
w.show(); |
90 |
|
✗ |
splash.finish(&w); |
91 |
|
✗ |
int retCode = a.exec(); |
92 |
|
✗ |
settings.saveState (); |
93 |
|
✗ |
return retCode; |
94 |
|
|
} |
95 |
|
|
|