GPL V2. Added settings to documentation
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 QString clipboardFile; // Clipboard used in all mapEditors
21 QDir vymBaseDir; // Containing all styles, scripts, images, ...
24 QString iconPath; // Pointing to icons used for toolbars
25 QString flagsPath; // Pointing to flags
27 bool debug; // global debugging flag
28 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
29 FlagRowObj *standardFlagsDefault;
32 Settings settings ("InSilmaril","vym"); // Organization, Application name
37 int statusbarTime=3500;
39 int main(int argc, char* argv[])
41 //Q_INIT_RESOURCE (application);
43 QApplication app(argc,argv);
46 vymVersion=__VYM_VERSION;
47 vymBuildDate=__VYM_BUILD_DATE;
48 vymCodeName=__VYM_CODENAME;
51 // Reading and initializing options commandline options
52 options.add ("debug", Option::Switch, "d", "debug");
53 options.add ("version", Option::Switch, "v","version");
54 options.add ("local", Option::Switch, "l", "local");
55 options.add ("help", Option::Switch, "h", "help");
56 options.add ("quit", Option::Switch, "q", "quit");
57 options.add ("run", Option::String, "r", "run");
58 options.add ("test", Option::String, "t", "test");
60 "VYM - View Your Mind\n"
61 "--------------------\n\n"
62 "Information about vym can be found in vym.pdf,\n"
63 "which should be part of the vym package.\n"
64 "It is also available at the project homepage:\n\n"
65 "http://www.InSilmaril.de/vym\n");
68 cout << endl << options.getHelpText().ascii()<<endl;
72 debug=options.isOn ("debug");
74 if (options.isOn ("version"))
76 cout << "vym version "<<__VYM_VERSION
77 <<" (c) 2004-2007 Uwe Drechsel - "
79 <<" "<<__VYM_CODENAME<<endl;
84 // Use /usr/share/vym or /usr/local/share/vym or . ?
86 if (options.isOn ("local"))
88 vymBaseDir.setPath (vymBaseDir.currentDirPath());
90 // then look for environment variable
91 if (getenv("VYMHOME")!=0)
93 vymBaseDir.setPath (getenv("VYMHOME"));
95 // ok, let's find my way on my own
97 #if defined (Q_OS_MACX)
98 vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
101 vymBaseDir.setPath ("/usr/share/vym");
102 if (!vymBaseDir.exists())
104 vymBaseDir.setPath ("/usr/local/share/vym");
105 if (!vymBaseDir.exists())
106 vymBaseDir.setPath(vymBaseDir.currentDirPath() );
111 iconPath=vymBaseDir.path()+"/icons/";
112 flagsPath=vymBaseDir.path()+"/flags/";
115 lastImageDir=QDir().current();
116 lastFileDir=QDir().current();
118 if (options.isOn ("help"))
120 cout << options.getHelpText().ascii()<<endl;
124 // Initialize translations
125 QTranslator translator (0);
126 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
127 app.installTranslator( &translator );
129 // Initializing the row of system flags
130 // is done in first call to MapEditor(),
131 // because we need at least one canvas first
132 systemFlagsDefault=NULL;
133 standardFlagsDefault=NULL;
135 // Initialize window of TextEditor
136 textEditor = new TextEditor();
137 textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
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.runScriptEverywhere (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()) );