1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
12 #include "flagrowobj.h"
13 #include "historywindow.h"
15 #include "mapeditor.h"
20 #include "texteditor.h"
21 #include "warningdialog.h"
23 extern TextEditor *textEditor;
24 extern Main *mainWindow;
25 extern QString tmpVymDir;
26 extern QString clipboardDir;
27 extern QString clipboardFile;
28 extern bool clipboardEmpty;
29 extern int statusbarTime;
30 extern FlagRowObj* standardFlagsDefault;
31 extern FlagRowObj* systemFlagsDefault;
32 extern QString vymName;
33 extern QString vymVersion;
34 extern QString vymBuildDate;
37 QMenu* branchContextMenu;
38 QMenu* branchAddContextMenu;
39 QMenu* branchRemoveContextMenu;
40 QMenu* branchLinksContextMenu;
41 QMenu* branchXLinksContextMenuEdit;
42 QMenu* branchXLinksContextMenuFollow;
43 QMenu* floatimageContextMenu;
44 QMenu* canvasContextMenu;
45 QMenu* fileLastMapsMenu;
46 QMenu* fileImportMenu;
47 QMenu* fileExportMenu;
50 extern Settings settings;
51 extern Options options;
52 extern ImageIO imageIO;
54 extern QDir vymBaseDir;
55 extern QDir lastImageDir;
56 extern QDir lastFileDir;
57 extern QString iconPath;
58 extern QString flagsPath;
60 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
61 QMainWindow(parent,name,f)
65 setCaption ("VYM - View Your Mind");
67 // Load window settings
68 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
69 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
72 // Sometimes we may need to remember old selections
76 currentColor=Qt::black;
78 // Create unique temporary directory
80 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
83 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
86 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
88 // Create direcctory for clipboard
89 clipboardDir=tmpVymDir+"/clipboard";
90 clipboardFile="map.xml";
92 d.mkdir (clipboardDir,true);
93 makeSubDirs (clipboardDir);
98 // Satellite windows //////////////////////////////////////////
101 historyWindow=new HistoryWindow();
102 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
105 branchPropertyWindow = new BranchPropertyWindow();
106 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
108 // Connect TextEditor, so that we can update flags if text changes
109 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
110 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
112 // Connect HistoryWindow, so that we can update flags
113 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
116 // Initialize script editor
117 scriptEditor = new SimpleScriptEditor();
118 scriptEditor->move (50,50);
120 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
121 this, SLOT( runScript( QString ) ) );
124 // Initialize Find window
125 findWindow=new FindWindow(NULL);
126 findWindow->move (x(),y()+70);
127 connect (findWindow, SIGNAL( findButton(QString) ),
128 this, SLOT(editFind(QString) ) );
129 connect (findWindow, SIGNAL( somethingChanged() ),
130 this, SLOT(editFindChanged() ) );
132 // Initialize some settings, which are platform dependant
135 // application to open URLs
136 p="/mainwindow/readerURL";
137 #if defined(Q_OS_LINUX)
138 s=settings.value (p,"konqueror").toString();
140 #if defined(Q_OS_MACX)
141 s=settings.value (p,"/usr/bin/open").toString();
143 s=settings.value (p,"mozilla");
146 settings.setValue( p,s);
148 // application to open PDFs
149 p="/mainwindow/readerPDF";
150 #if defined(Q_OS_LINUX)
151 s=settings.value (p,"acroread").toString();
153 #if defined(Q_OS_MACX)
154 s=settings.value (p,"/usr/bin/open").toString();
156 s=settings.value (p,"acroread").toString();
159 settings.setValue( p,s);
162 // Create tab widget which holds the maps
163 tabWidget= new QTabWidget (this);
164 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
165 this, SLOT( editorChanged( QWidget * ) ) );
167 lineedit=new QLineEdit (this);
170 setCentralWidget(tabWidget);
174 setupFormatActions();
178 setupSettingsActions();
181 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
186 restoreState (settings.value("/mainwindow/state",0).toByteArray());
194 settings.setValue ( "/mainwindow/geometry/size", size() );
195 settings.setValue ( "/mainwindow/geometry/pos", pos() );
196 settings.setValue ("/mainwindow/state",saveState(0));
198 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
199 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
200 settings.setValue( "/version/version", vymVersion );
201 settings.setValue( "/version/builddate", vymBuildDate );
203 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
204 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
205 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
206 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
207 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
208 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
209 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
211 //TODO save scriptEditor settings
213 // call the destructors
215 delete historyWindow;
216 delete branchPropertyWindow;
218 // Remove temporary directory
219 removeDir (QDir(tmpVymDir));
222 void Main::loadCmdLine()
224 /* TODO draw some kind of splashscreen while loading...
230 QStringList flist=options.getFileList();
231 QStringList::Iterator it=flist.begin();
233 while (it !=flist.end() )
235 fileLoad (*it, NewMap);
241 void Main::statusMessage(const QString &s)
243 statusBar()->message( s);
246 void Main::closeEvent (QCloseEvent* )
252 void Main::setupFileActions()
254 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
255 QToolBar *tb = addToolBar( tr ("&Map") );
256 tb->setObjectName ("mapTB");
259 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
260 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
261 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
263 fileMenu->addAction (a);
264 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
266 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
267 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
268 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
269 fileMenu->addAction (a);
270 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
272 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
273 a->setStatusTip (tr( "Open","Status tip File menu" ) );
274 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
276 fileMenu->addAction (a);
277 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
279 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
280 fileMenu->addSeparator();
282 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
283 a->setStatusTip ( tr( "Save","Status tip file menu" ));
284 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
286 fileMenu->addAction (a);
287 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
290 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
291 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
292 fileMenu->addAction (a);
293 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
295 fileMenu->addSeparator();
297 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
299 a = new QAction(tr("KDE Bookmarks"), this);
300 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
301 a->addTo (fileImportMenu);
302 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
304 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
306 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
307 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
308 a->addTo (fileImportMenu);
309 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
312 a = new QAction("Mind Manager...",this);
313 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
314 fileImportMenu->addAction (a);
315 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
317 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
318 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
319 fileImportMenu->addAction (a);
320 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
322 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
324 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
325 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
326 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
327 fileExportMenu->addAction (a);
329 a = new QAction( "Open Office...", this);
330 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
331 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
332 fileExportMenu->addAction (a);
334 a = new QAction( "Webpage (XHTML)...",this );
335 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
336 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
338 fileExportMenu->addAction (a);
340 a = new QAction( "Text (ASCII)...", this);
341 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
343 fileExportMenu->addAction (a);
345 a = new QAction( "Spreadsheet (CSV)...", this);
346 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
348 fileExportMenu->addAction (a);
350 a = new QAction( tr("KDE Bookmarks","File menu"), this);
351 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
352 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
353 fileExportMenu->addAction (a);
355 a = new QAction( "Taskjuggler...", this );
356 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
358 fileExportMenu->addAction (a);
360 a = new QAction( "LaTeX...", this);
361 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
363 fileExportMenu->addAction (a);
365 a = new QAction( "XML..." , this );
366 a->setStatusTip (tr( "Export as %1").arg("XML"));
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
368 fileExportMenu->addAction (a);
370 fileMenu->addSeparator();
372 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
373 a->setStatusTip ( tr( "Print" ,"File menu") );
374 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
376 fileMenu->addAction (a);
377 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
380 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
381 a->setStatusTip (tr( "Close Map" ) );
382 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
383 fileMenu->addAction (a);
384 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
386 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
387 a->setStatusTip ( tr( "Exit")+" "+vymName );
388 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
389 fileMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
395 void Main::setupEditActions()
397 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
398 tb->setLabel( "Edit Actions" );
399 tb->setObjectName ("actionsTB");
400 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
404 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
405 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
406 a->setStatusTip (tr( "Undo" ) );
407 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
408 a->setEnabled (false);
410 editMenu->addAction (a);
413 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
414 a->setStatusTip (tr( "Redo" ));
415 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
417 editMenu->addAction (a);
418 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
421 editMenu->addSeparator();
422 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
423 a->setStatusTip ( tr( "Copy" ) );
424 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
425 a->setEnabled (false);
427 editMenu->addAction (a);
428 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
431 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
432 a->setStatusTip ( tr( "Cut" ) );
433 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
434 a->setEnabled (false);
436 editMenu->addAction (a);
438 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
440 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
441 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
442 a->setStatusTip ( tr( "Paste" ) );
443 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
444 a->setEnabled (false);
446 editMenu->addAction (a);
449 // Shortcuts to modify heading:
450 a = new QAction(tr( "Edit heading","Edit menu" ),this);
451 a->setStatusTip ( tr( "edit Heading" ));
452 a->setShortcut ( Qt::Key_Enter); //Edit heading
453 // a->setShortcutContext (Qt::WindowShortcut);
455 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
456 actionListBranches.append(a);
457 a = new QAction( tr( "Edit heading","Edit menu" ), this);
458 a->setStatusTip (tr( "edit Heading" ));
459 a->setShortcut (Qt::Key_Return ); //Edit heading
460 //a->setShortcutContext (Qt::WindowShortcut);
462 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
463 actionListBranches.append(a);
464 editMenu->addAction (a);
466 a = new QAction( tr( "Edit heading","Edit menu" ), this);
467 a->setStatusTip (tr( "edit Heading" ));
468 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
469 a->setShortcutContext (Qt::WindowShortcut);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
472 actionListBranches.append(a);
474 // Shortcut to delete selection
475 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
476 a->setStatusTip (tr( "Delete Selection" ));
477 a->setShortcut ( Qt::Key_Delete); //Delete selection
478 a->setShortcutContext (Qt::WindowShortcut);
480 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
483 // Shortcut to add branch
484 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
485 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
486 alt->setShortcut (Qt::Key_A); //Add branch
487 alt->setShortcutContext (Qt::WindowShortcut);
489 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
490 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
491 a->setStatusTip ( tr( "Add a branch as child of selection" ));
492 a->setShortcut (Qt::Key_Insert); //Add branch
493 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
494 actionListBranches.append(a);
495 #if defined (Q_OS_MACX)
496 // In OSX show different shortcut in menues, the keys work indepently always
497 actionEditAddBranch=alt;
499 actionEditAddBranch=a;
501 editMenu->addAction (actionEditAddBranch);
502 tb->addAction (actionEditAddBranch);
505 // Add branch by inserting it at selection
506 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
507 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
508 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
509 a->setShortcutContext (Qt::WindowShortcut);
511 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
512 a->setEnabled (false);
513 actionListBranches.append(a);
514 actionEditAddBranchBefore=a;
515 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
516 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
517 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
518 a->setShortcutContext (Qt::WindowShortcut);
520 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
521 actionListBranches.append(a);
524 a = new QAction(tr( "Add branch above","Edit menu" ), this);
525 a->setStatusTip ( tr( "Add a branch above selection" ));
526 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
527 a->setShortcutContext (Qt::WindowShortcut);
529 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
530 a->setEnabled (false);
531 actionListBranches.append(a);
532 actionEditAddBranchAbove=a;
533 a = new QAction(tr( "Add branch above","Edit menu" ), this);
534 a->setStatusTip ( tr( "Add a branch above selection" ));
535 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
536 a->setShortcutContext (Qt::WindowShortcut);
538 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
539 actionListBranches.append(a);
542 a = new QAction(tr( "Add branch below","Edit menu" ), this);
543 a->setStatusTip ( tr( "Add a branch below selection" ));
544 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
545 a->setShortcutContext (Qt::WindowShortcut);
547 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
548 a->setEnabled (false);
549 actionListBranches.append(a);
550 actionEditAddBranchBelow=a;
551 a = new QAction(tr( "Add branch below","Edit menu" ), this);
552 a->setStatusTip ( tr( "Add a branch below selection" ));
553 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
554 a->setShortcutContext (Qt::WindowShortcut);
556 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
557 actionListBranches.append(a);
559 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
560 a->setStatusTip ( tr( "Move branch up" ) );
561 a->setShortcut (Qt::Key_PageUp ); // Move branch up
562 a->setEnabled (false);
564 editMenu->addAction (a);
565 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
568 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
569 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
570 a->setStatusTip (tr( "Move branch down" ) );
571 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
572 a->setEnabled (false);
574 editMenu->addAction (a);
575 actionEditMoveDown=a;
578 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
579 a->setShortcut ( Qt::Key_ScrollLock );
580 a->setStatusTip (tr( "Scroll branch" ) );
581 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
583 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
584 alt->setShortcut ( Qt::Key_S ); // Scroll branch
585 alt->setStatusTip (tr( "Scroll branch" ));
586 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
587 #if defined(Q_OS_MACX)
588 actionEditToggleScroll=alt;
590 actionEditToggleScroll=a;
592 actionEditToggleScroll->setEnabled (false);
593 actionEditToggleScroll->setToggleAction(true);
594 tb->addAction (actionEditToggleScroll);
595 editMenu->addAction ( actionEditToggleScroll);
596 editMenu->addAction (actionEditToggleScroll);
599 actionListBranches.append(actionEditToggleScroll);
601 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
602 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
603 editMenu->addAction (a);
604 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
606 editMenu->addSeparator();
608 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
609 a->setStatusTip (tr( "Find" ) );
610 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
611 editMenu->addAction (a);
612 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
614 editMenu->addSeparator();
616 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
617 a->setShortcut (Qt::CTRL + Qt::Key_U );
618 a->setShortcut (tr( "Open URL" ));
621 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
624 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
625 a->setStatusTip (tr( "Open URL in new tab" ));
626 a->setShortcut (Qt::CTRL+Qt::Key_U );
628 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
629 actionEditOpenURLTab=a;
631 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
632 a->setStatusTip (tr( "Open all URLs in subtree" ));
634 actionListBranches.append(a);
635 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
636 actionEditOpenMultipleURLTabs=a;
638 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
639 a->setStatusTip ( tr( "Edit URL" ) );
640 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
641 //a->setShortcut ( Qt::Key_U );
642 a->setShortcutContext (Qt::WindowShortcut);
643 actionListBranches.append(a);
645 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
648 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
649 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
650 a->setEnabled (false);
651 actionListBranches.append(a);
652 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
653 actionEditHeading2URL=a;
655 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
656 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
657 a->setEnabled (false);
658 actionListBranches.append(a);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
660 actionEditBugzilla2URL=a;
662 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
663 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
664 a->setEnabled (false);
665 actionListBranches.append(a);
666 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
667 actionEditFATE2URL=a;
669 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
670 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
672 a->setEnabled (false);
673 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
674 actionEditOpenVymLink=a;
676 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
677 a->setStatusTip ( tr( "Open all vym links in subtree" ));
678 a->setEnabled (false);
679 actionListBranches.append(a);
680 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
681 actionEditOpenMultipleVymLinks=a;
684 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
685 a->setEnabled (false);
686 a->setStatusTip ( tr( "Edit link to another vym map" ));
687 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
688 actionListBranches.append(a);
691 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
692 a->setStatusTip ( tr( "Delete link to another vym map" ));
693 a->setEnabled (false);
694 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
695 actionEditDeleteVymLink=a;
697 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
698 a->setStatusTip ( tr( "Hide object in exports" ) );
699 a->setShortcut (Qt::Key_H );
700 a->setToggleAction(true);
702 a->setEnabled (false);
703 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
704 actionEditToggleHideExport=a;
706 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
707 a->setStatusTip ( tr( "Edit Map Info" ));
708 a->setEnabled (true);
709 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
712 // Import at selection (adding to selection)
713 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
714 a->setStatusTip (tr( "Add map at selection" ));
715 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
716 a->setEnabled (false);
717 actionListBranches.append(a);
718 actionEditImportAdd=a;
720 // Import at selection (replacing selection)
721 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
722 a->setStatusTip (tr( "Replace selection with map" ));
723 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
724 a->setEnabled (false);
725 actionListBranches.append(a);
726 actionEditImportReplace=a;
729 a = new QAction( tr( "Save selection","Edit menu" ), this);
730 a->setStatusTip (tr( "Save selection" ));
731 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
732 a->setEnabled (false);
733 actionListBranches.append(a);
734 actionEditSaveBranch=a;
736 // Only remove branch, not its childs
737 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
738 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
739 a->setShortcut (Qt::ALT + Qt::Key_Delete );
740 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
741 a->setEnabled (false);
743 actionListBranches.append(a);
744 actionEditDeleteKeepChilds=a;
746 // Only remove childs of a branch
747 a = new QAction( tr( "Remove childs","Edit menu" ), this);
748 a->setStatusTip (tr( "Remove childs of branch" ));
749 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
750 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
751 a->setEnabled (false);
752 actionListBranches.append(a);
753 actionEditDeleteChilds=a;
755 // Shortcuts for navigating with cursor:
756 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
757 a->setStatusTip ( tr( "Select upper branch" ));
758 a->setShortcut (Qt::Key_Up );
759 a->setShortcutContext (Qt::WindowShortcut);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
762 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
763 a->setStatusTip (tr( "Select lower branch" ));
764 a->setShortcut ( Qt::Key_Down );
765 a->setShortcutContext (Qt::WindowShortcut);
767 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
768 a = new QAction(tr( "Select left branch","Edit menu" ), this);
769 a->setStatusTip ( tr( "Select left branch" ));
770 a->setShortcut (Qt::Key_Left );
771 a->setShortcutContext (Qt::WindowShortcut);
773 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
774 a = new QAction( tr( "Select child branch","Edit menu" ), this);
775 a->setStatusTip (tr( "Select right branch" ));
776 a->setShortcut (Qt::Key_Right);
777 a->setShortcutContext (Qt::WindowShortcut);
779 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
780 a = new QAction( tr( "Select first branch","Edit menu" ), this);
781 a->setStatusTip (tr( "Select first branch" ));
782 a->setShortcut (Qt::Key_Home );
783 a->setShortcutContext (Qt::WindowShortcut);
785 a->setEnabled (false);
786 editMenu->addAction (a);
787 actionListBranches.append(a);
788 actionEditSelectFirst=a;
789 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
790 a = new QAction( tr( "Select last branch","Edit menu" ),this);
791 a->setStatusTip (tr( "Select last branch" ));
792 a->setShortcut ( Qt::Key_End );
793 a->setShortcutContext (Qt::WindowShortcut);
795 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
796 a->setEnabled (false);
797 editMenu->addAction (a);
798 actionListBranches.append(a);
799 actionEditSelectLast=a;
801 a = new QAction( tr( "Add Image...","Edit menu" ), this);
802 a->setStatusTip (tr( "Add Image" ));
803 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
804 actionEditLoadImage=a;
806 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
807 a->setStatusTip (tr( "Set properties for selection" ));
808 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
809 a->setShortcutContext (Qt::WindowShortcut);
810 a->setToggleAction (true);
812 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
813 actionViewTogglePropertyWindow=a;
817 void Main::setupFormatActions()
819 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
821 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
822 tb->setObjectName ("formatTB");
825 pix.fill (Qt::black);
826 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
827 a->setStatusTip ( tr( "Set Color" ));
828 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
830 formatMenu->addAction (a);
832 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
833 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
834 a->setShortcut (Qt::CTRL + Qt::Key_K );
835 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
836 a->setEnabled (false);
838 formatMenu->addAction (a);
839 actionListBranches.append(a);
840 actionFormatPickColor=a;
842 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
843 a->setStatusTip ( tr( "Color branch" ) );
844 a->setShortcut (Qt::CTRL + Qt::Key_B);
845 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
846 a->setEnabled (false);
848 formatMenu->addAction (a);
849 actionListBranches.append(a);
850 actionFormatColorSubtree=a;
852 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
853 a->setStatusTip ( tr( "Color Subtree" ));
854 a->setShortcut (Qt::CTRL + Qt::Key_T);
855 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
856 a->setEnabled (false);
857 formatMenu->addAction (a);
859 actionListBranches.append(a);
860 actionFormatColorSubtree=a;
862 formatMenu->addSeparator();
863 actionGroupFormatLinkStyles=new QActionGroup ( this);
864 actionGroupFormatLinkStyles->setExclusive (true);
865 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
866 a->setStatusTip (tr( "Line" ));
867 a->setToggleAction(true);
868 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
869 formatMenu->addAction (a);
870 actionFormatLinkStyleLine=a;
871 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
872 a->setStatusTip (tr( "Line" ));
873 a->setToggleAction(true);
874 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
875 formatMenu->addAction (a);
876 actionFormatLinkStyleParabel=a;
877 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
878 a->setStatusTip (tr( "PolyLine" ));
879 a->setToggleAction(true);
880 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
881 formatMenu->addAction (a);
882 actionFormatLinkStylePolyLine=a;
883 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
884 a->setStatusTip (tr( "PolyParabel" ) );
885 a->setToggleAction(true);
886 a->setChecked (true);
887 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
888 formatMenu->addAction (a);
889 actionFormatLinkStylePolyParabel=a;
891 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
892 a->setStatusTip (tr( "Hide link" ));
893 a->setToggleAction(true);
894 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
895 actionFormatHideLinkUnselected=a;
897 formatMenu->addSeparator();
898 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
899 a->setStatusTip (tr( "Use same color for links and headings" ));
900 a->setToggleAction(true);
901 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
902 formatMenu->addAction (a);
903 actionFormatLinkColorHint=a;
905 pix.fill (Qt::white);
906 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
907 a->setStatusTip (tr( "Set Link Color" ));
908 formatMenu->addAction (a);
909 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
910 actionFormatLinkColor=a;
912 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
913 a->setStatusTip (tr( "Set Selection Color" ));
914 formatMenu->addAction (a);
915 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
916 actionFormatSelectionColor=a;
918 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
919 a->setStatusTip (tr( "Set Background Color" ));
920 formatMenu->addAction (a);
921 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
922 actionFormatBackColor=a;
924 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
925 a->setStatusTip (tr( "Set Background image" ));
926 formatMenu->addAction (a);
927 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
928 actionFormatBackImage=a;
932 void Main::setupViewActions()
934 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
935 tb->setLabel( "View Actions" );
936 tb->setObjectName ("viewTB");
937 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
940 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
941 a->setStatusTip ( tr( "Zoom reset" ) );
942 a->setShortcut (Qt::CTRL + Qt::Key_0 );
944 viewMenu->addAction (a);
945 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
947 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
948 a->setStatusTip (tr( "Zoom in" ));
949 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
951 viewMenu->addAction (a);
952 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
954 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
955 a->setStatusTip (tr( "Zoom out" ));
956 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
958 viewMenu->addAction (a);
959 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
961 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
962 a->setStatusTip (tr( "Show selection" ));
963 a->setShortcut (Qt::Key_Period);
965 viewMenu->addAction (a);
966 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
968 viewMenu->addSeparator();
970 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
971 a->setStatusTip ( tr( "Show Note Editor" ));
972 a->setShortcut ( Qt::CTRL + Qt::Key_E );
973 a->setToggleAction(true);
975 viewMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
977 actionViewToggleNoteEditor=a;
979 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
980 a->setStatusTip ( tr( "Show History Window" ));
981 a->setShortcut ( Qt::CTRL + Qt::Key_H );
982 a->setToggleAction(true);
984 viewMenu->addAction (a);
985 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
986 actionViewToggleHistoryWindow=a;
988 viewMenu->addAction (actionViewTogglePropertyWindow);
990 viewMenu->addSeparator();
992 a = new QAction(tr( "Antialiasing","View action" ),this );
993 a->setStatusTip ( tr( "Antialiasing" ));
994 a->setToggleAction(true);
995 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
996 viewMenu->addAction (a);
997 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
998 actionViewToggleAntiAlias=a;
1000 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1001 a->setStatusTip (a->text());
1002 a->setToggleAction(true);
1003 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1004 viewMenu->addAction (a);
1005 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1006 actionViewToggleSmoothPixmapTransform=a;
1008 a = new QAction(tr( "Next Map","View action" ), this);
1009 a->setStatusTip (a->text());
1010 a->setShortcut (Qt::ALT + Qt::Key_N );
1011 viewMenu->addAction (a);
1012 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1014 a = new QAction (tr( "Previous Map","View action" ), this );
1015 a->setStatusTip (a->text());
1016 a->setShortcut (Qt::ALT + Qt::Key_P );
1017 viewMenu->addAction (a);
1018 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1022 void Main::setupModeActions()
1024 //QPopupMenu *menu = new QPopupMenu( this );
1025 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1027 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1028 tb->setObjectName ("modesTB");
1030 actionGroupModModes=new QActionGroup ( this);
1031 actionGroupModModes->setExclusive (true);
1032 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1033 a->setShortcut (Qt::Key_J);
1034 a->setStatusTip ( tr( "Use modifier to color branches" ));
1035 a->setToggleAction(true);
1038 actionModModeColor=a;
1040 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1041 a->setShortcut( Qt::Key_K);
1042 a->setStatusTip( tr( "Use modifier to copy" ));
1043 a->setToggleAction(true);
1045 actionModModeCopy=a;
1047 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1048 a->setShortcut (Qt::Key_L);
1049 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1050 a->setToggleAction(true);
1052 actionModModeXLink=a;
1056 void Main::setupFlagActions()
1058 // Create System Flags
1059 systemFlagsDefault = new FlagRowObj ();
1060 systemFlagsDefault->setVisibility (false);
1061 systemFlagsDefault->setName ("systemFlagsDef");
1063 FlagObj *fo = new FlagObj ();
1064 fo->load(QPixmap(flagsPath+"flag-note.png"));
1065 fo->setName("note");
1066 fo->setToolTip(tr("Note","Systemflag"));
1067 systemFlagsDefault->addFlag (fo); // makes deep copy
1069 fo->load(QPixmap(flagsPath+"flag-url.png"));
1071 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1072 systemFlagsDefault->addFlag (fo);
1074 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1075 fo->setName("vymLink");
1076 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1077 systemFlagsDefault->addFlag (fo);
1079 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1080 fo->setName("scrolledright");
1081 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1082 systemFlagsDefault->addFlag (fo);
1084 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1085 fo->setName("tmpUnscrolledright");
1086 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1087 systemFlagsDefault->addFlag (fo);
1089 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1090 fo->setName("hideInExport");
1091 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1092 systemFlagsDefault->addFlag (fo);
1094 // Create Standard Flags
1095 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1096 tb->setObjectName ("standardFlagTB");
1098 standardFlagsDefault = new FlagRowObj ();
1099 standardFlagsDefault->setVisibility (false);
1100 standardFlagsDefault->setName ("standardFlagsDef");
1101 standardFlagsDefault->setToolBar (tb);
1103 fo->load(flagsPath+"flag-exclamationmark.png");
1104 fo->setName ("exclamationmark");
1105 fo->setGroup("standard-mark");
1106 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1109 a->setCheckable(true);
1110 a->setObjectName(fo->getName());
1111 a->setToolTip(tr("Take care!","Standardflag"));
1112 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1113 standardFlagsDefault->addFlag (fo); // makes deep copy
1115 fo->load(flagsPath+"flag-questionmark.png");
1116 fo->setName("questionmark");
1117 fo->setGroup("standard-mark");
1118 a=new QAction (fo->getPixmap(),fo->getName(),this);
1121 a->setCheckable(true);
1122 a->setObjectName(fo->getName());
1123 a->setToolTip(tr("Really?","Standardflag"));
1124 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1125 standardFlagsDefault->addFlag (fo);
1127 fo->load(flagsPath+"flag-hook-green.png");
1128 fo->setName("hook-green");
1129 fo->setGroup("standard-hook");
1130 a=new QAction (fo->getPixmap(),fo->getName(),this);
1133 a->setCheckable(true);
1134 a->setObjectName(fo->getName());
1135 a->setToolTip(tr("ok!","Standardflag"));
1136 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1137 standardFlagsDefault->addFlag (fo);
1139 fo->load(flagsPath+"flag-cross-red.png");
1140 fo->setName("cross-red");
1141 fo->setGroup("standard-hook");
1142 a=new QAction (fo->getPixmap(),fo->getName(),this);
1145 a->setCheckable(true);
1146 a->setObjectName(fo->getName());
1147 a->setToolTip(tr("Not ok!","Standardflag"));
1148 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1149 standardFlagsDefault->addFlag (fo);
1151 fo->load(flagsPath+"flag-stopsign.png");
1152 fo->setName("stopsign");
1153 a=new QAction (fo->getPixmap(),fo->getName(),this);
1156 a->setCheckable(true);
1157 a->setObjectName(fo->getName());
1158 a->setToolTip(tr("This won't work!","Standardflag"));
1159 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1160 standardFlagsDefault->addFlag (fo);
1162 fo->load(flagsPath+"flag-smiley-good.png");
1163 fo->setName("smiley-good");
1164 fo->setGroup("standard-smiley");
1165 a=new QAction (fo->getPixmap(),fo->getName(),this);
1168 a->setCheckable(true);
1169 a->setObjectName(fo->getName());
1170 a->setToolTip(tr("Good","Standardflag"));
1171 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1172 standardFlagsDefault->addFlag (fo);
1174 fo->load(flagsPath+"flag-smiley-sad.png");
1175 fo->setName("smiley-sad");
1176 fo->setGroup("standard-smiley");
1177 a=new QAction (fo->getPixmap(),fo->getName(),this);
1180 a->setCheckable(true);
1181 a->setObjectName(fo->getName());
1182 a->setToolTip(tr("Bad","Standardflag"));
1183 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1184 standardFlagsDefault->addFlag (fo);
1186 fo->load(flagsPath+"flag-smiley-omg.png");
1187 // Original omg.png (in KDE emoticons)
1188 fo->setName("smiley-omg");
1189 fo->setGroup("standard-smiley");
1190 a=new QAction (fo->getPixmap(),fo->getName(),this);
1193 a->setCheckable(true);
1194 a->setObjectName(fo->getName());
1195 a->setToolTip(tr("Oh no!","Standardflag"));
1196 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1197 standardFlagsDefault->addFlag (fo);
1199 fo->load(flagsPath+"flag-kalarm.png");
1200 fo->setName("clock");
1201 a=new QAction (fo->getPixmap(),fo->getName(),this);
1204 a->setCheckable(true);
1205 a->setObjectName(fo->getName());
1206 a->setToolTip(tr("Time critical","Standardflag"));
1207 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1208 standardFlagsDefault->addFlag (fo);
1210 fo->load(flagsPath+"flag-phone.png");
1211 fo->setName("phone");
1212 a=new QAction (fo->getPixmap(),fo->getName(),this);
1215 a->setCheckable(true);
1216 a->setObjectName(fo->getName());
1217 a->setToolTip(tr("Call...","Standardflag"));
1218 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1219 standardFlagsDefault->addFlag (fo);
1221 fo->load(flagsPath+"flag-lamp.png");
1222 fo->setName("lamp");
1223 a=new QAction (fo->getPixmap(),fo->getName(),this);
1226 a->setCheckable(true);
1227 a->setObjectName(fo->getName());
1228 a->setToolTip(tr("Idea!","Standardflag"));
1229 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1230 standardFlagsDefault->addFlag (fo);
1232 fo->load(flagsPath+"flag-arrow-up.png");
1233 fo->setName("arrow-up");
1234 fo->setGroup("standard-arrow");
1235 a=new QAction (fo->getPixmap(),fo->getName(),this);
1238 a->setCheckable(true);
1239 a->setObjectName(fo->getName());
1240 a->setToolTip(tr("Important","Standardflag"));
1241 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1242 standardFlagsDefault->addFlag (fo);
1244 fo->load(flagsPath+"flag-arrow-down.png");
1245 fo->setName("arrow-down");
1246 fo->setGroup("standard-arrow");
1247 a=new QAction (fo->getPixmap(),fo->getName(),this);
1250 a->setCheckable(true);
1251 a->setObjectName(fo->getName());
1252 a->setToolTip(tr("Unimportant","Standardflag"));
1253 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1254 standardFlagsDefault->addFlag (fo);
1256 fo->load(flagsPath+"flag-arrow-2up.png");
1257 fo->setName("2arrow-up");
1258 fo->setGroup("standard-arrow");
1259 a=new QAction (fo->getPixmap(),fo->getName(),this);
1262 a->setCheckable(true);
1263 a->setObjectName(fo->getName());
1264 a->setToolTip(tr("Very important!","Standardflag"));
1265 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1266 standardFlagsDefault->addFlag (fo);
1268 fo->load(flagsPath+"flag-arrow-2down.png");
1269 fo->setName("2arrow-down");
1270 fo->setGroup("standard-arrow");
1271 a=new QAction (fo->getPixmap(),fo->getName(),this);
1274 a->setCheckable(true);
1275 a->setObjectName(fo->getName());
1276 a->setToolTip(tr("Very unimportant!","Standardflag"));
1277 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1278 standardFlagsDefault->addFlag (fo);
1280 fo->load(flagsPath+"flag-thumb-up.png");
1281 fo->setName("thumb-up");
1282 fo->setGroup("standard-thumb");
1283 a=new QAction (fo->getPixmap(),fo->getName(),this);
1286 a->setCheckable(true);
1287 a->setObjectName(fo->getName());
1288 a->setToolTip(tr("I like this","Standardflag"));
1289 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1290 standardFlagsDefault->addFlag (fo);
1292 fo->load(flagsPath+"flag-thumb-down.png");
1293 fo->setName("thumb-down");
1294 fo->setGroup("standard-thumb");
1295 a=new QAction (fo->getPixmap(),fo->getName(),this);
1298 a->setCheckable(true);
1299 a->setObjectName(fo->getName());
1300 a->setToolTip(tr("I do not like this","Standardflag"));
1301 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1302 standardFlagsDefault->addFlag (fo);
1304 fo->load(flagsPath+"flag-rose.png");
1305 fo->setName("rose");
1306 a=new QAction (fo->getPixmap(),fo->getName(),this);
1309 a->setCheckable(true);
1310 a->setObjectName(fo->getName());
1311 a->setToolTip(tr("Rose","Standardflag"));
1312 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1313 standardFlagsDefault->addFlag (fo);
1315 fo->load(flagsPath+"flag-heart.png");
1316 fo->setName("heart");
1317 a=new QAction (fo->getPixmap(),fo->getName(),this);
1319 a->setCheckable(true);
1320 a->setObjectName(fo->getName());
1321 a->setToolTip(tr("I just love... ","Standardflag"));
1322 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1323 standardFlagsDefault->addFlag (fo);
1325 fo->load(flagsPath+"flag-present.png");
1326 fo->setName("present");
1327 a=new QAction (fo->getPixmap(),fo->getName(),this);
1330 a->setCheckable(true);
1331 a->setObjectName(fo->getName());
1332 a->setToolTip(tr("Surprise!","Standardflag"));
1333 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1334 standardFlagsDefault->addFlag (fo);
1336 fo->load(flagsPath+"flag-flash.png");
1337 fo->setName("flash");
1338 a=new QAction (fo->getPixmap(),fo->getName(),this);
1341 a->setCheckable(true);
1342 a->setObjectName(fo->getName());
1343 a->setToolTip(tr("Dangerous","Standardflag"));
1344 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1345 standardFlagsDefault->addFlag (fo);
1347 fo->load(flagsPath+"flag-info.png");
1348 // Original: xsldbg_output.png
1349 fo->setName("info");
1350 a=new QAction (fo->getPixmap(),fo->getName(),this);
1353 a->setCheckable(true);
1354 a->setObjectName(fo->getName());
1355 a->setToolTip(tr("Info","Standardflag"));
1356 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1357 standardFlagsDefault->addFlag (fo);
1359 fo->load(flagsPath+"flag-lifebelt.png");
1360 // Original khelpcenter.png
1361 fo->setName("lifebelt");
1362 a=new QAction (fo->getPixmap(),fo->getName(),this);
1365 a->setCheckable(true);
1366 a->setObjectName(fo->getName());
1367 a->setToolTip(tr("This will help","Standardflag"));
1368 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1369 standardFlagsDefault->addFlag (fo);
1375 void Main::setupSettingsActions()
1377 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1381 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1382 a->setStatusTip ( tr( "Set application to open pdf files"));
1383 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1384 settingsMenu->addAction (a);
1386 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1387 a->setStatusTip( tr( "Set application to open external links"));
1388 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1389 settingsMenu->addAction (a);
1391 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1392 a->setStatusTip( tr( "Set path for macros"));
1393 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1394 settingsMenu->addAction (a);
1396 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1397 a->setStatusTip( tr( "Set number of undo levels"));
1398 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1399 settingsMenu->addAction (a);
1401 settingsMenu->addSeparator();
1403 a = new QAction( tr( "Autosave","Settings action"), this);
1404 a->setStatusTip( tr( "Autosave"));
1405 a->setToggleAction(true);
1406 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1407 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1408 settingsMenu->addAction (a);
1409 actionSettingsAutosaveToggle=a;
1411 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1412 a->setStatusTip( tr( "Autosave time"));
1413 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1414 settingsMenu->addAction (a);
1415 actionSettingsAutosaveTime=a;
1417 settingsMenu->addSeparator();
1419 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1420 a->setStatusTip( tr( "Edit branch after adding it" ));
1421 a->setToggleAction(true);
1422 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1423 settingsMenu->addAction (a);
1424 actionSettingsAutoEdit=a;
1426 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1427 a->setStatusTip( tr( "Select branch after adding it" ));
1428 a->setToggleAction(true);
1429 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1430 settingsMenu->addAction (a);
1431 actionSettingsAutoSelectHeading=a;
1433 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1434 a->setStatusTip( tr( "Select heading before editing" ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1437 settingsMenu->addAction (a);
1438 actionSettingsAutoSelectText=a;
1440 a= new QAction( tr( "Delete key","Settings action" ), this);
1441 a->setStatusTip( tr( "Delete key for deleting branches" ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1444 settingsMenu->addAction (a);
1445 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1446 actionSettingsUseDelKey=a;
1448 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1449 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1450 a->setToggleAction(true);
1451 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1452 settingsMenu->addAction (a);
1453 actionSettingsUseFlagGroups=a;
1455 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1456 a->setStatusTip( tr( "Use hide flag during exports " ));
1457 a->setToggleAction(true);
1458 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1459 settingsMenu->addAction (a);
1460 actionSettingsUseHideExport=a;
1464 void Main::setupTestActions()
1466 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1469 a = new QAction( "Test function 1" , this);
1470 a->setStatusTip( "Call test function 1" );
1471 testMenu->addAction (a);
1472 //a->setShortcut (Qt::Key_F4 );
1473 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1475 a = new QAction( "Test function 2" , this);
1476 a->setStatusTip( "Call test function 2" );
1477 //a->setShortcut (Qt::Key_F4 );
1478 testMenu->addAction (a);
1479 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1481 a = new QAction( "Command" , this);
1482 a->setStatusTip( "Enter command to call in editor" );
1483 //a->setShortcut (Qt::Key_F5 );
1484 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1485 testMenu->addAction (a);
1489 void Main::setupHelpActions()
1491 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1494 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1495 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1496 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1497 helpMenu->addAction (a);
1499 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1500 a->setStatusTip( tr( "Open VYM example maps " ));
1501 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1502 helpMenu->addAction (a);
1504 a = new QAction( tr( "About VYM","Help action" ), this);
1505 a->setStatusTip( tr( "About VYM")+vymName);
1506 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1507 helpMenu->addAction (a);
1509 a = new QAction( tr( "About QT","Help action" ), this);
1510 a->setStatusTip( tr( "Information about QT toolkit" ));
1511 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1512 helpMenu->addAction (a);
1516 void Main::setupContextMenus()
1520 // Context Menu for branch or mapcenter
1521 branchContextMenu =new QMenu (this);
1522 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1523 branchContextMenu->addSeparator();
1526 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1527 branchAddContextMenu->addAction (actionEditPaste );
1528 branchAddContextMenu->addAction ( actionEditAddBranch );
1529 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1530 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1531 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1532 branchAddContextMenu->addSeparator();
1533 branchAddContextMenu->addAction ( actionEditImportAdd );
1534 branchAddContextMenu->addAction ( actionEditImportReplace );
1537 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1538 branchRemoveContextMenu->addAction (actionEditCut);
1539 branchRemoveContextMenu->addAction ( actionEditDelete );
1540 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1541 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1544 actionEditSaveBranch->addTo( branchContextMenu );
1546 branchContextMenu->addSeparator();
1547 branchContextMenu->addAction ( actionEditLoadImage);
1549 // Submenu for Links (URLs, vymLinks)
1550 branchLinksContextMenu =new QMenu (this);
1552 branchContextMenu->addSeparator();
1553 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1554 branchLinksContextMenu->addAction ( actionEditOpenURL );
1555 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1556 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1557 branchLinksContextMenu->addAction ( actionEditURL );
1558 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1559 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1560 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1562 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1564 branchLinksContextMenu->addSeparator();
1565 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1566 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1567 branchLinksContextMenu->addAction ( actionEditVymLink );
1568 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1571 // Context Menu for XLinks in a branch menu
1572 // This will be populated "on demand" in MapEditor::updateActions
1573 branchContextMenu->addSeparator();
1574 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1575 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1576 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1577 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1580 // Context menu for floatimage
1581 floatimageContextMenu =new QMenu (this);
1582 a= new QAction (tr ("Save image","Context action"),this);
1583 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1584 floatimageContextMenu->addAction (a);
1586 floatimageContextMenu->addSeparator();
1587 actionEditCopy->addTo( floatimageContextMenu );
1588 actionEditCut->addTo( floatimageContextMenu );
1590 floatimageContextMenu->addSeparator();
1591 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1594 // Context menu for canvas
1595 canvasContextMenu =new QMenu (this);
1596 actionEditMapInfo->addTo( canvasContextMenu );
1597 canvasContextMenu->insertSeparator();
1598 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1599 canvasContextMenu->insertSeparator();
1600 actionFormatLinkColorHint->addTo( canvasContextMenu );
1601 actionFormatLinkColor->addTo( canvasContextMenu );
1602 actionFormatSelectionColor->addTo( canvasContextMenu );
1603 actionFormatBackColor->addTo( canvasContextMenu );
1604 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1606 // Menu for last opened files
1608 for (int i = 0; i < MaxRecentFiles; ++i)
1610 recentFileActions[i] = new QAction(this);
1611 recentFileActions[i]->setVisible(false);
1612 fileLastMapsMenu->addAction(recentFileActions[i]);
1613 connect(recentFileActions[i], SIGNAL(triggered()),
1614 this, SLOT(fileLoadRecent()));
1616 setupRecentMapsMenu();
1619 void Main::setupRecentMapsMenu()
1621 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1623 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1625 for (int i = 0; i < numRecentFiles; ++i) {
1626 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1627 recentFileActions[i]->setText(text);
1628 recentFileActions[i]->setData(files[i]);
1629 recentFileActions[i]->setVisible(true);
1631 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1632 recentFileActions[j]->setVisible(false);
1635 void Main::setupMacros()
1637 for (int i = 0; i <= 11; i++)
1639 macroActions[i] = new QAction(this);
1640 macroActions[i]->setData(i);
1641 addAction (macroActions[i]);
1642 connect(macroActions[i], SIGNAL(triggered()),
1643 this, SLOT(callMacro()));
1645 macroActions[0]->setShortcut ( Qt::Key_F1 );
1646 macroActions[1]->setShortcut ( Qt::Key_F2 );
1647 macroActions[2]->setShortcut ( Qt::Key_F3 );
1648 macroActions[3]->setShortcut ( Qt::Key_F4 );
1649 macroActions[4]->setShortcut ( Qt::Key_F5 );
1650 macroActions[5]->setShortcut ( Qt::Key_F6 );
1651 macroActions[6]->setShortcut ( Qt::Key_F7 );
1652 macroActions[7]->setShortcut ( Qt::Key_F8 );
1653 macroActions[8]->setShortcut ( Qt::Key_F9 );
1654 macroActions[9]->setShortcut ( Qt::Key_F10 );
1655 macroActions[10]->setShortcut ( Qt::Key_F11 );
1656 macroActions[11]->setShortcut ( Qt::Key_F12 );
1659 void Main::hideEvent (QHideEvent * )
1661 if (!textEditor->isMinimized() ) textEditor->hide();
1664 void Main::showEvent (QShowEvent * )
1666 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1670 MapEditor* Main::currentMapEditor() const
1672 if ( tabWidget->currentPage() &&
1673 tabWidget->currentPage()->inherits( "MapEditor" ) )
1674 return (MapEditor*)tabWidget->currentPage();
1679 void Main::editorChanged(QWidget *)
1681 // Unselect all possibly selected objects
1682 // (Important to update note editor)
1684 for (int i=0;i<=tabWidget->count() -1;i++)
1687 me=(MapEditor*)tabWidget->page(i);
1690 currentMapEditor()->reselect();
1692 // Update actions to in menus and toolbars according to editor
1696 void Main::fileNew()
1698 QString fn="unnamed";
1699 MapEditor* me = new MapEditor ( NULL);
1700 tabWidget->addTab (me,fn);
1701 tabWidget->showPage(me);
1702 me->viewport()->setFocus();
1703 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1704 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1706 // For the very first map we do not have flagrows yet...
1710 void Main::fileNewCopy()
1712 QString fn="unnamed";
1713 MapEditor* oldME =currentMapEditor();
1717 MapEditor* newME = new MapEditor ( NULL);
1720 tabWidget->addTab (newME,fn);
1721 tabWidget->showPage(newME);
1722 newME->viewport()->setFocus();
1723 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1724 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1725 // For the very first map we do not have flagrows yet...
1726 newME->select("mc:");
1727 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace);
1733 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1735 ErrorCode err=success;
1737 // fn is usually the archive, mapfile the file after uncompressing
1740 // Make fn absolute (needed for unzip)
1741 fn=QDir (fn).absPath();
1747 // Check, if map is already loaded
1749 while (i<=tabWidget->count() -1)
1751 me=(MapEditor*)tabWidget->page(i);
1752 if (me->getFilePath() == fn)
1754 // Already there, ask for confirmation
1755 QMessageBox mb( vymName,
1756 tr("The map %1\nis already opened."
1757 "Opening the same map in multiple editors may lead \n"
1758 "to confusion when finishing working with vym."
1759 "Do you want to").arg(fn),
1760 QMessageBox::Warning,
1761 QMessageBox::Yes | QMessageBox::Default,
1762 QMessageBox::Cancel | QMessageBox::Escape,
1763 QMessageBox::NoButton);
1764 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1765 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1768 case QMessageBox::Yes:
1770 i=tabWidget->count();
1772 case QMessageBox::Cancel:
1784 if ( !fn.isEmpty() )
1786 me = currentMapEditor();
1787 int tabIndex=tabWidget->currentPageIndex();
1788 // Check first, if mapeditor exists
1789 // If it is not default AND we want a new map,
1790 // create a new mapeditor in a new tab
1791 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1793 me= new MapEditor ( NULL);
1794 tabWidget->addTab (me,fn);
1795 tabIndex=tabWidget->indexOf (me);
1796 tabWidget->setCurrentPage (tabIndex);
1797 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1798 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1801 // Check, if file exists (important for creating new files
1802 // from command line
1803 if (!QFile(fn).exists() )
1805 QMessageBox mb( vymName,
1806 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1807 QMessageBox::Question,
1809 QMessageBox::Cancel | QMessageBox::Default,
1810 QMessageBox::NoButton );
1812 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1813 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1816 case QMessageBox::Yes:
1818 currentMapEditor()->setFilePath(fn);
1819 tabWidget->setTabLabel (currentMapEditor(),
1820 currentMapEditor()->getFileName() );
1821 statusBar()->message( "Created " + fn , statusbarTime );
1824 case QMessageBox::Cancel:
1825 // don't create new map
1826 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1833 //tabWidget->currentPage() won't be NULL here, because of above...
1834 tabWidget->showPage(me);
1835 me->viewport()->setFocus();
1837 // Create temporary directory for packing
1839 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1842 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1843 tr("Couldn't create temporary directory before load\n"));
1847 // Try to unzip file
1848 err=unzipDir (tmpMapDir,fn);
1852 me->setZipped(false);
1855 me->setZipped(true);
1857 // Look for mapname.xml
1858 mapfile= fn.left(fn.findRev(".",-1,true));
1859 mapfile=mapfile.section( '/', -1 );
1860 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1861 if (!file.exists() )
1863 // mapname.xml does not exist, well,
1864 // maybe someone renamed the mapname.vym file...
1865 // Try to find any .xml in the toplevel
1866 // directory of the .vym file
1867 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1868 if (flist.count()==1)
1870 // Only one entry, take this one
1871 mapfile=tmpMapDir + "/"+flist.first();
1874 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1875 *it=tmpMapDir + "/" + *it;
1876 // TODO Multiple entries, load all (but only the first one into this ME)
1877 //mainWindow->fileLoadFromTmp (flist);
1878 //returnCode=1; // Silently forget this attempt to load
1879 qWarning ("MainWindow::load (fn) multimap found...");
1882 if (flist.isEmpty() )
1884 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1885 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1888 } //file doesn't exist
1890 mapfile=file.name();
1895 // Save existing filename in case we import
1896 QString fn_org=me->getFilePath();
1898 // Finally load map into mapEditor
1899 me->setFilePath (mapfile,fn);
1900 err=me->load(mapfile,lmode);
1902 // Restore old (maybe empty) filepath, if this is an import
1904 me->setFilePath (fn_org);
1907 // Finally check for errors and go home
1910 if (lmode==NewMap) fileCloseMap();
1911 statusBar()->message( "Could not load " + fn, statusbarTime );
1916 me->setFilePath (fn);
1917 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1918 if (fn.left(9)!="/tmp/vym-")
1920 // Only append to lastMaps if not loaded from a tmpDir
1921 // e.g. imported bookmarks are in a tmpDir
1922 addRecentMap(me->getFilePath() );
1924 actionFilePrint->setEnabled (true);
1926 statusBar()->message( "Loaded " + fn, statusbarTime );
1930 removeDir (QDir(tmpMapDir));
1936 void Main::fileLoad(const LoadMode &lmode)
1938 QStringList filters;
1939 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1940 QFileDialog *fd=new QFileDialog( this);
1941 fd->setDir (lastFileDir);
1942 fd->setFileMode (QFileDialog::ExistingFiles);
1943 fd->setFilters (filters);
1947 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1950 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1953 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1959 if ( fd->exec() == QDialog::Accepted )
1961 lastFileDir=fd->directory().path();
1962 QStringList flist = fd->selectedFiles();
1963 QStringList::Iterator it = flist.begin();
1964 while( it != flist.end() )
1967 fileLoad(*it, lmode);
1974 void Main::fileLoad()
1979 void Main::fileLoadRecent()
1981 QAction *action = qobject_cast<QAction *>(sender());
1983 fileLoad (action->data().toString(), NewMap);
1986 void Main::addRecentMap (const QString &fileName)
1989 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1990 files.removeAll(fileName);
1991 files.prepend(fileName);
1992 while (files.size() > MaxRecentFiles)
1995 settings.setValue("/mainwindow/recentFileList", files);
1997 setupRecentMapsMenu();
2000 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
2002 // tmp dir for zipping
2006 ErrorCode err=success;
2008 QString safeFilePath;
2010 bool saveZipped=me->saveZipped();
2014 QString fn=me->getFilePath();
2015 // filename=unnamed, filepath="" in constructor of mapEditor
2016 if ( !fn.isEmpty() )
2018 // We have a filepath, go on saving
2019 // First remove existing file, we
2020 // don't want to add to old zip archives
2024 QMessageBox::warning( 0, tr( "Save Error" ),
2025 fn+ tr("\ncould not be removed before saving"));
2027 // Look, if we should zip the data:
2030 QMessageBox mb( vymName,
2031 tr("The map %1\ndid not use the compressed "
2032 "vym file format.\nWriting it uncompressed will also write images \n"
2033 "and flags and thus may overwrite files in the "
2034 "given directory\n\nDo you want to write the map").arg(fn),
2035 QMessageBox::Warning,
2036 QMessageBox::Yes | QMessageBox::Default,
2038 QMessageBox::Cancel | QMessageBox::Escape);
2039 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2040 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2041 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2044 case QMessageBox::Yes:
2045 // save compressed (default file format)
2048 case QMessageBox::No:
2049 // save uncompressed
2052 case QMessageBox::Cancel:
2061 // Create temporary directory for packing
2063 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2066 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2067 tr("Couldn't create temporary directory before save\n"));
2071 safeFilePath=me->getFilePath();
2072 me->setFilePath (tmpMapDir+"/"+
2073 me->getMapName()+ ".xml",
2075 me->save (savemode);
2076 me->setFilePath (safeFilePath);
2078 zipDir (tmpMapDir,fn);
2083 safeFilePath=me->getFilePath();
2084 me->setFilePath (fn, safeFilePath);
2085 me->save (savemode);
2086 me->setFilePath (safeFilePath);
2088 } // filepath available
2091 // We have no filepath yet,
2092 // call fileSaveAs() now, this will call fileSave()
2094 // First switch to editor
2095 tabWidget->setCurrentWidget (me);
2096 fileSaveAs(savemode);
2100 if (saveZipped && !tmpMapDir.isEmpty())
2102 removeDir (QDir(tmpMapDir));
2106 statusBar()->message(
2107 tr("Saved %1").arg(me->getFilePath()),
2109 addRecentMap (me->getFilePath() );
2111 statusBar()->message(
2112 tr("Couldn't save ").arg(me->getFilePath()),
2116 void Main::fileSave()
2118 fileSave (currentMapEditor(), CompleteMap);
2121 void Main::fileSave(MapEditor *me)
2123 fileSave (me,CompleteMap);
2126 void Main::fileSaveAs(const SaveMode& savemode)
2130 if (currentMapEditor())
2132 if (savemode==CompleteMap)
2133 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2135 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2136 if ( !fn.isEmpty() )
2138 // Check for existing file
2139 if (QFile (fn).exists())
2141 QMessageBox mb( vymName,
2142 tr("The file %1\nexists already. Do you want to").arg(fn),
2143 QMessageBox::Warning,
2144 QMessageBox::Yes | QMessageBox::Default,
2145 QMessageBox::Cancel | QMessageBox::Escape,
2146 QMessageBox::NoButton);
2147 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2148 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2151 case QMessageBox::Yes:
2154 case QMessageBox::Cancel:
2161 // New file, add extension to filename, if missing
2162 // This is always .vym or .vyp, depending on savemode
2163 if (savemode==CompleteMap)
2165 if (!fn.contains (".vym") && !fn.contains (".xml"))
2169 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2178 currentMapEditor()->setFilePath(fn);
2179 fileSave(currentMapEditor(), savemode);
2182 if (savemode==CompleteMap)
2183 tabWidget->setTabLabel (currentMapEditor(),
2184 currentMapEditor()->getFileName() );
2190 void Main::fileSaveAs()
2192 fileSaveAs (CompleteMap);
2195 void Main::fileImportKDEBookmarks()
2197 ImportKDEBookmarks im;
2199 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2200 currentMapEditor()->setFilePath ("");
2203 void Main::fileImportFirefoxBookmarks()
2205 Q3FileDialog *fd=new Q3FileDialog( this);
2206 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2207 fd->setMode (Q3FileDialog::ExistingFiles);
2208 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2209 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2212 if ( fd->exec() == QDialog::Accepted )
2214 ImportFirefoxBookmarks im;
2215 QStringList flist = fd->selectedFiles();
2216 QStringList::Iterator it = flist.begin();
2217 while( it != flist.end() )
2220 if (im.transform() &&
2221 success==fileLoad (im.getTransformedFile(),NewMap) &&
2222 currentMapEditor() )
2223 currentMapEditor()->setFilePath ("");
2230 void Main::fileImportMM()
2234 Q3FileDialog *fd=new Q3FileDialog( this);
2235 fd->setDir (lastFileDir);
2236 fd->setMode (Q3FileDialog::ExistingFiles);
2237 fd->addFilter ("Mind Manager (*.mmap)");
2238 fd->setCaption(tr("Import")+" "+"Mind Manager");
2241 if ( fd->exec() == QDialog::Accepted )
2243 lastFileDir=fd->dirPath();
2244 QStringList flist = fd->selectedFiles();
2245 QStringList::Iterator it = flist.begin();
2246 while( it != flist.end() )
2249 if (im.transform() &&
2250 success==fileLoad (im.getTransformedFile(),NewMap) &&
2251 currentMapEditor() )
2252 currentMapEditor()->setFilePath ("");
2261 void Main::fileImportDir()
2263 if (currentMapEditor())
2264 currentMapEditor()->importDir();
2267 void Main::fileExportXML()
2269 MapEditor *me=currentMapEditor();
2270 if (me) me->exportXML();
2274 void Main::fileExportXHTML()
2276 MapEditor *me=currentMapEditor();
2277 if (me) me->exportXHTML();
2280 void Main::fileExportImage()
2282 MapEditor *me=currentMapEditor();
2283 if (me) me->exportImage();
2286 void Main::fileExportASCII()
2288 MapEditor *me=currentMapEditor();
2289 if (me) me->exportASCII();
2292 void Main::fileExportCSV() //FIXME not scriptable yet
2294 MapEditor *me=currentMapEditor();
2298 ex.setMapCenter(me->getMapCenter());
2299 ex.addFilter ("CSV (*.csv)");
2300 ex.setDir(lastImageDir);
2301 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2302 if (ex.execDialog() )
2304 me->setExportMode(true);
2306 me->setExportMode(false);
2311 void Main::fileExportLaTeX() //FIXME not scriptable yet
2313 MapEditor *me=currentMapEditor();
2317 ex.setMapCenter(me->getMapCenter());
2318 ex.addFilter ("Tex (*.tex)");
2319 ex.setDir(lastImageDir);
2320 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2321 if (ex.execDialog() )
2323 me->setExportMode(true);
2325 me->setExportMode(false);
2330 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2332 ExportKDEBookmarks ex;
2333 MapEditor *me=currentMapEditor();
2336 ex.setMapCenter (me->getMapCenter() );
2341 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2343 ExportTaskjuggler ex;
2344 MapEditor *me=currentMapEditor();
2347 ex.setMapCenter (me->getMapCenter() );
2348 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2349 ex.setDir(lastImageDir);
2350 ex.addFilter ("Taskjuggler (*.tjp)");
2351 if (ex.execDialog() )
2353 me->setExportMode(true);
2355 me->setExportMode(false);
2360 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2362 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2363 // TODO add preview in dialog
2364 //ImagePreview *p =new ImagePreview (fd);
2365 //fd->setContentsPreviewEnabled( TRUE );
2366 //fd->setContentsPreview( p, p );
2367 //fd->setPreviewMode( QFileDialog::Contents );
2368 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2369 fd->setDir (QDir().current());
2370 if (fd->foundConfig())
2374 if ( fd->exec() == QDialog::Accepted )
2376 QString fn=fd->selectedFile();
2377 if (!fn.contains (".odp"))
2380 //lastImageDir=fn.left(fn.findRev ("/"));
2381 if (currentMapEditor())
2382 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2386 QMessageBox::warning(0,
2388 tr("Couldn't find configuration for export to Open Office\n"));
2392 void Main::fileCloseMap()
2394 if (currentMapEditor())
2396 if (currentMapEditor()->hasChanged())
2398 QMessageBox mb( vymName,
2399 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2400 QMessageBox::Warning,
2401 QMessageBox::Yes | QMessageBox::Default,
2403 QMessageBox::Cancel | QMessageBox::Escape );
2404 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2405 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2408 case QMessageBox::Yes:
2410 fileSave(currentMapEditor(), CompleteMap);
2412 case QMessageBox::No:
2413 // close without saving
2415 case QMessageBox::Cancel:
2420 currentMapEditor()->closeMap();
2421 tabWidget->removePage(currentMapEditor());
2422 if (tabWidget->count()==0)
2423 actionFilePrint->setEnabled (false);
2427 void Main::filePrint()
2429 if (currentMapEditor())
2430 currentMapEditor()->print();
2433 void Main::fileExitVYM()
2435 // Check if one or more editors have changed
2438 for (i=0;i<=tabWidget->count() -1;i++)
2441 me=(MapEditor*)tabWidget->page(i);
2443 // If something changed, ask what to do
2444 if (me->hasChanged())
2446 tabWidget->setCurrentPage(i);
2447 QMessageBox mb( vymName,
2448 tr("This map is not saved yet. Do you want to"),
2449 QMessageBox::Warning,
2450 QMessageBox::Yes | QMessageBox::Default,
2452 QMessageBox::Cancel | QMessageBox::Escape );
2453 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2454 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2457 mb.setActiveWindow();
2458 switch( mb.exec() ) {
2459 case QMessageBox::Yes:
2460 // save (the changed editors) and exit
2461 fileSave(currentMapEditor(), CompleteMap);
2463 case QMessageBox::No:
2464 // exit without saving
2466 case QMessageBox::Cancel:
2467 // don't save and don't exit
2471 } // loop over all MEs
2475 void Main::editUndo()
2477 if (currentMapEditor())
2478 currentMapEditor()->undo();
2481 void Main::editRedo()
2483 if (currentMapEditor())
2484 currentMapEditor()->redo();
2487 void Main::gotoHistoryStep (int i)
2489 if (currentMapEditor())
2490 currentMapEditor()->gotoHistoryStep (i);
2493 void Main::editCopy()
2495 if (currentMapEditor())
2496 currentMapEditor()->copy();
2499 void Main::editPaste()
2501 if (currentMapEditor())
2502 currentMapEditor()->paste();
2505 void Main::editCut()
2507 if (currentMapEditor())
2508 currentMapEditor()->cut();
2511 void Main::editOpenFindWindow()
2513 findWindow->popup();
2514 findWindow->raise();
2515 findWindow->setActiveWindow();
2518 void Main::editFind(QString s)
2521 BranchObj *bo=currentMapEditor()->findText(s, cs);
2524 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2527 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2528 tr("No matches found for \"%1\"").arg(s));
2532 void Main::editFindChanged()
2533 { // Notify editor, to abort the current find process
2534 currentMapEditor()->findReset();
2537 void Main::openTabs(QStringList urls)
2539 if (!urls.isEmpty())
2543 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2545 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2547 QString u=urls.takeFirst();
2548 procBrowser = new QProcess( this );
2550 procBrowser->start(browser,args);
2551 if ( !procBrowser->waitForStarted())
2553 // try to set path to browser
2554 QMessageBox::warning(0,
2556 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2557 tr("Please use Settings->")+tr("Set application to open an URL"));
2562 if (browser.contains("konqueror"))
2564 for (int i=0; i<urls.size(); i++)
2567 // Try to open new tab in existing konqueror started previously by vym
2568 p=new QProcess (this);
2570 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2571 "konqueror-mainwindow#1"<<
2574 p->start ("dcop",args);
2575 if ( !p->waitForStarted() ) success=false;
2578 QMessageBox::warning(0,
2580 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2582 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2584 for (int i=0; i<urls.size(); i++)
2586 // Try to open new tab in firefox
2587 p=new QProcess (this);
2588 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2589 p->start (browser,args);
2590 if ( !p->waitForStarted() ) success=false;
2593 QMessageBox::warning(0,
2595 tr("Couldn't start %1 to open a new tab").arg(browser));
2598 QMessageBox::warning(0,
2600 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2604 void Main::editOpenURL()
2607 if (currentMapEditor())
2609 QString url=currentMapEditor()->getURL();
2611 if (url=="") return;
2612 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2613 procBrowser = new QProcess( this );
2615 procBrowser->start(browser,args);
2616 if ( !procBrowser->waitForStarted())
2618 // try to set path to browser
2619 QMessageBox::warning(0,
2621 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2622 tr("Please use Settings->")+tr("Set application to open an URL"));
2627 void Main::editOpenURLTab()
2629 if (currentMapEditor())
2632 urls.append(currentMapEditor()->getURL());
2636 void Main::editOpenMultipleURLTabs()
2638 if (currentMapEditor())
2641 urls=currentMapEditor()->getURLs();
2647 void Main::editURL()
2649 if (currentMapEditor())
2650 currentMapEditor()->editURL();
2653 void Main::editHeading2URL()
2655 if (currentMapEditor())
2656 currentMapEditor()->editHeading2URL();
2659 void Main::editBugzilla2URL()
2661 if (currentMapEditor())
2662 currentMapEditor()->editBugzilla2URL();
2665 void Main::editFATE2URL()
2667 if (currentMapEditor())
2668 currentMapEditor()->editFATE2URL();
2671 void Main::editHeadingFinished()
2673 // only called from editHeading(), so there is a currentME
2674 MapEditor *me=currentMapEditor();
2677 me->setStateEditHeading (false);
2678 QPoint p; //Not used here, only to find out pos of branch
2680 QString s=me->getHeading(ok,p);
2682 #if defined(Q_OS_MACX)
2684 if (ok && s!=lineedit->text())
2685 me->setHeading(lineedit->text());
2687 lineedit->releaseKeyboard();
2691 if (!prevSelection.isEmpty()) me->select(prevSelection);
2696 void Main::editHeading()
2698 if (currentMapEditor())
2700 MapEditor *me=currentMapEditor();
2701 QString oldSel=me->getSelectString();
2703 if (lineedit->isVisible())
2704 editHeadingFinished();
2709 QString s=currentMapEditor()->getHeading(ok,p);
2713 me->setStateEditHeading (true);
2714 #if defined(Q_OS_MACX)
2715 p=currentMapEditor()->mapTo (this,p);
2716 QDialog *d =new QDialog(NULL);
2717 QLineEdit *le=new QLineEdit (d);
2718 d->setWindowFlags (Qt::FramelessWindowHint);
2719 d->setGeometry(p.x(),p.y(),230,25);
2720 le->resize (d->width()-10,d->height());
2723 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2724 d->activateWindow();
2726 currentMapEditor()->setHeading (le->text());
2729 editHeadingFinished();
2731 p=currentMapEditor()->mapTo (this,p);
2732 lineedit->setGeometry(p.x(),p.y(),230,25);
2733 lineedit->setText(s);
2734 lineedit->setCursorPosition(1);
2735 lineedit->selectAll();
2737 lineedit->grabKeyboard();
2738 lineedit->setFocus();
2742 } // currentMapEditor()
2745 void Main::openVymLinks(const QStringList &vl)
2747 for (int j=0; j<vl.size(); j++)
2749 // compare path with already loaded maps
2753 for (i=0;i<=tabWidget->count() -1;i++)
2755 me=(MapEditor*)tabWidget->page(i);
2756 if (vl.at(j)==me->getFilePath() )
2765 if (!QFile(vl.at(j)).exists() )
2766 QMessageBox::critical( 0, tr( "Critical Error" ),
2767 tr("Couldn't open map %1").arg(vl.at(j)));
2770 fileLoad (vl.at(j), NewMap);
2771 tabWidget->setCurrentPage (tabWidget->count()-1);
2774 // Go to tab containing the map
2775 tabWidget->setCurrentPage (index);
2779 void Main::editOpenVymLink()
2781 if (currentMapEditor())
2784 vl.append(currentMapEditor()->getVymLink());
2789 void Main::editOpenMultipleVymLinks()
2791 QString currentVymLink;
2792 if (currentMapEditor())
2794 QStringList vl=currentMapEditor()->getVymLinks();
2799 void Main::editVymLink()
2801 if (currentMapEditor())
2802 currentMapEditor()->editVymLink();
2805 void Main::editDeleteVymLink()
2807 if (currentMapEditor())
2808 currentMapEditor()->deleteVymLink();
2811 void Main::editToggleHideExport()
2813 if (currentMapEditor())
2814 currentMapEditor()->toggleHideExport();
2817 void Main::editMapInfo()
2819 if (currentMapEditor())
2820 currentMapEditor()->editMapInfo();
2823 void Main::editMoveUp()
2825 if (currentMapEditor())
2826 currentMapEditor()->moveBranchUp();
2829 void Main::editMoveDown()
2831 if (currentMapEditor())
2832 currentMapEditor()->moveBranchDown();
2835 void Main::editToggleScroll()
2837 if (currentMapEditor())
2839 currentMapEditor()->toggleScroll();
2843 void Main::editUnscrollChilds()
2845 if (currentMapEditor())
2846 currentMapEditor()->unscrollChilds();
2849 void Main::editNewBranch()
2851 MapEditor *me=currentMapEditor();
2852 if (!lineedit->isVisible() && me)
2854 BranchObj *bo=(BranchObj*)me->getSelection();
2855 BranchObj *newbo=me->addNewBranch(0);
2858 me->select (newbo->getSelectString());
2862 if (actionSettingsAutoEdit->isOn())
2864 if (!actionSettingsAutoSelectHeading->isOn())
2865 prevSelection=bo->getSelectString();
2871 void Main::editNewBranchBefore()
2873 MapEditor *me=currentMapEditor();
2874 if (!lineedit->isVisible() && me)
2876 BranchObj *bo=(BranchObj*)me->getSelection();
2877 BranchObj *newbo=me->addNewBranchBefore();
2880 me->select (newbo->getSelectString());
2884 if (actionSettingsAutoEdit->isOn())
2886 if (!actionSettingsAutoSelectHeading->isOn())
2887 prevSelection=bo->getSelectString();
2893 void Main::editNewBranchAbove()
2895 MapEditor *me=currentMapEditor();
2896 if (!lineedit->isVisible() && me)
2898 BranchObj *bo=(BranchObj*)me->getSelection();
2899 BranchObj *newbo=me->addNewBranch (-1);
2902 me->select (newbo->getSelectString());
2906 if (actionSettingsAutoEdit->isOn())
2908 if (!actionSettingsAutoSelectHeading->isOn())
2909 prevSelection=bo->getSelectString();
2915 void Main::editNewBranchBelow()
2917 MapEditor *me=currentMapEditor();
2918 if (!lineedit->isVisible() && me)
2920 BranchObj *bo=(BranchObj*)me->getSelection();
2921 BranchObj *newbo=me->addNewBranch (1);
2924 me->select (newbo->getSelectString());
2928 if (actionSettingsAutoEdit->isOn())
2930 if (!actionSettingsAutoSelectHeading->isOn())
2931 prevSelection=bo->getSelectString();
2937 void Main::editImportAdd()
2939 fileLoad (ImportAdd);
2942 void Main::editImportReplace()
2944 fileLoad (ImportReplace);
2947 void Main::editSaveBranch()
2949 fileSaveAs (PartOfMap);
2952 void Main::editDeleteKeepChilds()
2954 if (currentMapEditor())
2955 currentMapEditor()->deleteKeepChilds();
2958 void Main::editDeleteChilds()
2960 if (currentMapEditor())
2961 currentMapEditor()->deleteChilds();
2964 void Main::editDeleteSelection()
2966 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2967 currentMapEditor()->deleteSelection();
2970 void Main::editUpperBranch()
2972 if (currentMapEditor())
2973 currentMapEditor()->selectUpperBranch();
2976 void Main::editLowerBranch()
2978 if (currentMapEditor())
2979 currentMapEditor()->selectLowerBranch();
2982 void Main::editLeftBranch()
2984 if (currentMapEditor())
2985 currentMapEditor()->selectLeftBranch();
2988 void Main::editRightBranch()
2990 if (currentMapEditor())
2991 currentMapEditor()->selectRightBranch();
2994 void Main::editFirstBranch()
2996 if (currentMapEditor())
2997 currentMapEditor()->selectFirstBranch();
3000 void Main::editLastBranch()
3002 if (currentMapEditor())
3003 currentMapEditor()->selectLastBranch();
3006 void Main::editLoadImage()
3008 if (currentMapEditor())
3009 currentMapEditor()->loadFloatImage();
3012 void Main::editSaveImage()
3014 if (currentMapEditor())
3015 currentMapEditor()->saveFloatImage();
3018 void Main::editFollowXLink(QAction *a)
3021 if (currentMapEditor())
3022 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3025 void Main::editEditXLink(QAction *a)
3027 if (currentMapEditor())
3028 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3031 void Main::formatSelectColor()
3033 if (currentMapEditor())
3035 QColor col = QColorDialog::getColor((currentColor ), this );
3036 if ( !col.isValid() ) return;
3037 colorChanged( col );
3041 void Main::formatPickColor()
3043 if (currentMapEditor())
3044 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3047 void Main::colorChanged(QColor c)
3049 QPixmap pix( 16, 16 );
3051 actionFormatColor->setIconSet( pix );
3055 void Main::formatColorBranch()
3057 if (currentMapEditor())
3058 currentMapEditor()->colorBranch(currentColor);
3061 void Main::formatColorSubtree()
3063 if (currentMapEditor())
3064 currentMapEditor()->colorSubtree (currentColor);
3067 void Main::formatLinkStyleLine()
3069 if (currentMapEditor())
3070 currentMapEditor()->setMapLinkStyle("StyleLine");
3073 void Main::formatLinkStyleParabel()
3075 if (currentMapEditor())
3076 currentMapEditor()->setMapLinkStyle("StyleParabel");
3079 void Main::formatLinkStylePolyLine()
3081 if (currentMapEditor())
3082 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3085 void Main::formatLinkStylePolyParabel()
3087 if (currentMapEditor())
3088 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3091 void Main::formatSelectBackColor()
3093 if (currentMapEditor())
3094 currentMapEditor()->selectMapBackgroundColor();
3097 void Main::formatSelectBackImage()
3099 if (currentMapEditor())
3100 currentMapEditor()->selectMapBackgroundImage();
3103 void Main::formatSelectLinkColor()
3105 if (currentMapEditor())
3106 currentMapEditor()->selectMapLinkColor();
3109 void Main::formatSelectSelectionColor()
3111 if (currentMapEditor())
3112 currentMapEditor()->selectMapSelectionColor();
3115 void Main::formatToggleLinkColorHint()
3117 currentMapEditor()->toggleMapLinkColorHint();
3121 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3123 if (currentMapEditor())
3124 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3127 void Main::viewZoomReset()
3129 if (currentMapEditor())
3133 currentMapEditor()->setMatrix( m );
3137 void Main::viewZoomIn()
3139 if (currentMapEditor())
3141 QMatrix m = currentMapEditor()->matrix();
3142 m.scale( 1.25, 1.25 );
3143 currentMapEditor()->setMatrix( m );
3147 void Main::viewZoomOut()
3149 if (currentMapEditor())
3151 QMatrix m = currentMapEditor()->matrix();
3152 m.scale( 0.8, 0.8 );
3153 currentMapEditor()->setMatrix( m );
3157 void Main::viewCenter()
3159 MapEditor *me=currentMapEditor();
3162 me->ensureSelectionVisible();
3166 bool Main::settingsPDF()
3168 // Default browser is set in constructor
3170 QString text = QInputDialog::getText(
3171 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3172 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3174 settings.setValue ("/mainwindow/readerPDF",text);
3179 bool Main::settingsURL()
3181 // Default browser is set in constructor
3183 QString text = QInputDialog::getText(
3184 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3185 settings.value("/mainwindow/readerURL").toString()
3188 settings.setValue ("/mainwindow/readerURL",text);
3192 void Main::settingsMacroDir()
3194 QDir defdir=vymBaseDir;
3195 defdir.cd("macros");
3196 if (!defdir.exists())
3198 QDir dir=QFileDialog::getExistingDirectory (
3200 tr ("Directory with vym macros:"),
3201 settings.value ("/macros/macroDir",defdir.path()).toString()
3204 settings.setValue ("/macros/macroDir",dir.path());
3207 void Main::settingsUndoLevels()
3210 int i = QInputDialog::getInteger(
3212 tr("QInputDialog::getInteger()"),
3213 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3216 settings.setValue ("/mapeditor/stepsTotal",i);
3217 QMessageBox::information( this, tr( "VYM -Information:" ),
3218 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3222 void Main::settingsAutosaveToggle()
3224 settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() );
3227 void Main::settingsAutosaveTime()
3230 int i = QInputDialog::getInteger(
3232 tr("QInputDialog::getInteger()"),
3233 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3236 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3240 void Main::settingsToggleDelKey()
3242 if (actionSettingsUseDelKey->isOn())
3244 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3247 actionEditDelete->setAccel (QKeySequence (""));
3251 void Main::windowToggleNoteEditor()
3253 if (textEditor->isVisible() )
3254 windowHideNoteEditor();
3256 windowShowNoteEditor();
3259 void Main::windowToggleHistory()
3261 if (historyWindow->isVisible())
3262 historyWindow->hide();
3264 historyWindow->show();
3268 void Main::windowToggleProperty()
3270 if (branchPropertyWindow->isVisible())
3271 branchPropertyWindow->hide();
3273 branchPropertyWindow->show();
3275 if(currentMapEditor())
3277 LinkableMapObj *sel=currentMapEditor()->getSelection();
3278 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3279 typeid(*sel) == typeid(MapCenterObj)))
3281 branchPropertyWindow->setMapEditor(currentMapEditor());
3282 branchPropertyWindow->setBranch((BranchObj*)sel);
3287 branchPropertyWindow->setBranch(NULL);
3290 void Main::windowToggleAntiAlias()
3292 bool b=actionViewToggleAntiAlias->isOn();
3294 for (int i=0;i<tabWidget->count();i++)
3297 me=(MapEditor*)tabWidget->page(i);
3298 me->setAntiAlias(b);
3303 void Main::windowToggleSmoothPixmap()
3305 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3307 for (int i=0;i<tabWidget->count();i++)
3310 me=(MapEditor*)tabWidget->page(i);
3311 me->setSmoothPixmap(b);
3315 void Main::updateHistory(SimpleSettings &undoSet)
3317 historyWindow->update (undoSet);
3320 void Main::updateNoteFlag()
3322 if (currentMapEditor())
3323 currentMapEditor()->updateNoteFlag();
3326 void Main::updateSatellites(MapEditor *me)
3328 branchPropertyWindow->setMapEditor (me);
3331 void Main::updateActions()
3333 MapEditor *me=currentMapEditor();
3336 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3338 // updateActions is also called when NoteEditor is closed
3339 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3340 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3341 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3343 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3344 actionFormatLinkColorHint->setOn(true);
3346 actionFormatLinkColorHint->setOn(false);
3348 switch (me->getMapLinkStyle())
3350 case LinkableMapObj::Line:
3351 actionFormatLinkStyleLine->setOn(true);
3353 case LinkableMapObj::Parabel:
3354 actionFormatLinkStyleParabel->setOn(true);
3356 case LinkableMapObj::PolyLine:
3357 actionFormatLinkStylePolyLine->setOn(true);
3359 case LinkableMapObj::PolyParabel:
3360 actionFormatLinkStylePolyParabel->setOn(true);
3367 QPixmap pix( 16, 16 );
3368 pix.fill( me->getMapBackgroundColor() );
3369 actionFormatBackColor->setIconSet( pix );
3370 pix.fill( me->getSelectionColor() );
3371 actionFormatSelectionColor->setIconSet( pix );
3372 pix.fill( me->getMapDefLinkColor() );
3373 actionFormatLinkColor->setIconSet( pix );
3376 actionFileSave->setEnabled( me->hasChanged() );
3377 if (me->isUndoAvailable())
3378 actionEditUndo->setEnabled( true);
3380 actionEditUndo->setEnabled( false);
3382 if (me->isRedoAvailable())
3383 actionEditRedo->setEnabled( true);
3385 actionEditRedo->setEnabled( false);
3387 LinkableMapObj *selection=me->getSelection();
3390 if ( (typeid(*selection) == typeid(BranchObj)) ||
3391 (typeid(*selection) == typeid(MapCenterObj)) )
3393 BranchObj *bo=(BranchObj*)selection;
3394 // Take care of links
3395 if (bo->countXLinks()==0)
3397 branchXLinksContextMenuEdit->clear();
3398 branchXLinksContextMenuFollow->clear();
3403 branchXLinksContextMenuEdit->clear();
3404 branchXLinksContextMenuFollow->clear();
3405 for (int i=0; i<=bo->countXLinks();i++)
3407 bot=bo->XLinkTargetAt(i);
3410 s=bot->getHeading();
3413 branchXLinksContextMenuFollow->addAction (s);
3414 branchXLinksContextMenuEdit->addAction (s);
3419 standardFlagsDefault->setEnabled (true);
3421 actionEditToggleScroll->setEnabled (true);
3422 if ( bo->isScrolled() )
3423 actionEditToggleScroll->setOn(true);
3425 actionEditToggleScroll->setOn(false);
3427 if ( bo->getURL().isEmpty() )
3429 actionEditOpenURL->setEnabled (false);
3430 actionEditOpenURLTab->setEnabled (false);
3434 actionEditOpenURL->setEnabled (true);
3435 actionEditOpenURLTab->setEnabled (true);
3437 if ( bo->getVymLink().isEmpty() )
3439 actionEditOpenVymLink->setEnabled (false);
3440 actionEditDeleteVymLink->setEnabled (false);
3443 actionEditOpenVymLink->setEnabled (true);
3444 actionEditDeleteVymLink->setEnabled (true);
3447 if (bo->canMoveBranchUp())
3448 actionEditMoveUp->setEnabled (true);
3450 actionEditMoveUp->setEnabled (false);
3451 if (bo->canMoveBranchDown())
3452 actionEditMoveDown->setEnabled (true);
3454 actionEditMoveDown->setEnabled (false);
3457 actionEditToggleHideExport->setEnabled (true);
3458 actionEditToggleHideExport->setOn (bo->hideInExport() );
3460 actionEditCopy->setEnabled (true);
3461 actionEditCut->setEnabled (true);
3462 if (!clipboardEmpty)
3463 actionEditPaste->setEnabled (true);
3465 actionEditPaste->setEnabled (false);
3466 for (int i=0; i<actionListBranches.size(); ++i)
3467 actionListBranches.at(i)->setEnabled(true);
3468 actionEditDelete->setEnabled (true);
3469 actionFormatHideLinkUnselected->setOn
3470 (selection->getHideLinkUnselected());
3472 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3474 FloatObj *fo=(FloatImageObj*)selection;
3476 actionEditOpenURL->setEnabled (false);
3477 actionEditOpenVymLink->setEnabled (false);
3478 actionEditDeleteVymLink->setEnabled (false);
3479 actionEditToggleHideExport->setEnabled (true);
3480 actionEditToggleHideExport->setOn (fo->hideInExport() );
3483 actionEditCopy->setEnabled (true);
3484 actionEditCut->setEnabled (true);
3485 actionEditPaste->setEnabled (false);
3486 for (int i=0; i<actionListBranches.size(); ++i)
3487 actionListBranches.at(i)->setEnabled(false);
3488 actionEditDelete->setEnabled (true);
3489 actionFormatHideLinkUnselected->setOn
3490 ( selection->getHideLinkUnselected());
3491 actionEditMoveUp->setEnabled (false);
3492 actionEditMoveDown->setEnabled (false);
3497 actionEditCopy->setEnabled (false);
3498 actionEditCut->setEnabled (false);
3499 actionEditPaste->setEnabled (false);
3500 for (int i=0; i<actionListBranches.size(); ++i)
3501 actionListBranches.at(i)->setEnabled(false);
3503 actionEditToggleScroll->setEnabled (false);
3504 actionEditOpenURL->setEnabled (false);
3505 actionEditOpenVymLink->setEnabled (false);
3506 actionEditDeleteVymLink->setEnabled (false);
3507 actionEditHeading2URL->setEnabled (false);
3508 actionEditDelete->setEnabled (false);
3509 actionEditMoveUp->setEnabled (false);
3510 actionEditMoveDown->setEnabled (false);
3511 actionEditToggleHideExport->setEnabled (false);
3515 Main::ModMode Main::getModMode()
3517 if (actionModModeColor->isOn()) return ModModeColor;
3518 if (actionModModeCopy->isOn()) return ModModeCopy;
3519 if (actionModModeXLink->isOn()) return ModModeXLink;
3523 bool Main::autoEdit()
3525 return actionSettingsAutoEdit->isOn();
3528 bool Main::autoSelectHeading()
3530 return actionSettingsAutoSelectHeading->isOn();
3533 bool Main::useFlagGroups()
3535 return actionSettingsUseFlagGroups->isOn();
3538 void Main::windowShowNoteEditor()
3540 textEditor->setShowWithMain(true);
3542 actionViewToggleNoteEditor->setOn (true);
3545 void Main::windowHideNoteEditor()
3547 textEditor->setShowWithMain(false);
3549 actionViewToggleNoteEditor->setOn (false);
3552 void Main::setScript (const QString &script)
3554 scriptEditor->setScript (script);
3557 void Main::runScript (const QString &script)
3559 if (currentMapEditor())
3560 currentMapEditor()->runScript (script);
3563 void Main::runScriptEverywhere (const QString &script)
3566 for (int i=0;i<=tabWidget->count() -1;i++)
3568 me=(MapEditor*)tabWidget->page(i);
3569 if (me) me->runScript (script);
3573 void Main::windowNextEditor()
3575 if (tabWidget->currentPageIndex() < tabWidget->count())
3576 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3579 void Main::windowPreviousEditor()
3581 if (tabWidget->currentPageIndex() >0)
3582 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3585 void Main::standardFlagChanged()
3587 if (currentMapEditor())
3588 currentMapEditor()->toggleStandardFlag(sender()->name());
3591 void Main::testFunction1()
3593 if (!currentMapEditor()) return;
3594 currentMapEditor()->testFunction1();
3597 void Main::testFunction2()
3599 if (!currentMapEditor()) return;
3600 currentMapEditor()->testFunction2();
3603 void Main::testCommand()
3605 if (!currentMapEditor()) return;
3606 scriptEditor->show();
3609 QString com = QInputDialog::getText(
3610 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3611 if (ok) currentMapEditor()->parseAtom(com);
3615 void Main::helpDoc()
3617 QString locale = QLocale::system().name();
3619 if (locale.left(2)=="es")
3620 docname="vym_es.pdf";
3624 QStringList searchList;
3626 #if defined(Q_OS_MACX)
3627 searchList << "./vym.app/Contents";
3629 // default path in SUSE LINUX
3630 searchList <<"/usr/share/doc/packages/vym/doc";
3633 searchList << "doc"; // relative path for easy testing in tarball
3634 searchList << "doc/tex"; // Easy testing working on vym.tex
3635 searchList << "/usr/share/doc/vym"; // Debian
3636 searchList << "/usr/share/doc/packages";// Knoppix
3640 for (int i=0; i<searchList.count(); ++i)
3642 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3643 if (docfile.exists() )
3652 QMessageBox::critical(0,
3653 tr("Critcal error"),
3654 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3659 Process *pdfProc = new Process();
3660 args <<docfile.fileName();
3662 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3663 if ( !pdfProc->waitForStarted() )
3666 QMessageBox::warning(0,
3668 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3669 tr("Please use Settings->")+tr("Set application to open PDF files"));
3676 void Main::helpDemo()
3678 QStringList filters;
3679 filters <<"VYM example map (*.vym)";
3680 QFileDialog *fd=new QFileDialog( this);
3681 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3682 fd->setFileMode (QFileDialog::ExistingFiles);
3683 fd->setFilters (filters);
3684 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3688 if ( fd->exec() == QDialog::Accepted )
3690 lastFileDir=fd->directory().path();
3691 QStringList flist = fd->selectedFiles();
3692 QStringList::Iterator it = flist.begin();
3693 while( it != flist.end() )
3696 fileLoad(*it, NewMap);
3704 void Main::helpAbout()
3707 ad.setName ("aboutwindow");
3708 ad.setMinimumSize(500,500);
3709 ad.resize (QSize (500,500));
3713 void Main::helpAboutQT()
3715 QMessageBox::aboutQt( this, "Qt Application Example" );
3718 void Main::callMacro ()
3720 QAction *action = qobject_cast<QAction *>(sender());
3724 i=action->data().toInt();
3725 QString mDir (settings.value ("macros/macroDir").toString() );
3727 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3729 if ( !f.open( QIODevice::ReadOnly ) )
3731 QMessageBox::warning(0,
3733 tr("Couldn't find a macro at %1.\n").arg(fn)+
3734 tr("Please use Settings->")+tr("Set directory for vym macros"));
3738 QTextStream ts( &f );
3739 QString m= ts.read();
3743 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3744 currentMapEditor()->runScript (m);