1 #include <QApplication>
6 #include "flagrowobj.h"
7 #include "mainwindow.h"
12 #if defined(Q_OS_WIN32)
13 #define WIN32_LEAN_AND_MEAN
18 TextEditor *textEditor; // used in Constr. of LinkableMapObj
19 // initialized in mainwindow
25 Main *mainWindow; // used in BranchObj::select()
26 QString tmpVymDir; // All temp files go there, created in mainwindow
27 QString clipboardDir; // Clipboard used in all mapEditors
28 QString clipboardFile; // Clipboard used in all mapEditors
29 QDir vymBaseDir; // Containing all styles, scripts, images, ...
32 #if defined(Q_OS_WIN32)
35 QString iconPath; // Pointing to icons used for toolbars
36 QString flagsPath; // Pointing to flags
38 bool debug; // global debugging flag
39 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
40 FlagRowObj *standardFlagsDefault;
43 Settings settings ("InSilmaril","vym"); // Organization, Application name
48 int statusbarTime=3500;
50 int main(int argc, char* argv[])
52 //Q_INIT_RESOURCE (application);
54 QApplication app(argc,argv);
57 vymVersion=__VYM_VERSION;
58 vymBuildDate=__VYM_BUILD_DATE;
59 vymCodeName=__VYM_CODENAME;
62 // Reading and initializing options commandline options
63 options.add ("debug", Option::Switch, "d", "debug");
64 options.add ("version", Option::Switch, "v","version");
65 options.add ("local", Option::Switch, "l", "local");
66 options.add ("help", Option::Switch, "h", "help");
67 options.add ("quit", Option::Switch, "q", "quit");
68 options.add ("run", Option::String, "r", "run");
69 options.add ("test", Option::String, "t", "test");
71 "VYM - View Your Mind\n"
72 "--------------------\n\n"
73 "Information about vym can be found in vym.pdf,\n"
74 "which should be part of the vym package.\n"
75 "It is also available at the project homepage:\n\n"
76 "http://www.InSilmaril.de/vym\n");
79 cout << endl << qPrintable( options.getHelpText())<<endl;
83 debug=options.isOn ("debug");
85 if (options.isOn ("version"))
87 cout << "VYM - View Your Mind (c) 2004-2007 Uwe Drechsel " << endl
88 <<" Version: "<<__VYM_VERSION <<endl
89 <<"Build date: "<<__VYM_BUILD_DATE << endl
90 <<" "<<__VYM_CODENAME<<endl;
95 // Use /usr/share/vym or /usr/local/share/vym or . ?
97 if (options.isOn ("local"))
99 vymBaseDir.setPath (vymBaseDir.currentDirPath());
101 // then look for environment variable
102 if (getenv("VYMHOME")!=0)
104 vymBaseDir.setPath (getenv("VYMHOME"));
106 // ok, let's find my way on my own
108 #if defined (Q_OS_MACX)
109 vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
111 #elif defined (Q_OS_WIN32)
115 if (GetModuleFileName(NULL, wbuf, 512))
117 QString mfn(QString::fromWCharArray(wbuf));
118 mfn.replace('\\', '/');
119 if (mfn.endsWith("/bin/vym.exe", Qt::CaseInsensitive))
126 if (basePath.isEmpty())
127 basePath = vymBaseDir.currentDirPath();
129 vymInstallDir.setPath(basePath);
130 vymBaseDir.setPath(basePath + "/share/vym");
133 vymBaseDir.setPath ("/usr/share/vym");
134 if (!vymBaseDir.exists())
136 vymBaseDir.setPath ("/usr/local/share/vym");
137 if (!vymBaseDir.exists())
138 vymBaseDir.setPath(vymBaseDir.currentDirPath() );
143 iconPath=vymBaseDir.path()+"/icons/";
144 flagsPath=vymBaseDir.path()+"/flags/";
147 lastImageDir=QDir().current();
148 lastFileDir=QDir().current();
150 if (options.isOn ("help"))
152 cout << qPrintable (options.getHelpText())<<endl;
156 // Initialize translations
157 QTranslator translator (0);
158 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
159 app.installTranslator( &translator );
161 // Initializing the row of system flags
162 // is done in first call to MapEditor(),
163 // because we need at least one canvas first
164 systemFlagsDefault=NULL;
165 standardFlagsDefault=NULL;
167 // Initialize window of TextEditor
168 textEditor = new TextEditor();
169 textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
171 // Initialize mainwindow
172 #if defined(Q_OS_WIN32)
173 Main m(0, 0, (Qt::Window | Qt::MSWindowsOwnDC));
178 //m.resize(m.sizeHint());
179 m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
185 if (options.isOn ("run"))
188 QString fn=options.getArg ("run");
192 if ( !f.open( QIODevice::ReadOnly ) )
194 QMessageBox::warning(0,
195 QObject::tr("Error"),
196 QObject::tr("Couldn't open %1.\n").arg(fn));
200 QTextStream ts( &f );
203 m.setScript (script);
204 m.runScriptEverywhere (script);
208 // For benchmarking we may want to quit instead of entering event loop
209 if (options.isOn ("quit"))
214 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );