1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
#include <QApplication>
#include "flagrowobj.h"
#include "mainwindow.h"
#include "options.h"
#include "settings.h"
#include "version.h"
// Global variables
TextEditor *textEditor; // used in Constr. of LinkableMapObj
// initialized in mainwindow
QString vymName;
QString vymVersion;
QString vymBuildDate;
QString vymCodeName;
Main *mainWindow; // used in BranchObj::select()
QString tmpVymDir; // All temp files go there, created in mainwindow
QString clipboardDir; // Clipboard used in all mapEditors
QString clipboardFile; // Clipboard used in all mapEditors
QDir vymBaseDir; // Containing all styles, scripts, images, ...
QDir lastImageDir;
QDir lastFileDir;
QString iconPath; // Pointing to icons used for toolbars
QString flagsPath; // Pointing to flags
bool clipboardEmpty;
bool debug; // global debugging flag
FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
FlagRowObj *standardFlagsDefault;
Settings settings ("InSilmaril","vym"); // Organization, Application name
Options options;
ImageIO imageIO;
int statusbarTime=3500;
int main(int argc, char* argv[])
{
//Q_INIT_RESOURCE (application);
QApplication app(argc,argv);
vymName=__VYM_NAME;
vymVersion=__VYM_VERSION;
vymBuildDate=__VYM_BUILD_DATE;
vymCodeName=__VYM_CODENAME;
// Reading and initializing options commandline options
options.add ("debug", Option::Switch, "d", "debug");
options.add ("version", Option::Switch, "v","version");
options.add ("local", Option::Switch, "l", "local");
options.add ("help", Option::Switch, "h", "help");
options.add ("quit", Option::Switch, "q", "quit");
options.add ("run", Option::String, "r", "run");
options.add ("test", Option::String, "t", "test");
options.setHelpText (
"VYM - View Your Mind\n"
"--------------------\n\n"
"Information about vym can be found in vym.pdf,\n"
"which should be part of the vym package.\n"
"It is also available at the project homepage:\n\n"
"http://www.InSilmaril.de/vym\n");
if (options.parse())
{
cout << endl << options.getHelpText().ascii()<<endl;
return 1;
}
debug=options.isOn ("debug");
if (options.isOn ("version"))
{
cout << "VYM - View Your Mind (c) 2004-2007 Uwe Drechsel " << endl
<<" Version: "<<__VYM_VERSION <<endl
<<"Build date: "<<__VYM_BUILD_DATE << endl
<<" "<<__VYM_CODENAME<<endl;
return 0;
}
// Use /usr/share/vym or /usr/local/share/vym or . ?
// First try options
if (options.isOn ("local"))
{
vymBaseDir.setPath (vymBaseDir.currentDirPath());
} else
// then look for environment variable
if (getenv("VYMHOME")!=0)
{
vymBaseDir.setPath (getenv("VYMHOME"));
} else
// ok, let's find my way on my own
{
#if defined (Q_OS_MACX)
vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
#else
vymBaseDir.setPath ("/usr/share/vym");
if (!vymBaseDir.exists())
{
vymBaseDir.setPath ("/usr/local/share/vym");
if (!vymBaseDir.exists())
vymBaseDir.setPath(vymBaseDir.currentDirPath() );
}
#endif
}
iconPath=vymBaseDir.path()+"/icons/";
flagsPath=vymBaseDir.path()+"/flags/";
// Some directories
lastImageDir=QDir().current();
lastFileDir=QDir().current();
if (options.isOn ("help"))
{
cout << options.getHelpText().ascii()<<endl;
return 0;
}
// Initialize translations
QTranslator translator (0);
translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
app.installTranslator( &translator );
// Initializing the row of system flags
// is done in first call to MapEditor(),
// because we need at least one canvas first
systemFlagsDefault=NULL;
standardFlagsDefault=NULL;
// Initialize window of TextEditor
textEditor = new TextEditor();
textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
// Initialize mainwindow
Main m;
//m.resize(m.sizeHint());
m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
m.show();
m.fileNew();
m.loadCmdLine();
// Run script
if (options.isOn ("run"))
{
QString script;
QString fn=options.getArg ("run");
if ( !fn.isEmpty() )
{
QFile f( fn );
if ( !f.open( QIODevice::ReadOnly ) )
{
QMessageBox::warning(0,
QObject::tr("Error"),
QObject::tr("Couldn't open %1.\n").arg(fn));
return 0;
}
QTextStream ts( &f );
script= ts.read();
f.close();
m.setScript (script);
m.runScriptEverywhere (script);
}
}
// For benchmarking we may want to quit instead of entering event loop
if (options.isOn ("quit"))
{
return 0;
}
QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
return app.exec();
}
|