1 #include <qapplication.h>
3 #include <qtranslator.h>
6 #include <qtextcodec.h>
12 #include "mainwindow.h"
14 #include "icons/vym-48x48.xpm"
15 #include "icons/vym-128x128.xpm"
16 #include "icons/vym-editor.xpm"
18 #include "flagrowobj.h"
21 TextEditor *textEditor; // used in Constr. of LinkableMapObj
22 // initialized in mainwindow
24 Main *mainWindow; // used in BranchObj::select()
25 QString tmpVymDir; // All temp files go there, created in mainwindow
26 QString clipboardDir; // Clipboard used in all mapEditors
28 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
29 FlagRowObj *standardFlagsDefault;
32 // (QActionGroup could not be "enabled")
33 QPtrList <QAction> actionListBranches;
35 // Actions which change sometimes
36 QAction *actionFileSave;
37 QAction *actionFilePrint;
38 QAction *actionEditUndo;
39 QAction *actionEditRedo;
40 QAction *actionEditCopy;
41 QAction *actionEditCut;
42 QAction *actionEditPaste;
43 QAction *actionEditMoveUp;
44 QAction *actionEditMoveDown;
45 QAction *actionEditToggleScroll;
46 QAction *actionEditOpenURL;
47 QAction *actionEditURL;
48 QAction *actionEditHeading2URL;
49 QAction *actionEditBugzilla2URL;
50 QAction *actionEditFATE2URL;
51 QAction *actionEditOpenVymLink;
52 QAction *actionEditVymLink;
53 QAction *actionEditDeleteVymLink;
54 QAction *actionEditMapInfo;
55 QAction *actionEditHeading;
56 QAction *actionEditDelete;
57 QAction *actionEditAddBranch;
58 QAction *actionEditAddBranchHere;
59 QAction *actionEditAddBranchAbove;
60 QAction *actionEditAddBranchBelow;
61 QAction *actionEditRemoveBranchHere;
62 QAction *actionEditRemoveChilds;
63 QAction *actionEditImportAdd;
64 QAction *actionEditImportReplace;
65 QAction *actionEditSaveBranch;
66 QAction *actionEditSelectFirst;
67 QAction *actionEditSelectLast;
68 QAction *actionEditLoadImage;
69 QAction *actionEditToggleFloatExport;
71 QAction *actionFormatColor;
72 QAction *actionFormatPickColor;
73 QAction *actionFormatColorBranch;
74 QAction *actionFormatColorSubtree;
75 QAction *actionFormatBackColor;
76 QAction *actionFormatLinkColorHint;
77 QAction *actionFormatLinkColor;
79 QActionGroup *actionGroupModModes;
80 QAction *actionModModeColor;
81 QAction *actionModModeLink;
82 QAction *actionModModeCopy;
84 QActionGroup *actionGroupFormatFrameTypes;
85 QAction *actionFormatFrameNone;
86 QAction *actionFormatFrameRectangle;
88 QActionGroup *actionGroupFormatLinkStyles;
89 QAction *actionFormatIncludeImagesVer;
90 QAction *actionFormatIncludeImagesHor;
91 QAction *actionFormatHideLinkUnselected;
92 QAction *actionFormatLinkStyleLine;
93 QAction *actionFormatLinkStyleParabel;
94 QAction *actionFormatLinkStylePolyLine;
95 QAction *actionFormatLinkStylePolyParabel;
97 QAction *actionViewToggleNoteEditor;
99 QAction *actionSettingsAutoselectHeading;
100 QAction *actionSettingsAutoselectText;
101 QAction *actionSettingsPasteNewHeading;
102 QAction *actionSettingsAutoedit;
103 QAction *actionSettingsUseDelKey;
104 QAction *actionSettingsUseFlagGroups;
106 QPopupMenu *branchContextMenu;
107 QPopupMenu *branchAddContextMenu;
108 QPopupMenu *branchRemoveContextMenu;
109 QPopupMenu *branchLinksContextMenu;
110 QPopupMenu *branchLinksContextMenuDup;
111 QPopupMenu *floatimageContextMenu;
112 QPopupMenu *saveImageFormatMenu;
113 QPopupMenu *canvasContextMenu;
114 QPopupMenu *lastMapsMenu;
115 QPopupMenu *importMenu;
116 QPopupMenu *exportMenu;
117 QPopupMenu *exportImageFormatMenu;
123 int statusbarTime=3500;
125 int main(int argc, char** argv)
127 QApplication app(argc,argv);
129 QMimeSourceFactory *factory = QMimeSourceFactory::defaultFactory();
130 factory->setPixmap("vym_48x48", QPixmap(vym_48x48_xpm));
131 factory->setPixmap("vym_128x128", QPixmap(vym_128x128_xpm));
132 qInitNetworkProtocols();
134 // Use /usr/share/vym or /usr/local/share/vym or .
136 shareDir.setPath ("/usr/share/vym");
137 if (!shareDir.exists())
138 shareDir.setPath ("/usr/local/share/vym");
139 if (!shareDir.exists())
140 shareDir.setPath(".");
142 // Initialize translations
143 QTranslator translator (0);
144 translator.load( QString("vym_")+QTextCodec::locale(), shareDir.path() + "/lang");
145 app.installTranslator( &translator );
147 // Initializing the row of system flags
148 // is done in first call to MapEditor(),
149 // because we need at least one canvas first
150 systemFlagsDefault=NULL;
151 standardFlagsDefault=NULL;
153 // Reading and initializing options commandline options
154 options.add ("version", SwitchOption, "v","version");
155 options.add ("help", SwitchOption, "h", "help");
156 options.add ("quit", SwitchOption, "q", "quit");
157 options.add ("test", StringOption, "t", "test");
158 options.setHelpText (
159 "VYM - View Your Mind\n"
160 "--------------------\n\n"
161 "Information about vym can be found in vym.pdf,\n"
162 "which should be part of the vym package.\n"
163 "It is also available at the project homepage:\n\n"
164 "http://www.InSilmaril.de/vym\n");
167 cout << endl << options.getHelpText()<<endl;
171 if (options.isOn ("version"))
173 cout << "vym version "<<__VYM_VERSION
174 <<" (c) 2004 Uwe Drechsel - "
175 <<__BUILD_DATE<<endl;
180 if (options.isOn ("help"))
182 cout << options.getHelpText()<<endl;
186 if (options.isOn ("test"))
188 // FIXME testing string option only
189 cout << "Testing: "<<options.getArg("test")<< endl;
192 // Initialize window of TextEditor
193 textEditor = new TextEditor();
194 textEditor->setIcon (QPixmap (vym_editor_xpm));
195 if (textEditor->showWithMain()) textEditor->show();
197 // Initialize mainwindow
199 //m.resize(m.sizeHint());
200 m.setIcon (QPixmap (vym_48x48_xpm));
205 // For benchmarking we may want to quit immediatly after drawing
206 if (options.isOn ("quit"))
211 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );