insilmaril@79: #include insilmaril@0: insilmaril@0: #include "flagrowobj.h" insilmaril@79: #include "mainwindow.h" insilmaril@79: #include "options.h" insilmaril@79: #include "settings.h" insilmaril@79: #include "version.h" insilmaril@79: insilmaril@79: #if defined(Q_OS_WIN32) insilmaril@79: #define WIN32_LEAN_AND_MEAN insilmaril@79: #include insilmaril@79: #endif insilmaril@0: insilmaril@0: // Global variables insilmaril@0: TextEditor *textEditor; // used in Constr. of LinkableMapObj insilmaril@0: // initialized in mainwindow insilmaril@79: QString vymName; insilmaril@79: QString vymVersion; insilmaril@79: QString vymBuildDate; insilmaril@79: QString vymCodeName; insilmaril@0: insilmaril@0: Main *mainWindow; // used in BranchObj::select() insilmaril@79: QString tmpVymDir; // All temp files go there, created in mainwindow insilmaril@79: QString clipboardDir; // Clipboard used in all mapEditors insilmaril@79: QString clipboardFile; // Clipboard used in all mapEditors insilmaril@79: QDir vymBaseDir; // Containing all styles, scripts, images, ... insilmaril@79: QDir lastImageDir; insilmaril@79: QDir lastFileDir; insilmaril@79: #if defined(Q_OS_WIN32) insilmaril@79: QDir vymInstallDir; insilmaril@79: #endif insilmaril@79: QString iconPath; // Pointing to icons used for toolbars insilmaril@79: QString flagsPath; // Pointing to flags insilmaril@79: bool clipboardEmpty; insilmaril@79: bool debug; // global debugging flag insilmaril@0: FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj insilmaril@0: FlagRowObj *standardFlagsDefault; insilmaril@0: insilmaril@0: insilmaril@79: Settings settings ("InSilmaril","vym"); // Organization, Application name insilmaril@0: insilmaril@0: Options options; insilmaril@79: ImageIO imageIO; insilmaril@0: insilmaril@0: int statusbarTime=3500; insilmaril@0: insilmaril@79: int main(int argc, char* argv[]) insilmaril@0: { insilmaril@79: //Q_INIT_RESOURCE (application); insilmaril@79: insilmaril@0: QApplication app(argc,argv); insilmaril@0: insilmaril@79: vymName=__VYM_NAME; insilmaril@79: vymVersion=__VYM_VERSION; insilmaril@79: vymBuildDate=__VYM_BUILD_DATE; insilmaril@79: vymCodeName=__VYM_CODENAME; insilmaril@0: insilmaril@0: insilmaril@0: // Reading and initializing options commandline options insilmaril@79: options.add ("debug", Option::Switch, "d", "debug"); insilmaril@79: options.add ("version", Option::Switch, "v","version"); insilmaril@79: options.add ("local", Option::Switch, "l", "local"); insilmaril@79: options.add ("help", Option::Switch, "h", "help"); insilmaril@79: options.add ("quit", Option::Switch, "q", "quit"); insilmaril@79: options.add ("run", Option::String, "r", "run"); insilmaril@79: options.add ("test", Option::String, "t", "test"); insilmaril@0: options.setHelpText ( insilmaril@0: "VYM - View Your Mind\n" insilmaril@0: "--------------------\n\n" insilmaril@0: "Information about vym can be found in vym.pdf,\n" insilmaril@0: "which should be part of the vym package.\n" insilmaril@0: "It is also available at the project homepage:\n\n" insilmaril@0: "http://www.InSilmaril.de/vym\n"); insilmaril@0: if (options.parse()) insilmaril@0: { insilmaril@79: cout << endl << qPrintable( options.getHelpText())<setIcon (QPixmap (iconPath+"vym-editor.png")); insilmaril@0: insilmaril@79: // Initialize mainwindow insilmaril@79: #if defined(Q_OS_WIN32) insilmaril@79: Main m(0, 0, (Qt::Window | Qt::MSWindowsOwnDC)); insilmaril@79: #else insilmaril@79: Main m; insilmaril@79: #endif insilmaril@0: insilmaril@0: //m.resize(m.sizeHint()); insilmaril@79: m.setIcon (QPixmap (iconPath+"vym.png")); insilmaril@0: m.show(); insilmaril@0: m.fileNew(); insilmaril@0: m.loadCmdLine(); insilmaril@0: insilmaril@79: // Run script insilmaril@79: if (options.isOn ("run")) insilmaril@79: { insilmaril@79: QString script; insilmaril@79: QString fn=options.getArg ("run"); insilmaril@79: if ( !fn.isEmpty() ) insilmaril@79: { insilmaril@79: QFile f( fn ); insilmaril@79: if ( !f.open( QIODevice::ReadOnly ) ) insilmaril@79: { insilmaril@79: QMessageBox::warning(0, insilmaril@79: QObject::tr("Error"), insilmaril@79: QObject::tr("Couldn't open %1.\n").arg(fn)); insilmaril@79: return 0; insilmaril@79: } insilmaril@79: insilmaril@79: QTextStream ts( &f ); insilmaril@79: script= ts.read(); insilmaril@79: f.close(); insilmaril@79: m.setScript (script); insilmaril@79: m.runScriptEverywhere (script); insilmaril@79: } insilmaril@79: } insilmaril@79: insilmaril@79: // For benchmarking we may want to quit instead of entering event loop insilmaril@0: if (options.isOn ("quit")) insilmaril@0: { insilmaril@0: return 0; insilmaril@0: } insilmaril@0: insilmaril@0: QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) ); insilmaril@0: insilmaril@0: return app.exec(); insilmaril@0: }