1 #include <QApplication>
3 #include "flagrowobj.h"
4 #include "mainwindow.h"
10 TextEditor *textEditor; // used in Constr. of LinkableMapObj
11 // initialized in mainwindow
16 Main *mainWindow; // used in BranchObj::select()
17 QString tmpVymDir; // All temp files go there, created in mainwindow
18 QString clipboardDir; // Clipboard used in all mapEditors
19 QDir vymBaseDir; // Containing all styles, scripts, images, ...
22 QString iconPath; // Pointing to icons used for toolbars
23 QString flagsPath; // Pointing to flags
25 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
26 FlagRowObj *standardFlagsDefault;
29 Settings settings ("InSilmaril","vym"); // Organization, Application name
34 int statusbarTime=3500;
36 int main(int argc, char* argv[])
38 //Q_INIT_RESOURCE (application);
40 QApplication app(argc,argv);
43 vymVersion=__VYM_VERSION;
44 vymBuildDate=__VYM_BUILD_DATE;
47 // Reading and initializing options commandline options
48 options.add ("version", SwitchOption, "v","version");
49 options.add ("local", SwitchOption, "l", "local");
50 options.add ("help", SwitchOption, "h", "help");
51 options.add ("quit", SwitchOption, "q", "quit");
52 options.add ("run", StringOption, "r", "run");
53 options.add ("test", StringOption, "t", "test");
55 "VYM - View Your Mind\n"
56 "--------------------\n\n"
57 "Information about vym can be found in vym.pdf,\n"
58 "which should be part of the vym package.\n"
59 "It is also available at the project homepage:\n\n"
60 "http://www.InSilmaril.de/vym\n");
63 cout << endl << options.getHelpText().ascii()<<endl;
67 if (options.isOn ("version"))
69 cout << "vym version "<<__VYM_VERSION
70 <<" (c) 2004-2006 Uwe Drechsel - "
71 <<__VYM_BUILD_DATE<<endl;
76 // Use /usr/share/vym or /usr/local/share/vym or . ?
78 if (options.isOn ("local"))
80 vymBaseDir.setPath (vymBaseDir.currentDirPath());
82 // then look for environment variable
83 if (getenv("VYMHOME")!=0)
85 vymBaseDir.setPath (getenv("VYMHOME"));
87 // ok, let's find my way on my own
89 #if defined (Q_OS_MACX)
90 vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
93 vymBaseDir.setPath ("/usr/share/vym");
94 if (!vymBaseDir.exists())
96 vymBaseDir.setPath ("/usr/local/share/vym");
97 if (!vymBaseDir.exists())
98 vymBaseDir.setPath(vymBaseDir.currentDirPath() );
103 iconPath=vymBaseDir.path()+"/icons/";
104 flagsPath=vymBaseDir.path()+"/flags/";
107 lastImageDir=QDir().current();
108 lastFileDir=QDir().current();
110 if (options.isOn ("help"))
112 cout << options.getHelpText().ascii()<<endl;
116 // Initialize translations
117 QTranslator translator (0);
118 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
119 app.installTranslator( &translator );
121 // Initializing the row of system flags
122 // is done in first call to MapEditor(),
123 // because we need at least one canvas first
124 systemFlagsDefault=NULL;
125 standardFlagsDefault=NULL;
127 // Initialize window of TextEditor
128 textEditor = new TextEditor();
129 textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
130 if (textEditor->showWithMain()) textEditor->show();
132 // Initialize mainwindow
134 //m.resize(m.sizeHint());
135 m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
141 if (options.isOn ("run"))
144 QString fn=options.getArg ("run");
148 if ( !f.open( QIODevice::ReadOnly ) )
150 QMessageBox::warning(0,
151 QObject::tr("Error"),
152 QObject::tr("Couldn't open %1.\n").arg(fn));
156 QTextStream ts( &f );
159 m.setScript (script);
160 m.runScript (script);
164 // For benchmarking we may want to quit instead of entering event loop
165 if (options.isOn ("quit"))
170 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );