insilmaril@366: #include insilmaril@781: #include insilmaril@0: insilmaril@721: #include insilmaril@721: using namespace std; insilmaril@721: insilmaril@782: #include "adaptor.h" //FIXME-3 insilmaril@782: insilmaril@767: #include "flagrow.h" insilmaril@404: #include "flagrowobj.h" insilmaril@404: #include "mainwindow.h" insilmaril@404: #include "options.h" insilmaril@0: #include "settings.h" insilmaril@404: #include "version.h" insilmaril@0: insilmaril@625: #if defined(Q_OS_WIN32) insilmaril@625: #define WIN32_LEAN_AND_MEAN insilmaril@625: #include insilmaril@625: #endif insilmaril@625: insilmaril@0: // Global variables insilmaril@0: TextEditor *textEditor; // used in Constr. of LinkableMapObj insilmaril@0: // initialized in mainwindow insilmaril@406: QString vymName; insilmaril@406: QString vymVersion; insilmaril@406: QString vymBuildDate; insilmaril@473: QString vymCodeName; insilmaril@0: insilmaril@0: Main *mainWindow; // used in BranchObj::select() insilmaril@781: QDBusConnection dbusConnection= QDBusConnection::sessionBus(); insilmaril@781: insilmaril@164: QString tmpVymDir; // All temp files go there, created in mainwindow insilmaril@166: QString clipboardDir; // Clipboard used in all mapEditors insilmaril@491: QString clipboardFile; // Clipboard used in all mapEditors insilmaril@215: QDir vymBaseDir; // Containing all styles, scripts, images, ... insilmaril@366: QDir lastImageDir; insilmaril@366: QDir lastFileDir; insilmaril@625: #if defined(Q_OS_WIN32) insilmaril@625: QDir vymInstallDir; insilmaril@625: #endif insilmaril@269: QString iconPath; // Pointing to icons used for toolbars insilmaril@269: QString flagsPath; // Pointing to flags insilmaril@166: bool clipboardEmpty; insilmaril@473: bool debug; // global debugging flag insilmaril@767: FlagRow *systemFlagsMaster; insilmaril@767: FlagRow *standardFlagsMaster; insilmaril@366: insilmaril@366: Settings settings ("InSilmaril","vym"); // Organization, Application name insilmaril@366: insilmaril@0: Options options; insilmaril@366: ImageIO imageIO; insilmaril@0: insilmaril@0: int statusbarTime=3500; insilmaril@0: insilmaril@394: int main(int argc, char* argv[]) insilmaril@0: { insilmaril@394: //Q_INIT_RESOURCE (application); insilmaril@366: insilmaril@0: QApplication app(argc,argv); insilmaril@0: insilmaril@406: vymName=__VYM_NAME; insilmaril@406: vymVersion=__VYM_VERSION; insilmaril@406: vymBuildDate=__VYM_BUILD_DATE; insilmaril@473: vymCodeName=__VYM_CODENAME; insilmaril@406: insilmaril@0: insilmaril@0: // Reading and initializing options commandline options insilmaril@473: options.add ("debug", Option::Switch, "d", "debug"); insilmaril@473: options.add ("version", Option::Switch, "v","version"); insilmaril@473: options.add ("local", Option::Switch, "l", "local"); insilmaril@473: options.add ("help", Option::Switch, "h", "help"); insilmaril@473: options.add ("quit", Option::Switch, "q", "quit"); insilmaril@473: options.add ("run", Option::String, "r", "run"); insilmaril@473: 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@657: cout << endl << qPrintable( options.getHelpText())<setName ("systemFlagsMaster"); insilmaril@767: standardFlagsMaster=new FlagRow; insilmaril@767: standardFlagsMaster->setName ("standardFlagsMaster"); insilmaril@767: insilmaril@243: insilmaril@0: // Initialize window of TextEditor insilmaril@0: textEditor = new TextEditor(); insilmaril@269: textEditor->setIcon (QPixmap (iconPath+"vym-editor.png")); insilmaril@0: insilmaril@166: // Initialize mainwindow insilmaril@625: #if defined(Q_OS_WIN32) insilmaril@625: Main m(0, 0, (Qt::Window | Qt::MSWindowsOwnDC)); insilmaril@625: #else insilmaril@0: Main m; insilmaril@625: #endif insilmaril@625: insilmaril@0: //m.resize(m.sizeHint()); insilmaril@269: m.setIcon (QPixmap (iconPath+"vym-48x48.png")); insilmaril@0: m.show(); insilmaril@0: m.fileNew(); insilmaril@742: // Paint Mainwindow first time insilmaril@742: qApp->processEvents(); insilmaril@742: insilmaril@782: // FIXME-3 playing around with dbus insilmaril@782: /* insilmaril@782: new Adaptor (&app); insilmaril@782: dbusConnection.registerService("org.insilmaril.MainWindow"); insilmaril@782: QDBusConnection::sessionBus().registerObject("/MainApplication", &app); insilmaril@782: */ insilmaril@782: insilmaril@782: insilmaril@0: m.loadCmdLine(); insilmaril@0: insilmaril@434: // Run script insilmaril@434: if (options.isOn ("run")) insilmaril@434: { insilmaril@434: QString script; insilmaril@434: QString fn=options.getArg ("run"); insilmaril@434: if ( !fn.isEmpty() ) insilmaril@434: { insilmaril@434: QFile f( fn ); insilmaril@434: if ( !f.open( QIODevice::ReadOnly ) ) insilmaril@434: { insilmaril@434: QMessageBox::warning(0, insilmaril@434: QObject::tr("Error"), insilmaril@434: QObject::tr("Couldn't open %1.\n").arg(fn)); insilmaril@434: return 0; insilmaril@434: } insilmaril@434: insilmaril@434: QTextStream ts( &f ); insilmaril@434: script= ts.read(); insilmaril@434: f.close(); insilmaril@434: m.setScript (script); insilmaril@514: m.runScriptEverywhere (script); insilmaril@434: } insilmaril@434: } insilmaril@434: insilmaril@434: // 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: }