1 /* |
|
2 * LDForge: LDraw parts authoring CAD |
|
3 * Copyright (C) 2013 - 2015 Teemu Piippo |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation, either version 3 of the License, or |
|
8 * (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 |
|
19 #include <QApplication> |
|
20 #include <QMessageBox> |
|
21 #include <QAbstractButton> |
|
22 #include <QFile> |
|
23 #include <QTextStream> |
|
24 #include <QDir> |
|
25 #include "mainWindow.h" |
|
26 #include "ldDocument.h" |
|
27 #include "miscallenous.h" |
|
28 #include "configuration.h" |
|
29 #include "colors.h" |
|
30 #include "basics.h" |
|
31 #include "primitives.h" |
|
32 #include "glRenderer.h" |
|
33 #include "configDialog.h" |
|
34 #include "dialogs.h" |
|
35 #include "crashCatcher.h" |
|
36 |
|
37 MainWindow* g_win = null; |
|
38 static QString g_versionString, g_fullVersionString; |
|
39 static bool g_IsExiting (false); |
|
40 |
|
41 const Vertex Origin (0.0f, 0.0f, 0.0f); |
|
42 const Matrix IdentityMatrix ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); |
|
43 |
|
44 CFGENTRY (Bool, FirstStart, true) |
|
45 |
|
46 // ============================================================================= |
|
47 // |
|
48 int main (int argc, char* argv[]) |
|
49 { |
|
50 QApplication app (argc, argv); |
|
51 app.setOrganizationName (APPNAME); |
|
52 app.setApplicationName (APPNAME); |
|
53 InitCrashCatcher(); |
|
54 Config::Initialize(); |
|
55 |
|
56 // Load or create the configuration |
|
57 if (not Config::Load()) |
|
58 { |
|
59 print ("Creating configuration file...\n"); |
|
60 |
|
61 if (Config::Save()) |
|
62 print ("Configuration file successfully created.\n"); |
|
63 else |
|
64 Critical ("Failed to create configuration file!\n"); |
|
65 } |
|
66 |
|
67 LDPaths::initPaths(); |
|
68 InitColors(); |
|
69 LoadPrimitives(); |
|
70 MainWindow* win = new MainWindow; |
|
71 newFile(); |
|
72 win->show(); |
|
73 |
|
74 // If this is the first start, get the user to configuration. Especially point |
|
75 // them to the profile tab, it's the most important form to fill in. |
|
76 if (cfg::FirstStart) |
|
77 { |
|
78 (new ConfigDialog (ConfigDialog::ProfileTab))->exec(); |
|
79 cfg::FirstStart = false; |
|
80 Config::Save(); |
|
81 } |
|
82 |
|
83 // Process the command line |
|
84 for (int arg = 1; arg < argc; ++arg) |
|
85 OpenMainModel (QString::fromLocal8Bit (argv[arg])); |
|
86 |
|
87 int result = app.exec(); |
|
88 g_IsExiting = true; |
|
89 return result; |
|
90 } |
|
91 |
|
92 bool IsExiting() |
|
93 { |
|
94 return g_IsExiting; |
|
95 } |
|
96 |
|
97 void Exit() |
|
98 { |
|
99 g_IsExiting = true; |
|
100 exit (EXIT_SUCCESS); |
|
101 } |
|