insilmaril@366
|
1 |
#include <QApplication>
|
insilmaril@366
|
2 |
#include <q3network.h>
|
insilmaril@0
|
3 |
|
insilmaril@404
|
4 |
#include "flagrowobj.h"
|
insilmaril@404
|
5 |
#include "mainwindow.h"
|
insilmaril@404
|
6 |
#include "options.h"
|
insilmaril@0
|
7 |
#include "settings.h"
|
insilmaril@404
|
8 |
#include "version.h"
|
insilmaril@0
|
9 |
|
insilmaril@0
|
10 |
// Global variables
|
insilmaril@0
|
11 |
TextEditor *textEditor; // used in Constr. of LinkableMapObj
|
insilmaril@0
|
12 |
// initialized in mainwindow
|
insilmaril@406
|
13 |
QString vymName;
|
insilmaril@406
|
14 |
QString vymVersion;
|
insilmaril@406
|
15 |
QString vymBuildDate;
|
insilmaril@0
|
16 |
|
insilmaril@0
|
17 |
Main *mainWindow; // used in BranchObj::select()
|
insilmaril@164
|
18 |
QString tmpVymDir; // All temp files go there, created in mainwindow
|
insilmaril@166
|
19 |
QString clipboardDir; // Clipboard used in all mapEditors
|
insilmaril@215
|
20 |
QDir vymBaseDir; // Containing all styles, scripts, images, ...
|
insilmaril@366
|
21 |
QDir lastImageDir;
|
insilmaril@366
|
22 |
QDir lastFileDir;
|
insilmaril@269
|
23 |
QString iconPath; // Pointing to icons used for toolbars
|
insilmaril@269
|
24 |
QString flagsPath; // Pointing to flags
|
insilmaril@166
|
25 |
bool clipboardEmpty;
|
insilmaril@0
|
26 |
FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
|
insilmaril@0
|
27 |
FlagRowObj *standardFlagsDefault;
|
insilmaril@0
|
28 |
|
insilmaril@366
|
29 |
|
insilmaril@366
|
30 |
Settings settings ("InSilmaril","vym"); // Organization, Application name
|
insilmaril@366
|
31 |
|
insilmaril@0
|
32 |
Options options;
|
insilmaril@366
|
33 |
ImageIO imageIO;
|
insilmaril@0
|
34 |
|
insilmaril@0
|
35 |
int statusbarTime=3500;
|
insilmaril@0
|
36 |
|
insilmaril@394
|
37 |
int main(int argc, char* argv[])
|
insilmaril@0
|
38 |
{
|
insilmaril@394
|
39 |
//Q_INIT_RESOURCE (application);
|
insilmaril@366
|
40 |
|
insilmaril@0
|
41 |
QApplication app(argc,argv);
|
insilmaril@0
|
42 |
|
insilmaril@406
|
43 |
vymName=__VYM_NAME;
|
insilmaril@406
|
44 |
vymVersion=__VYM_VERSION;
|
insilmaril@406
|
45 |
vymBuildDate=__VYM_BUILD_DATE;
|
insilmaril@406
|
46 |
|
insilmaril@0
|
47 |
|
insilmaril@0
|
48 |
// Reading and initializing options commandline options
|
insilmaril@0
|
49 |
options.add ("version", SwitchOption, "v","version");
|
insilmaril@243
|
50 |
options.add ("local", SwitchOption, "l", "local");
|
insilmaril@0
|
51 |
options.add ("help", SwitchOption, "h", "help");
|
insilmaril@0
|
52 |
options.add ("quit", SwitchOption, "q", "quit");
|
insilmaril@0
|
53 |
options.add ("test", StringOption, "t", "test");
|
insilmaril@0
|
54 |
options.setHelpText (
|
insilmaril@0
|
55 |
"VYM - View Your Mind\n"
|
insilmaril@0
|
56 |
"--------------------\n\n"
|
insilmaril@0
|
57 |
"Information about vym can be found in vym.pdf,\n"
|
insilmaril@0
|
58 |
"which should be part of the vym package.\n"
|
insilmaril@0
|
59 |
"It is also available at the project homepage:\n\n"
|
insilmaril@0
|
60 |
"http://www.InSilmaril.de/vym\n");
|
insilmaril@0
|
61 |
if (options.parse())
|
insilmaril@0
|
62 |
{
|
insilmaril@366
|
63 |
cout << endl << options.getHelpText().ascii()<<endl;
|
insilmaril@0
|
64 |
return 1;
|
insilmaril@0
|
65 |
}
|
insilmaril@0
|
66 |
|
insilmaril@0
|
67 |
if (options.isOn ("version"))
|
insilmaril@0
|
68 |
{
|
insilmaril@185
|
69 |
cout << "vym version "<<__VYM_VERSION
|
insilmaril@366
|
70 |
<<" (c) 2004-2006 Uwe Drechsel - "
|
insilmaril@404
|
71 |
<<__VYM_BUILD_DATE<<endl;
|
insilmaril@0
|
72 |
|
insilmaril@0
|
73 |
return 0;
|
insilmaril@0
|
74 |
}
|
insilmaril@0
|
75 |
|
insilmaril@243
|
76 |
// Use /usr/share/vym or /usr/local/share/vym or . ?
|
insilmaril@269
|
77 |
// First try options
|
insilmaril@243
|
78 |
if (options.isOn ("local"))
|
insilmaril@243
|
79 |
{
|
insilmaril@243
|
80 |
vymBaseDir.setPath (vymBaseDir.currentDirPath());
|
insilmaril@269
|
81 |
} else
|
insilmaril@269
|
82 |
// then look for environment variable
|
insilmaril@269
|
83 |
if (getenv("VYMHOME")!=0)
|
insilmaril@269
|
84 |
{
|
insilmaril@269
|
85 |
vymBaseDir.setPath (getenv("VYMHOME"));
|
insilmaril@269
|
86 |
} else
|
insilmaril@269
|
87 |
// ok, let's find my way on my own
|
insilmaril@243
|
88 |
{
|
insilmaril@390
|
89 |
#if defined (Q_OS_MACX)
|
insilmaril@394
|
90 |
vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
|
insilmaril@390
|
91 |
|
insilmaril@390
|
92 |
#else
|
insilmaril@390
|
93 |
vymBaseDir.setPath ("/usr/share/vym");
|
insilmaril@308
|
94 |
if (!vymBaseDir.exists())
|
insilmaril@390
|
95 |
{
|
insilmaril@390
|
96 |
vymBaseDir.setPath ("/usr/local/share/vym");
|
insilmaril@390
|
97 |
if (!vymBaseDir.exists())
|
insilmaril@390
|
98 |
vymBaseDir.setPath(vymBaseDir.currentDirPath() );
|
insilmaril@390
|
99 |
}
|
insilmaril@390
|
100 |
#endif
|
insilmaril@243
|
101 |
}
|
insilmaril@243
|
102 |
|
insilmaril@269
|
103 |
iconPath=vymBaseDir.path()+"/icons/";
|
insilmaril@269
|
104 |
flagsPath=vymBaseDir.path()+"/flags/";
|
insilmaril@269
|
105 |
|
insilmaril@366
|
106 |
// Some directories
|
insilmaril@366
|
107 |
lastImageDir=QDir().current();
|
insilmaril@366
|
108 |
lastFileDir=QDir().current();
|
insilmaril@366
|
109 |
|
insilmaril@0
|
110 |
if (options.isOn ("help"))
|
insilmaril@0
|
111 |
{
|
insilmaril@366
|
112 |
cout << options.getHelpText().ascii()<<endl;
|
insilmaril@0
|
113 |
return 0;
|
insilmaril@0
|
114 |
}
|
insilmaril@0
|
115 |
|
insilmaril@366
|
116 |
q3InitNetworkProtocols();
|
insilmaril@243
|
117 |
|
insilmaril@243
|
118 |
|
insilmaril@243
|
119 |
// Initialize translations
|
insilmaril@243
|
120 |
QTranslator translator (0);
|
insilmaril@243
|
121 |
translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
|
insilmaril@243
|
122 |
app.installTranslator( &translator );
|
insilmaril@243
|
123 |
|
insilmaril@243
|
124 |
// Initializing the row of system flags
|
insilmaril@243
|
125 |
// is done in first call to MapEditor(),
|
insilmaril@243
|
126 |
// because we need at least one canvas first
|
insilmaril@243
|
127 |
systemFlagsDefault=NULL;
|
insilmaril@243
|
128 |
standardFlagsDefault=NULL;
|
insilmaril@243
|
129 |
|
insilmaril@0
|
130 |
// Initialize window of TextEditor
|
insilmaril@0
|
131 |
textEditor = new TextEditor();
|
insilmaril@269
|
132 |
textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
|
insilmaril@0
|
133 |
if (textEditor->showWithMain()) textEditor->show();
|
insilmaril@0
|
134 |
|
insilmaril@166
|
135 |
// Initialize mainwindow
|
insilmaril@0
|
136 |
Main m;
|
insilmaril@0
|
137 |
//m.resize(m.sizeHint());
|
insilmaril@269
|
138 |
m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
|
insilmaril@0
|
139 |
m.show();
|
insilmaril@0
|
140 |
m.fileNew();
|
insilmaril@0
|
141 |
m.loadCmdLine();
|
insilmaril@0
|
142 |
|
insilmaril@0
|
143 |
// For benchmarking we may want to quit immediatly after drawing
|
insilmaril@0
|
144 |
if (options.isOn ("quit"))
|
insilmaril@0
|
145 |
{
|
insilmaril@0
|
146 |
return 0;
|
insilmaril@0
|
147 |
}
|
insilmaril@0
|
148 |
|
insilmaril@0
|
149 |
QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
|
insilmaril@0
|
150 |
|
insilmaril@0
|
151 |
return app.exec();
|
insilmaril@0
|
152 |
}
|
insilmaril@0
|
153 |
|