1 #include <QApplication>
3 #include "flagrowobj.h"
4 #include "mainwindow.h"
10 TextEditor *textEditor; // used in Constr. of LinkableMapObj
11 // initialized in mainwindow
17 Main *mainWindow; // used in BranchObj::select()
18 QString tmpVymDir; // All temp files go there, created in mainwindow
19 QString clipboardDir; // Clipboard used in all mapEditors
20 QDir vymBaseDir; // Containing all styles, scripts, images, ...
23 QString iconPath; // Pointing to icons used for toolbars
24 QString flagsPath; // Pointing to flags
26 bool debug; // global debugging flag
27 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
28 FlagRowObj *standardFlagsDefault;
31 Settings settings ("InSilmaril","vym"); // Organization, Application name
36 int statusbarTime=3500;
38 int main(int argc, char* argv[])
40 //Q_INIT_RESOURCE (application);
42 QApplication app(argc,argv);
45 vymVersion=__VYM_VERSION;
46 vymBuildDate=__VYM_BUILD_DATE;
47 vymCodeName=__VYM_CODENAME;
50 // Reading and initializing options commandline options
51 options.add ("debug", Option::Switch, "d", "debug");
52 options.add ("version", Option::Switch, "v","version");
53 options.add ("local", Option::Switch, "l", "local");
54 options.add ("help", Option::Switch, "h", "help");
55 options.add ("quit", Option::Switch, "q", "quit");
56 options.add ("run", Option::String, "r", "run");
57 options.add ("test", Option::String, "t", "test");
59 "VYM - View Your Mind\n"
60 "--------------------\n\n"
61 "Information about vym can be found in vym.pdf,\n"
62 "which should be part of the vym package.\n"
63 "It is also available at the project homepage:\n\n"
64 "http://www.InSilmaril.de/vym\n");
67 cout << endl << options.getHelpText().ascii()<<endl;
71 debug=options.isOn ("debug");
73 if (options.isOn ("version"))
75 cout << "vym version "<<__VYM_VERSION
76 <<" (c) 2004-2007 Uwe Drechsel - "
78 <<" "<<__VYM_CODENAME<<endl;
83 // Use /usr/share/vym or /usr/local/share/vym or . ?
85 if (options.isOn ("local"))
87 vymBaseDir.setPath (vymBaseDir.currentDirPath());
89 // then look for environment variable
90 if (getenv("VYMHOME")!=0)
92 vymBaseDir.setPath (getenv("VYMHOME"));
94 // ok, let's find my way on my own
96 #if defined (Q_OS_MACX)
97 vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
100 vymBaseDir.setPath ("/usr/share/vym");
101 if (!vymBaseDir.exists())
103 vymBaseDir.setPath ("/usr/local/share/vym");
104 if (!vymBaseDir.exists())
105 vymBaseDir.setPath(vymBaseDir.currentDirPath() );
110 iconPath=vymBaseDir.path()+"/icons/";
111 flagsPath=vymBaseDir.path()+"/flags/";
114 lastImageDir=QDir().current();
115 lastFileDir=QDir().current();
117 if (options.isOn ("help"))
119 cout << options.getHelpText().ascii()<<endl;
123 // Initialize translations
124 QTranslator translator (0);
125 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
126 app.installTranslator( &translator );
128 // Initializing the row of system flags
129 // is done in first call to MapEditor(),
130 // because we need at least one canvas first
131 systemFlagsDefault=NULL;
132 standardFlagsDefault=NULL;
134 // Initialize window of TextEditor
135 textEditor = new TextEditor();
136 textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
137 if (textEditor->showWithMain()) textEditor->show();
139 // Initialize mainwindow
141 //m.resize(m.sizeHint());
142 m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
148 if (options.isOn ("run"))
151 QString fn=options.getArg ("run");
155 if ( !f.open( QIODevice::ReadOnly ) )
157 QMessageBox::warning(0,
158 QObject::tr("Error"),
159 QObject::tr("Couldn't open %1.\n").arg(fn));
163 QTextStream ts( &f );
166 m.setScript (script);
167 m.runScript (script);
171 // For benchmarking we may want to quit instead of entering event loop
172 if (options.isOn ("quit"))
177 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );