1 #include <qapplication.h>
3 #include <qtranslator.h>
5 #include <qtextcodec.h>
9 #include "mainwindow.h"
11 #include "icons/vym-48x48.xpm"
12 #include "icons/vym-editor.xpm"
14 #include "flagrowobj.h"
17 TextEditor *textEditor; // used in Constr. of LinkableMapObj
18 // initialized in mainwindow
20 Main *mainWindow; // used in BranchObj::select()
21 MapEditor *clipboardME;
22 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
23 FlagRowObj *standardFlagsDefault;
25 // Actions which change sometimes
26 QAction *actionFileSave;
27 QAction *actionFilePrint;
28 QAction *actionEditUndo;
29 QAction *actionEditCopy;
30 QAction *actionEditCut;
31 QAction *actionEditPaste;
32 QAction *actionEditMoveUp;
33 QAction *actionEditMoveDown;
34 QAction *actionEditToggleScroll;
35 QAction *actionEditOpenURL;
36 QAction *actionEditURL;
37 QAction *actionEditHeading2URL;
38 QAction *actionEditBugzilla2URL;
39 QAction *actionEditOpenVymLink;
40 QAction *actionEditVymLink;
41 QAction *actionEditDeleteVymLink;
42 QAction *actionEditMapInfo;
43 QAction *actionEditHeading;
44 QAction *actionEditDelete;
45 QAction *actionEditAddBranch;
46 QAction *actionEditAddBranchAbove;
47 QAction *actionEditAddBranchBelow;
48 QAction *actionEditImportAdd;
49 QAction *actionEditImportReplace;
50 QAction *actionEditSaveBranch;
51 QAction *actionEditSelectFirst;
52 QAction *actionEditSelectLast;
53 QAction *actionEditLoadImage;
54 QAction *actionEditToggleFloatExport;
55 QAction *actionEditNoLink;
57 QAction *actionFormatColor;
58 QAction *actionFormatPickColor;
59 QAction *actionFormatColorBranch;
60 QAction *actionFormatColorSubtree;
61 QAction *actionFormatBackColor;
62 QAction *actionFormatLinkColorHint;
63 QAction *actionFormatLinkColor;
65 QActionGroup *actionGroupModModes;
66 QAction *actionModModeColor;
67 QAction *actionModModeLink;
69 QActionGroup *actionGroupFormatFrameTypes;
70 QAction *actionFormatFrameNone;
71 QAction *actionFormatFrameRectangle;
73 QActionGroup *actionGroupFormatLinkStyles;
74 QAction *actionFormatLinkStyleLine;
75 QAction *actionFormatLinkStyleParabel;
76 QAction *actionFormatLinkStylePolyLine;
77 QAction *actionFormatLinkStylePolyParabel;
79 QAction *actionViewToggleNoteEditor;
81 QAction *actionSettingsAutoselectHeading;
82 QAction *actionSettingsAutoselectText;
83 QAction *actionSettingsPasteNewHeading;
84 QAction *actionSettingsAutoedit;
85 QAction *actionSettingsUseDelKey;
87 QPopupMenu *branchContextMenu;
88 QPopupMenu *branchLinksContextMenu;
89 QPopupMenu *floatimageContextMenu;
90 QPopupMenu *saveImageFormatMenu;
91 QPopupMenu *canvasContextMenu;
92 QPopupMenu *lastMapsMenu;
93 QPopupMenu *exportMenu;
94 QPopupMenu *exportImageFormatMenu;
100 int statusbarTime=3500;
102 int main(int argc, char** argv)
104 QApplication app(argc,argv);
107 // Use /usr/share/vym or /usr/local/share/vym or .
109 shareDir.setPath ("/usr/share/vym");
110 if (!shareDir.exists())
111 shareDir.setPath ("/usr/local/share/vym");
112 if (!shareDir.exists())
113 shareDir.setPath(".");
115 // Initialize translations
116 QTranslator translator (0);
117 translator.load( QString("vym_")+QTextCodec::locale(), shareDir.path() + "/lang");
118 app.installTranslator( &translator );
120 // Initializing the row of system flags
121 // is done in first call to MapEditor(),
122 // because we need at least one canvas first
123 systemFlagsDefault=NULL;
124 standardFlagsDefault=NULL;
126 // Reading and initializing options commandline options
127 options.add ("version", SwitchOption, "v","version");
128 options.add ("help", SwitchOption, "h", "help");
129 options.add ("quit", SwitchOption, "q", "quit");
130 options.add ("test", StringOption, "t", "test");
131 options.setHelpText (
132 "VYM - View Your Mind\n"
133 "--------------------\n\n"
134 "Information about vym can be found in vym.pdf,\n"
135 "which should be part of the vym package.\n"
136 "It is also available at the project homepage:\n\n"
137 "http://www.InSilmaril.de/vym\n");
140 cout << endl << options.getHelpText()<<endl;
144 if (options.isOn ("version"))
146 cout << "vym version "<<__VYM_VERSION__
147 <<" (c) 2004 Uwe Drechsel - "
148 <<__BUILD_DATE__<<endl;
153 if (options.isOn ("help"))
155 cout << options.getHelpText()<<endl;
159 if (options.isOn ("test"))
161 // FIXME testing string option only
162 cout << "Testing: "<<options.getArg("test")<< endl;
165 // Initialize window of TextEditor
166 textEditor = new TextEditor();
167 textEditor->setIcon (QPixmap (vym_editor_xpm));
168 if (textEditor->showWithMain()) textEditor->show();
170 clipboardME = new MapEditor();
171 clipboardME->resize (800,600);
172 clipboardME->setCaption("VYM - clipboard");
175 // Initialize mainwindow after Mapeditors (because of Flags)
177 //m.resize(m.sizeHint());
178 m.setIcon (QPixmap (vym_logo_xpm));
183 // For benchmarking we may want to quit immediatly after drawing
184 if (options.isOn ("quit"))
189 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );