src/main.cpp

changeset 971
c00f9665a9f8
parent 970
c8aae45afd85
child 972
a34b73114823
equal deleted inserted replaced
970:c8aae45afd85 971:c00f9665a9f8
23 #include <QTextStream> 23 #include <QTextStream>
24 #include <QDir> 24 #include <QDir>
25 #include "mainwindow.h" 25 #include "mainwindow.h"
26 #include "ldDocument.h" 26 #include "ldDocument.h"
27 #include "miscallenous.h" 27 #include "miscallenous.h"
28 #include "configuration.h"
29 #include "colors.h" 28 #include "colors.h"
30 #include "basics.h" 29 #include "basics.h"
31 #include "primitives.h" 30 #include "primitives.h"
32 #include "glRenderer.h" 31 #include "glRenderer.h"
33 #include "configDialog.h"
34 #include "dialogs.h" 32 #include "dialogs.h"
35 #include "crashCatcher.h" 33 #include "crashCatcher.h"
36 #include "ldpaths.h" 34 #include "ldpaths.h"
37 35
38 MainWindow* g_win = null; 36 MainWindow* g_win = null;
40 static bool g_IsExiting (false); 38 static bool g_IsExiting (false);
41 39
42 const Vertex Origin (0.0f, 0.0f, 0.0f); 40 const Vertex Origin (0.0f, 0.0f, 0.0f);
43 const Matrix IdentityMatrix ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); 41 const Matrix IdentityMatrix ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f});
44 42
45 ConfigOption (bool firstStart = true) 43 ConfigOption (bool FirstStart = true)
46 44
47 // ============================================================================= 45 // =============================================================================
48 // 46 //
49 int main (int argc, char* argv[]) 47 int main (int argc, char* argv[])
50 { 48 {
51 QApplication app (argc, argv); 49 QApplication app (argc, argv);
52 app.setOrganizationName (APPNAME); 50 app.setOrganizationName (APPNAME);
53 app.setApplicationName (APPNAME); 51 app.setApplicationName (APPNAME);
54 initCrashCatcher(); 52 initCrashCatcher();
55 Config::Initialize();
56
57 // Load or create the configuration
58 if (not Config::Load())
59 {
60 print ("Creating configuration file...\n");
61
62 if (Config::Save())
63 print ("Configuration file successfully created.\n");
64 else
65 Critical ("Failed to create configuration file!\n");
66 }
67
68 MainWindow* win = new MainWindow; 53 MainWindow* win = new MainWindow;
69 LDPaths* paths = new LDPaths (win); 54 LDPaths* paths = new LDPaths (win);
70 paths->checkPaths(); 55 paths->checkPaths();
71 paths->deleteLater(); 56 paths->deleteLater();
72 InitColors(); 57 InitColors();
73 LoadPrimitives(); 58 LoadPrimitives();
74 newFile(); 59 newFile();
75 win->show(); 60 win->show();
76
77 // If this is the first start, get the user to configuration. Especially point
78 // them to the profile tab, it's the most important form to fill in.
79 if (win->configBag()->firstStart)
80 {
81 (new ConfigDialog (ConfigDialog::ProfileTab))->exec();
82 win->configBag()->firstStart = false;
83 Config::Save();
84 }
85 61
86 // Process the command line 62 // Process the command line
87 for (int arg = 1; arg < argc; ++arg) 63 for (int arg = 1; arg < argc; ++arg)
88 OpenMainModel (QString::fromLocal8Bit (argv[arg])); 64 OpenMainModel (QString::fromLocal8Bit (argv[arg]));
89 65

mercurial