1 #include <QApplication>
4 #include "flagrowobj.h"
5 #include "mainwindow.h"
10 #if defined(Q_OS_WIN32)
11 #define WIN32_LEAN_AND_MEAN
16 TextEditor *textEditor; // used in Constr. of LinkableMapObj
17 // initialized in mainwindow
23 Main *mainWindow; // used in BranchObj::select()
24 QString tmpVymDir; // All temp files go there, created in mainwindow
25 QString clipboardDir; // Clipboard used in all mapEditors
26 QString clipboardFile; // Clipboard used in all mapEditors
27 QDir vymBaseDir; // Containing all styles, scripts, images, ...
30 #if defined(Q_OS_WIN32)
33 QString iconPath; // Pointing to icons used for toolbars
34 QString flagsPath; // Pointing to flags
36 bool debug; // global debugging flag
37 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
38 FlagRowObj *standardFlagsDefault;
41 Settings settings ("InSilmaril","vym"); // Organization, Application name
46 int statusbarTime=3500;
48 int main(int argc, char* argv[])
50 //Q_INIT_RESOURCE (application);
52 QApplication app(argc,argv);
55 vymVersion=__VYM_VERSION;
56 vymBuildDate=__VYM_BUILD_DATE;
57 vymCodeName=__VYM_CODENAME;
60 // Reading and initializing options commandline options
61 options.add ("debug", Option::Switch, "d", "debug");
62 options.add ("version", Option::Switch, "v","version");
63 options.add ("local", Option::Switch, "l", "local");
64 options.add ("help", Option::Switch, "h", "help");
65 options.add ("quit", Option::Switch, "q", "quit");
66 options.add ("run", Option::String, "r", "run");
67 options.add ("test", Option::String, "t", "test");
69 "VYM - View Your Mind\n"
70 "--------------------\n\n"
71 "Information about vym can be found in vym.pdf,\n"
72 "which should be part of the vym package.\n"
73 "It is also available at the project homepage:\n\n"
74 "http://www.InSilmaril.de/vym\n");
77 cout << endl << qPrintable( options.getHelpText())<<endl;
81 debug=options.isOn ("debug");
83 if (options.isOn ("version"))
85 cout << "VYM - View Your Mind (c) 2004-2007 Uwe Drechsel " << endl
86 <<" Version: "<<__VYM_VERSION <<endl
87 <<"Build date: "<<__VYM_BUILD_DATE << endl
88 <<" "<<__VYM_CODENAME<<endl;
93 // Use /usr/share/vym or /usr/local/share/vym or . ?
95 if (options.isOn ("local"))
97 vymBaseDir.setPath (vymBaseDir.currentDirPath());
99 // then look for environment variable
100 if (getenv("VYMHOME")!=0)
102 vymBaseDir.setPath (getenv("VYMHOME"));
104 // ok, let's find my way on my own
106 #if defined (Q_OS_MACX)
107 vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
109 #elif defined (Q_OS_WIN32)
113 if (GetModuleFileName(NULL, wbuf, 512))
115 QString mfn(QString::fromWCharArray(wbuf));
116 mfn.replace('\\', '/');
117 if (mfn.endsWith("/bin/vym.exe", Qt::CaseInsensitive))
124 if (basePath.isEmpty())
125 basePath = vymBaseDir.currentDirPath();
127 vymInstallDir.setPath(basePath);
128 vymBaseDir.setPath(basePath + "/share/vym");
131 vymBaseDir.setPath ("/usr/share/vym");
132 if (!vymBaseDir.exists())
134 vymBaseDir.setPath ("/usr/local/share/vym");
135 if (!vymBaseDir.exists())
136 vymBaseDir.setPath(vymBaseDir.currentDirPath() );
141 iconPath=vymBaseDir.path()+"/icons/";
142 flagsPath=vymBaseDir.path()+"/flags/";
145 lastImageDir=QDir().current();
146 lastFileDir=QDir().current();
148 if (options.isOn ("help"))
150 cout << qPrintable (options.getHelpText())<<endl;
154 // Initialize translations
155 QTranslator translator (0);
156 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
157 app.installTranslator( &translator );
159 // Initializing the row of system flags
160 // is done in first call to MapEditor(),
161 // because we need at least one canvas first
162 systemFlagsDefault=NULL;
163 standardFlagsDefault=NULL;
165 // Initialize window of TextEditor
166 textEditor = new TextEditor();
167 textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
169 // Initialize mainwindow
170 #if defined(Q_OS_WIN32)
171 Main m(0, 0, (Qt::Window | Qt::MSWindowsOwnDC));
176 //m.resize(m.sizeHint());
177 m.setIcon (QPixmap (iconPath+"vym.png"));
183 if (options.isOn ("run"))
186 QString fn=options.getArg ("run");
190 if ( !f.open( QIODevice::ReadOnly ) )
192 QMessageBox::warning(0,
193 QObject::tr("Error"),
194 QObject::tr("Couldn't open %1.\n").arg(fn));
198 QTextStream ts( &f );
201 m.setScript (script);
202 m.runScriptEverywhere (script);
206 // For benchmarking we may want to quit instead of entering event loop
207 if (options.isOn ("quit"))
212 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );