diff -r 7a96bd401351 -r 5c5b4464b24f main.cpp --- a/main.cpp Sun Jan 30 12:58:47 2005 +0000 +++ b/main.cpp Fri Mar 05 20:16:46 2010 +0000 @@ -1,117 +1,69 @@ -#include -#include -#include - -#include "settings.h" -#include "options.h" -#include "mainwindow.h" - -#include "icons/vym-48x48.xpm" -#include "icons/vym-editor.xpm" +#include #include "flagrowobj.h" +#include "mainwindow.h" +#include "options.h" +#include "settings.h" +#include "version.h" + +#if defined(Q_OS_WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#endif // 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() -MapEditor *clipboardME; +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; +#if defined(Q_OS_WIN32) +QDir vymInstallDir; +#endif +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; -// Actions which change sometimes -QAction *actionFileSave; -QAction *actionFilePrint; -QAction *actionEditUndo; -QAction *actionEditCopy; -QAction *actionEditCut; -QAction *actionEditPaste; -QAction *actionEditMoveUp; -QAction *actionEditMoveDown; -QAction *actionEditToggleScroll; -QAction *actionEditOpenURL; -QAction *actionEditURL; -QAction *actionEditHeading2URL; -QAction *actionEditBugzilla2URL; -QAction *actionEditOpenVymLink; -QAction *actionEditVymLink; -QAction *actionEditDeleteVymLink; -QAction *actionEditMapInfo; -QAction *actionEditHeading; -QAction *actionEditDelete; -QAction *actionEditAddBranch; -QAction *actionEditAddBranchAbove; -QAction *actionEditAddBranchBelow; -QAction *actionEditImportAdd; -QAction *actionEditImportReplace; -QAction *actionEditSaveBranch; -QAction *actionEditSelectFirst; -QAction *actionEditSelectLast; -QAction *actionEditLoadImage; -QAction *actionEditToggleFloatExport; -QAction *actionFormatColor; -QAction *actionFormatPickColor; -QAction *actionFormatColorBranch; -QAction *actionFormatColorSubtree; -QAction *actionFormatBackColor; -QAction *actionFormatLinkColorHint; -QAction *actionFormatLinkColor; +Settings settings ("InSilmaril","vym"); // Organization, Application name -QActionGroup *actionGroupFormatFrameTypes; -QAction *actionFormatFrameNone; -QAction *actionFormatFrameRectangle; - -QActionGroup *actionGroupFormatLinkStyles; -QAction *actionFormatLinkStyleLine; -QAction *actionFormatLinkStyleParabel; -QAction *actionFormatLinkStylePolyLine; -QAction *actionFormatLinkStylePolyParabel; - -QAction *actionViewToggleNoteEditor; - -QAction *actionSettingsAutoselectHeading; -QAction *actionSettingsAutoselectText; -QAction *actionSettingsPasteNewHeading; -QAction *actionSettingsAutoedit; -QAction *actionSettingsUseDelKey; - -QPopupMenu *branchContextMenu; -QPopupMenu *floatimageContextMenu; -QPopupMenu *saveImageFormatMenu; -QPopupMenu *canvasContextMenu; -QPopupMenu *lastMapsMenu; -QPopupMenu *exportMenu; -QPopupMenu *exportImageFormatMenu; - - -Settings settings; Options options; +ImageIO imageIO; int statusbarTime=3500; -int main(int argc, char** argv) +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; - // Initialize translations - QTranslator translator (0); - translator.load( "vym_de", "." ); - 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; // Reading and initializing options commandline options - options.add ("version", SwitchOption, "v","version"); - options.add ("help", SwitchOption, "h", "help"); - options.add ("quit", SwitchOption, "q", "quit"); - options.add ("test", StringOption, "t", "test"); + 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" @@ -121,50 +73,136 @@ "http://www.InSilmaril.de/vym\n"); if (options.parse()) { - cout << endl << options.getHelpText()<setIcon (QPixmap (vym_editor_xpm)); - if (textEditor->showWithMain()) textEditor->show(); + textEditor->setIcon (QPixmap (iconPath+"vym-editor.png")); - clipboardME = new MapEditor(); - clipboardME->resize (800,600); - clipboardME->setCaption("VYM - clipboard"); - clipboardME->hide(); + // Initialize mainwindow +#if defined(Q_OS_WIN32) + Main m(0, 0, (Qt::Window | Qt::MSWindowsOwnDC)); +#else + Main m; +#endif - // Initialize mainwindow after Mapeditors (because of Flags) - Main m; //m.resize(m.sizeHint()); - m.setIcon (QPixmap (vym_logo_xpm)); + m.setIcon (QPixmap (iconPath+"vym.png")); m.show(); m.fileNew(); m.loadCmdLine(); - // For benchmarking we may want to quit immediatly after drawing + // 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; @@ -174,4 +212,3 @@ return app.exec(); } -