1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "exportoofiledialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 #if defined(Q_OS_WIN32)
25 // Define only this structure as opposed to
26 // including full 'windows.h'. FindWindow
27 // clashes with the one in Win32 API.
28 typedef struct _PROCESS_INFORMATION
34 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
37 extern TextEditor *textEditor;
38 extern Main *mainWindow;
39 extern QString tmpVymDir;
40 extern QString clipboardDir;
41 extern QString clipboardFile;
42 extern bool clipboardEmpty;
43 extern int statusbarTime;
44 extern FlagRowObj* standardFlagsDefault;
45 extern FlagRowObj* systemFlagsDefault;
46 extern QString vymName;
47 extern QString vymVersion;
48 extern QString vymBuildDate;
51 QMenu* branchContextMenu;
52 QMenu* branchAddContextMenu;
53 QMenu* branchRemoveContextMenu;
54 QMenu* branchLinksContextMenu;
55 QMenu* branchXLinksContextMenuEdit;
56 QMenu* branchXLinksContextMenuFollow;
57 QMenu* floatimageContextMenu;
58 QMenu* canvasContextMenu;
59 QMenu* fileLastMapsMenu;
60 QMenu* fileImportMenu;
61 QMenu* fileExportMenu;
64 extern Settings settings;
65 extern Options options;
66 extern ImageIO imageIO;
68 extern QDir vymBaseDir;
69 extern QDir lastImageDir;
70 extern QDir lastFileDir;
71 #if defined(Q_OS_WIN32)
72 extern QDir vymInstallDir;
74 extern QString iconPath;
75 extern QString flagsPath;
77 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
78 QMainWindow(parent,name,f)
82 setObjectName ("MainWindow");
84 setCaption ("VYM - View Your Mind");
86 // Load window settings
87 #if defined(Q_OS_WIN32)
88 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
90 setWindowState(Qt::WindowMaximized);
95 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
96 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
99 // Sometimes we may need to remember old selections
103 currentColor=Qt::black;
105 // Create unique temporary directory
107 tmpVymDir=makeTmpDir (ok,"vym");
110 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
113 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
115 // Create direcctory for clipboard
116 clipboardDir=tmpVymDir+"/clipboard";
117 clipboardFile="map.xml";
118 QDir d(clipboardDir);
119 d.mkdir (clipboardDir,true);
120 makeSubDirs (clipboardDir);
125 // Satellite windows //////////////////////////////////////////
128 historyWindow=new HistoryWindow();
129 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
132 branchPropertyWindow = new BranchPropertyWindow();
133 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 // Connect TextEditor, so that we can update flags if text changes
136 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
137 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
139 // Connect HistoryWindow, so that we can update flags
140 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
143 // Initialize script editor
144 scriptEditor = new SimpleScriptEditor();
145 scriptEditor->move (50,50);
147 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
148 this, SLOT( runScript( QString ) ) );
151 // Initialize Find window
152 findWindow=new FindWindow(NULL);
153 findWindow->move (x(),y()+70);
154 connect (findWindow, SIGNAL( findButton(QString) ),
155 this, SLOT(editFind(QString) ) );
156 connect (findWindow, SIGNAL( somethingChanged() ),
157 this, SLOT(editFindChanged() ) );
159 // Initialize some settings, which are platform dependant
162 // application to open URLs
163 p="/mainwindow/readerURL";
164 #if defined(Q_OS_LINUX)
165 s=settings.value (p,"xdg-open").toString();
167 #if defined(Q_OS_MACX)
168 s=settings.value (p,"/usr/bin/open").toString();
171 #if defined(Q_OS_WIN32)
172 // Assume that system has been set up so that
173 // Explorer automagically opens up the URL
174 // in the user's preferred browser.
175 s=settings.value (p,"explorer").toString();
177 s=settings.value (p,"mozilla").toString();
181 settings.setValue( p,s);
183 // application to open PDFs
184 p="/mainwindow/readerPDF";
185 #if defined(Q_OS_LINUX)
186 s=settings.value (p,"xdg-open").toString();
188 #if defined(Q_OS_MACX)
189 s=settings.value (p,"/usr/bin/open").toString();
190 #elif defined(Q_OS_WIN32)
191 s=settings.value (p,"acrord32").toString();
193 s=settings.value (p,"acroread").toString();
196 settings.setValue( p,s);
198 // width of xLinksMenu
201 // Create tab widget which holds the maps
202 tabWidget= new QTabWidget (this);
203 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
204 this, SLOT( editorChanged( QWidget * ) ) );
206 lineedit=new QLineEdit (this);
209 setCentralWidget(tabWidget);
213 setupFormatActions();
217 setupNetworkActions();
218 setupSettingsActions();
221 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
226 restoreState (settings.value("/mainwindow/state",0).toByteArray());
233 //cout << "Destr MainWindow\n";
235 #if defined(Q_OS_WIN32)
236 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
238 settings.setValue ("/mainwindow/geometry/size", size());
239 settings.setValue ("/mainwindow/geometry/pos", pos());
240 settings.setValue ("/mainwindow/state",saveState(0));
242 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
243 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
244 settings.setValue( "/version/version", vymVersion );
245 settings.setValue( "/version/builddate", vymBuildDate );
247 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
248 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
249 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
250 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
251 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
252 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
253 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
254 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
256 //TODO save scriptEditor settings
258 // call the destructors
260 delete historyWindow;
261 delete branchPropertyWindow;
263 // Remove temporary directory
264 removeDir (QDir(tmpVymDir));
267 void Main::loadCmdLine()
269 /* TODO draw some kind of splashscreen while loading...
275 QStringList flist=options.getFileList();
276 QStringList::Iterator it=flist.begin();
278 while (it !=flist.end() )
280 fileLoad (*it, NewMap);
286 void Main::statusMessage(const QString &s)
288 statusBar()->message( s);
291 void Main::closeEvent (QCloseEvent* )
297 void Main::setupFileActions()
299 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
300 QToolBar *tb = addToolBar( tr ("&Map") );
301 tb->setObjectName ("mapTB");
304 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
305 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
306 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
308 fileMenu->addAction (a);
309 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
311 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
312 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
313 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
314 fileMenu->addAction (a);
315 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
318 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
319 a->setStatusTip (tr( "Open","Status tip File menu" ) );
320 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
322 fileMenu->addAction (a);
323 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
325 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
326 fileMenu->addSeparator();
328 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
329 a->setStatusTip ( tr( "Save","Status tip file menu" ));
330 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
332 fileMenu->addAction (a);
333 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
336 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
337 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
338 fileMenu->addAction (a);
339 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
341 fileMenu->addSeparator();
343 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
345 a = new QAction(tr("KDE 3 Bookmarks"), this);
346 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
347 a->addTo (fileImportMenu);
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
350 a = new QAction(tr("KDE 4 Bookmarks"), this);
351 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
352 a->addTo (fileImportMenu);
353 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
355 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
357 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
358 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
359 a->addTo (fileImportMenu);
360 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
363 a = new QAction("Freemind...",this);
364 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
365 fileImportMenu->addAction (a);
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
368 a = new QAction("Mind Manager...",this);
369 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
370 fileImportMenu->addAction (a);
371 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
373 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
374 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
375 fileImportMenu->addAction (a);
376 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
378 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
380 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
381 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
383 fileExportMenu->addAction (a);
385 a = new QAction( "Open Office...", this);
386 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
388 fileExportMenu->addAction (a);
390 a = new QAction( "Webpage (XHTML)...",this );
391 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
392 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
393 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
394 fileExportMenu->addAction (a);
396 a = new QAction( "Text (ASCII)...", this);
397 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
398 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
399 fileExportMenu->addAction (a);
401 a = new QAction( "Spreadsheet (CSV)...", this);
402 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
403 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
404 fileExportMenu->addAction (a);
406 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
407 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
408 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
409 fileExportMenu->addAction (a);
411 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
412 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
413 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
414 fileExportMenu->addAction (a);
416 a = new QAction( "Taskjuggler...", this );
417 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
418 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
419 fileExportMenu->addAction (a);
421 a = new QAction( "LaTeX...", this);
422 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
423 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
424 fileExportMenu->addAction (a);
426 a = new QAction( "XML..." , this );
427 a->setStatusTip (tr( "Export as %1").arg("XML"));
428 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
429 fileExportMenu->addAction (a);
431 fileMenu->addSeparator();
433 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
434 a->setStatusTip ( tr( "Print" ,"File menu") );
435 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
437 fileMenu->addAction (a);
438 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
441 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
442 a->setStatusTip (tr( "Close Map" ) );
443 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
444 fileMenu->addAction (a);
445 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
447 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
448 a->setStatusTip ( tr( "Exit")+" "+vymName );
449 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
450 fileMenu->addAction (a);
451 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
456 void Main::setupEditActions()
458 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
459 tb->setLabel( "Edit Actions" );
460 tb->setObjectName ("actionsTB");
461 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
465 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
466 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
467 a->setStatusTip (tr( "Undo" ) );
468 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
469 a->setEnabled (false);
471 editMenu->addAction (a);
474 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
475 a->setStatusTip (tr( "Redo" ));
476 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
478 editMenu->addAction (a);
479 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
482 editMenu->addSeparator();
483 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
484 a->setStatusTip ( tr( "Copy" ) );
485 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
486 a->setEnabled (false);
488 editMenu->addAction (a);
489 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
492 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
493 a->setStatusTip ( tr( "Cut" ) );
494 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
495 a->setEnabled (false);
497 editMenu->addAction (a);
499 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
501 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
502 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
503 a->setStatusTip ( tr( "Paste" ) );
504 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
505 a->setEnabled (false);
507 editMenu->addAction (a);
510 // Shortcuts to modify heading:
511 a = new QAction(tr( "Edit heading","Edit menu" ),this);
512 a->setStatusTip ( tr( "edit Heading" ));
513 a->setShortcut ( Qt::Key_Enter); //Edit heading
514 // a->setShortcutContext (Qt::WindowShortcut);
516 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
517 actionListBranches.append(a);
518 a = new QAction( tr( "Edit heading","Edit menu" ), this);
519 a->setStatusTip (tr( "edit Heading" ));
520 a->setShortcut (Qt::Key_Return ); //Edit heading
521 //a->setShortcutContext (Qt::WindowShortcut);
523 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
524 actionListBranches.append(a);
525 editMenu->addAction (a);
527 a = new QAction( tr( "Edit heading","Edit menu" ), this);
528 a->setStatusTip (tr( "edit Heading" ));
529 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
530 a->setShortcutContext (Qt::WindowShortcut);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
533 actionListBranches.append(a);
535 // Shortcut to delete selection
536 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
537 a->setStatusTip (tr( "Delete Selection" ));
538 a->setShortcut ( Qt::Key_Delete); //Delete selection
539 a->setShortcutContext (Qt::WindowShortcut);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
544 // Shortcut to add mapcenter
545 a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
546 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
547 actionEditAddMapCenter = a;
550 // Shortcut to add branch
551 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
552 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
553 alt->setShortcut (Qt::Key_A); //Add branch
554 alt->setShortcutContext (Qt::WindowShortcut);
556 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
557 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
558 a->setStatusTip ( tr( "Add a branch as child of selection" ));
559 a->setShortcut (Qt::Key_Insert); //Add branch
560 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
561 actionListBranches.append(a);
562 #if defined (Q_OS_MACX)
563 // In OSX show different shortcut in menues, the keys work indepently always
564 actionEditAddBranch=alt;
566 actionEditAddBranch=a;
568 editMenu->addAction (actionEditAddBranch);
569 tb->addAction (actionEditAddBranch);
572 // Add branch by inserting it at selection
573 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
574 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
575 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
576 a->setShortcutContext (Qt::WindowShortcut);
578 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
579 a->setEnabled (false);
580 actionListBranches.append(a);
581 actionEditAddBranchBefore=a;
582 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
583 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
584 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
585 a->setShortcutContext (Qt::WindowShortcut);
587 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
588 actionListBranches.append(a);
591 a = new QAction(tr( "Add branch above","Edit menu" ), this);
592 a->setStatusTip ( tr( "Add a branch above selection" ));
593 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
594 a->setShortcutContext (Qt::WindowShortcut);
596 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
597 a->setEnabled (false);
598 actionListBranches.append(a);
599 actionEditAddBranchAbove=a;
600 a = new QAction(tr( "Add branch above","Edit menu" ), this);
601 a->setStatusTip ( tr( "Add a branch above selection" ));
602 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
603 a->setShortcutContext (Qt::WindowShortcut);
605 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
606 actionListBranches.append(a);
609 a = new QAction(tr( "Add branch below","Edit menu" ), this);
610 a->setStatusTip ( tr( "Add a branch below selection" ));
611 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
612 a->setShortcutContext (Qt::WindowShortcut);
614 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
615 a->setEnabled (false);
616 actionListBranches.append(a);
617 actionEditAddBranchBelow=a;
618 a = new QAction(tr( "Add branch below","Edit menu" ), this);
619 a->setStatusTip ( tr( "Add a branch below selection" ));
620 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
621 a->setShortcutContext (Qt::WindowShortcut);
623 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
624 actionListBranches.append(a);
626 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
627 a->setStatusTip ( tr( "Move branch up" ) );
628 a->setShortcut (Qt::Key_PageUp ); // Move branch up
629 a->setEnabled (false);
631 editMenu->addAction (a);
632 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
635 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
636 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
637 a->setStatusTip (tr( "Move branch down" ) );
638 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
639 a->setEnabled (false);
641 editMenu->addAction (a);
642 actionEditMoveDown=a;
644 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
645 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
646 a->setEnabled (true);
648 editMenu->addAction (a);
649 actionEditSortChildren=a;
651 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
652 a->setShortcut ( Qt::Key_ScrollLock );
653 a->setStatusTip (tr( "Scroll branch" ) );
654 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
656 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
657 alt->setShortcut ( Qt::Key_S ); // Scroll branch
658 alt->setStatusTip (tr( "Scroll branch" ));
659 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
660 #if defined(Q_OS_MACX)
661 actionEditToggleScroll=alt;
663 actionEditToggleScroll=a;
665 actionEditToggleScroll->setEnabled (false);
666 actionEditToggleScroll->setToggleAction(true);
667 tb->addAction (actionEditToggleScroll);
668 editMenu->addAction ( actionEditToggleScroll);
669 editMenu->addAction (actionEditToggleScroll);
672 actionListBranches.append(actionEditToggleScroll);
674 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
675 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
676 editMenu->addAction (a);
677 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
679 editMenu->addSeparator();
681 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
682 a->setStatusTip (tr( "Find" ) );
683 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
684 editMenu->addAction (a);
685 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
687 editMenu->addSeparator();
689 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
690 a->setShortcut (Qt::CTRL + Qt::Key_U );
691 a->setShortcut (tr( "Open URL" ));
694 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
697 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
698 a->setStatusTip (tr( "Open URL in new tab" ));
699 //a->setShortcut (Qt::CTRL+Qt::Key_U );
701 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
702 actionEditOpenURLTab=a;
704 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
705 a->setStatusTip (tr( "Open all URLs in subtree" ));
707 actionListBranches.append(a);
708 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
709 actionEditOpenMultipleURLTabs=a;
711 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
712 a->setStatusTip ( tr( "Edit URL" ) );
713 a->setShortcut ( Qt::Key_U );
714 a->setShortcutContext (Qt::WindowShortcut);
715 actionListBranches.append(a);
717 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
720 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
721 a->setStatusTip ( tr( "Edit local URL" ) );
722 a->setShortcut (Qt::SHIFT + Qt::Key_U );
723 a->setShortcutContext (Qt::WindowShortcut);
724 actionListBranches.append(a);
726 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
727 actionEditLocalURL=a;
729 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
730 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
731 a->setEnabled (false);
732 actionListBranches.append(a);
733 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
734 actionEditHeading2URL=a;
736 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
737 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
738 a->setEnabled (false);
739 actionListBranches.append(a);
740 a->setShortcut ( Qt::Key_B );
741 a->setShortcutContext (Qt::WindowShortcut);
743 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
744 actionEditBugzilla2URL=a;
746 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
747 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
748 a->setEnabled (false);
749 actionListBranches.append(a);
750 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
751 actionEditFATE2URL=a;
753 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
754 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
756 a->setEnabled (false);
757 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
758 actionEditOpenVymLink=a;
760 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
761 a->setStatusTip ( tr( "Open all vym links in subtree" ));
762 a->setEnabled (false);
763 actionListBranches.append(a);
764 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
765 actionEditOpenMultipleVymLinks=a;
768 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
769 a->setEnabled (false);
770 a->setStatusTip ( tr( "Edit link to another vym map" ));
771 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
772 actionListBranches.append(a);
775 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
776 a->setStatusTip ( tr( "Delete link to another vym map" ));
777 a->setEnabled (false);
778 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
779 actionEditDeleteVymLink=a;
781 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
782 a->setStatusTip ( tr( "Hide object in exports" ) );
783 a->setShortcut (Qt::Key_H );
784 a->setToggleAction(true);
786 a->setEnabled (false);
787 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
788 actionEditToggleHideExport=a;
790 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
791 a->setStatusTip ( tr( "Edit Map Info" ));
792 a->setEnabled (true);
793 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
796 // Import at selection (adding to selection)
797 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
798 a->setStatusTip (tr( "Add map at selection" ));
799 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
800 a->setEnabled (false);
801 actionListBranches.append(a);
802 actionEditImportAdd=a;
804 // Import at selection (replacing selection)
805 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
806 a->setStatusTip (tr( "Replace selection with map" ));
807 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
808 a->setEnabled (false);
809 actionListBranches.append(a);
810 actionEditImportReplace=a;
813 a = new QAction( tr( "Save selection","Edit menu" ), this);
814 a->setStatusTip (tr( "Save selection" ));
815 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
816 a->setEnabled (false);
817 actionListBranches.append(a);
818 actionEditSaveBranch=a;
820 // Only remove branch, not its childs
821 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
822 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
823 a->setShortcut (Qt::ALT + Qt::Key_Delete );
824 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
825 a->setEnabled (false);
827 actionListBranches.append(a);
828 actionEditDeleteKeepChilds=a;
830 // Only remove childs of a branch
831 a = new QAction( tr( "Remove childs","Edit menu" ), this);
832 a->setStatusTip (tr( "Remove childs of branch" ));
833 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
834 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
835 a->setEnabled (false);
836 actionListBranches.append(a);
837 actionEditDeleteChilds=a;
839 // Shortcuts for navigating with cursor:
840 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
841 a->setStatusTip ( tr( "Select upper branch" ));
842 a->setShortcut (Qt::Key_Up );
843 a->setShortcutContext (Qt::WindowShortcut);
845 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
846 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
847 a->setStatusTip (tr( "Select lower branch" ));
848 a->setShortcut ( Qt::Key_Down );
849 a->setShortcutContext (Qt::WindowShortcut);
851 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
852 a = new QAction(tr( "Select left branch","Edit menu" ), this);
853 a->setStatusTip ( tr( "Select left branch" ));
854 a->setShortcut (Qt::Key_Left );
855 a->setShortcutContext (Qt::WindowShortcut);
857 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
858 a = new QAction( tr( "Select child branch","Edit menu" ), this);
859 a->setStatusTip (tr( "Select right branch" ));
860 a->setShortcut (Qt::Key_Right);
861 a->setShortcutContext (Qt::WindowShortcut);
863 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
864 a = new QAction( tr( "Select first branch","Edit menu" ), this);
865 a->setStatusTip (tr( "Select first branch" ));
866 a->setShortcut (Qt::Key_Home );
867 a->setShortcutContext (Qt::WindowShortcut);
869 a->setEnabled (false);
870 editMenu->addAction (a);
871 actionListBranches.append(a);
872 actionEditSelectFirst=a;
873 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
874 a = new QAction( tr( "Select last branch","Edit menu" ),this);
875 a->setStatusTip (tr( "Select last branch" ));
876 a->setShortcut ( Qt::Key_End );
877 a->setShortcutContext (Qt::WindowShortcut);
879 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
880 a->setEnabled (false);
881 editMenu->addAction (a);
882 actionListBranches.append(a);
883 actionEditSelectLast=a;
885 a = new QAction( tr( "Add Image...","Edit menu" ), this);
886 a->setStatusTip (tr( "Add Image" ));
887 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
888 actionEditLoadImage=a;
890 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
891 a->setStatusTip (tr( "Set properties for selection" ));
892 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
893 a->setShortcutContext (Qt::WindowShortcut);
894 a->setToggleAction (true);
896 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
897 actionViewTogglePropertyWindow=a;
901 void Main::setupFormatActions()
903 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
905 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
906 tb->setObjectName ("formatTB");
909 pix.fill (Qt::black);
910 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
911 a->setStatusTip ( tr( "Set Color" ));
912 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
914 formatMenu->addAction (a);
916 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
917 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
918 a->setShortcut (Qt::CTRL + Qt::Key_K );
919 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
920 a->setEnabled (false);
922 formatMenu->addAction (a);
923 actionListBranches.append(a);
924 actionFormatPickColor=a;
926 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
927 a->setStatusTip ( tr( "Color branch" ) );
928 a->setShortcut (Qt::CTRL + Qt::Key_B);
929 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
930 a->setEnabled (false);
932 formatMenu->addAction (a);
933 actionListBranches.append(a);
934 actionFormatColorSubtree=a;
936 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
937 a->setStatusTip ( tr( "Color Subtree" ));
938 a->setShortcut (Qt::CTRL + Qt::Key_T);
939 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
940 a->setEnabled (false);
941 formatMenu->addAction (a);
943 actionListBranches.append(a);
944 actionFormatColorSubtree=a;
946 formatMenu->addSeparator();
947 actionGroupFormatLinkStyles=new QActionGroup ( this);
948 actionGroupFormatLinkStyles->setExclusive (true);
949 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
950 a->setStatusTip (tr( "Line" ));
951 a->setToggleAction(true);
952 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
953 formatMenu->addAction (a);
954 actionFormatLinkStyleLine=a;
955 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
956 a->setStatusTip (tr( "Line" ));
957 a->setToggleAction(true);
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
959 formatMenu->addAction (a);
960 actionFormatLinkStyleParabel=a;
961 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
962 a->setStatusTip (tr( "PolyLine" ));
963 a->setToggleAction(true);
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
965 formatMenu->addAction (a);
966 actionFormatLinkStylePolyLine=a;
967 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
968 a->setStatusTip (tr( "PolyParabel" ) );
969 a->setToggleAction(true);
970 a->setChecked (true);
971 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
972 formatMenu->addAction (a);
973 actionFormatLinkStylePolyParabel=a;
975 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
976 a->setStatusTip (tr( "Hide link" ));
977 a->setToggleAction(true);
978 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
979 actionFormatHideLinkUnselected=a;
981 formatMenu->addSeparator();
982 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
983 a->setStatusTip (tr( "Use same color for links and headings" ));
984 a->setToggleAction(true);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
986 formatMenu->addAction (a);
987 actionFormatLinkColorHint=a;
989 pix.fill (Qt::white);
990 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
991 a->setStatusTip (tr( "Set Link Color" ));
992 formatMenu->addAction (a);
993 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
994 actionFormatLinkColor=a;
996 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
997 a->setStatusTip (tr( "Set Selection Color" ));
998 formatMenu->addAction (a);
999 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1000 actionFormatSelectionColor=a;
1002 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1003 a->setStatusTip (tr( "Set Background Color" ));
1004 formatMenu->addAction (a);
1005 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1006 actionFormatBackColor=a;
1008 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1009 a->setStatusTip (tr( "Set Background image" ));
1010 formatMenu->addAction (a);
1011 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1012 actionFormatBackImage=a;
1016 void Main::setupViewActions()
1018 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1019 tb->setLabel( "View Actions" );
1020 tb->setObjectName ("viewTB");
1021 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1024 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1025 a->setStatusTip ( tr( "Zoom reset" ) );
1026 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1028 viewMenu->addAction (a);
1029 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1031 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1032 a->setStatusTip (tr( "Zoom in" ));
1033 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1035 viewMenu->addAction (a);
1036 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1038 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1039 a->setStatusTip (tr( "Zoom out" ));
1040 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1042 viewMenu->addAction (a);
1043 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1045 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1046 a->setStatusTip (tr( "Show selection" ));
1047 a->setShortcut (Qt::Key_Period);
1049 viewMenu->addAction (a);
1050 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1052 viewMenu->addSeparator();
1054 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1055 a->setStatusTip ( tr( "Show Note Editor" ));
1056 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1057 a->setToggleAction(true);
1059 viewMenu->addAction (a);
1060 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1061 actionViewToggleNoteEditor=a;
1063 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1064 a->setStatusTip ( tr( "Show History Window" ));
1065 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1066 a->setToggleAction(true);
1068 viewMenu->addAction (a);
1069 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1070 actionViewToggleHistoryWindow=a;
1072 viewMenu->addAction (actionViewTogglePropertyWindow);
1074 viewMenu->addSeparator();
1076 a = new QAction(tr( "Antialiasing","View action" ),this );
1077 a->setStatusTip ( tr( "Antialiasing" ));
1078 a->setToggleAction(true);
1079 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1080 viewMenu->addAction (a);
1081 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1082 actionViewToggleAntiAlias=a;
1084 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1085 a->setStatusTip (a->text());
1086 a->setToggleAction(true);
1087 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1088 viewMenu->addAction (a);
1089 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1090 actionViewToggleSmoothPixmapTransform=a;
1092 a = new QAction(tr( "Next Map","View action" ), this);
1093 a->setStatusTip (a->text());
1094 a->setShortcut (Qt::ALT + Qt::Key_N );
1095 viewMenu->addAction (a);
1096 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1098 a = new QAction (tr( "Previous Map","View action" ), this );
1099 a->setStatusTip (a->text());
1100 a->setShortcut (Qt::ALT + Qt::Key_P );
1101 viewMenu->addAction (a);
1102 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1106 void Main::setupModeActions()
1108 //QPopupMenu *menu = new QPopupMenu( this );
1109 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1111 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1112 tb->setObjectName ("modesTB");
1114 actionGroupModModes=new QActionGroup ( this);
1115 actionGroupModModes->setExclusive (true);
1116 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1117 a->setShortcut (Qt::Key_J);
1118 a->setStatusTip ( tr( "Use modifier to color branches" ));
1119 a->setToggleAction(true);
1122 actionModModeColor=a;
1124 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1125 a->setShortcut( Qt::Key_K);
1126 a->setStatusTip( tr( "Use modifier to copy" ));
1127 a->setToggleAction(true);
1129 actionModModeCopy=a;
1131 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1132 a->setShortcut (Qt::Key_L);
1133 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1134 a->setToggleAction(true);
1136 actionModModeXLink=a;
1140 void Main::setupFlagActions()
1142 // Create System Flags
1146 systemFlagsDefault = new FlagRowObj ();
1147 systemFlagsDefault->setVisibility (false);
1148 systemFlagsDefault->setName ("systemFlagsDef");
1150 FlagObj *fo = new FlagObj ();
1151 fo->load(QPixmap(flagsPath+"flag-note.png"));
1152 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1154 fo->load(QPixmap(flagsPath+"flag-url.png"));
1155 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1157 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1158 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1160 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1161 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1163 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1164 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1166 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1167 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1169 // Create Standard Flags
1170 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1171 tb->setObjectName ("standardFlagTB");
1173 standardFlagsDefault = new FlagRowObj ();
1174 standardFlagsDefault->setVisibility (false);
1175 standardFlagsDefault->setName ("standardFlagsDef");
1176 standardFlagsDefault->setToolBar (tb);
1178 fo->load(flagsPath+"flag-exclamationmark.png");
1179 fo->setGroup("standard-mark");
1180 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1182 fo->load(flagsPath+"flag-questionmark.png");
1183 fo->setGroup("standard-mark");
1184 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1186 fo->load(flagsPath+"flag-hook-green.png");
1187 fo->setGroup("standard-hook");
1188 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1190 fo->load(flagsPath+"flag-cross-red.png");
1191 fo->setGroup("standard-hook");
1192 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1195 fo->load(flagsPath+"flag-stopsign.png");
1196 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1198 fo->load(flagsPath+"flag-smiley-good.png");
1199 fo->setGroup("standard-smiley");
1200 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1202 fo->load(flagsPath+"flag-smiley-sad.png");
1203 fo->setGroup("standard-smiley");
1204 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1206 fo->load(flagsPath+"flag-smiley-omg.png");
1207 fo->setGroup("standard-smiley");
1208 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1209 // Original omg.png (in KDE emoticons)
1212 fo->load(flagsPath+"flag-kalarm.png");
1213 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1215 fo->load(flagsPath+"flag-phone.png");
1216 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1218 fo->load(flagsPath+"flag-lamp.png");
1219 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1221 fo->load(flagsPath+"flag-arrow-up.png");
1222 fo->setGroup("standard-arrow");
1223 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1225 fo->load(flagsPath+"flag-arrow-down.png");
1226 fo->setGroup("standard-arrow");
1227 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1229 fo->load(flagsPath+"flag-arrow-2up.png");
1230 fo->setGroup("standard-arrow");
1231 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1233 fo->load(flagsPath+"flag-arrow-2down.png");
1234 fo->setGroup("standard-arrow");
1235 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1238 fo->load(flagsPath+"flag-thumb-up.png");
1239 fo->setGroup("standard-thumb");
1240 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1242 fo->load(flagsPath+"flag-thumb-down.png");
1243 fo->setGroup("standard-thumb");
1244 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1247 fo->load(flagsPath+"flag-rose.png");
1248 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1250 fo->load(flagsPath+"flag-heart.png");
1251 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1253 fo->load(flagsPath+"flag-present.png");
1254 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1256 fo->load(flagsPath+"flag-flash.png");
1257 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1259 // Original: xsldbg_output.png
1260 fo->load(flagsPath+"flag-info.png");
1261 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1263 // Original khelpcenter.png
1264 fo->load(flagsPath+"flag-lifebelt.png");
1265 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1271 fo->load(flagsPath+"freemind/warning.png");
1272 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1274 for (int i=1; i<8; i++)
1276 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1277 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1280 fo->load(flagsPath+"freemind/back.png");
1281 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1283 fo->load(flagsPath+"freemind/forward.png");
1284 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1286 fo->load(flagsPath+"freemind/attach.png");
1287 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1289 fo->load(flagsPath+"freemind/clanbomber.png");
1290 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1292 fo->load(flagsPath+"freemind/desktopnew.png");
1293 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1295 fo->load(flagsPath+"freemind/flag.png");
1296 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1299 fo->load(flagsPath+"freemind/gohome.png");
1300 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1303 fo->load(flagsPath+"freemind/kaddressbook.png");
1304 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1306 fo->load(flagsPath+"freemind/knotify.png");
1307 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1309 fo->load(flagsPath+"freemind/korn.png");
1310 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1312 fo->load(flagsPath+"freemind/mail.png");
1313 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1315 fo->load(flagsPath+"freemind/password.png");
1316 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1318 fo->load(flagsPath+"freemind/pencil.png");
1319 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1321 fo->load(flagsPath+"freemind/stop.png");
1322 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1324 fo->load(flagsPath+"freemind/wizard.png");
1325 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1327 fo->load(flagsPath+"freemind/xmag.png");
1328 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1330 fo->load(flagsPath+"freemind/bell.png");
1331 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1333 fo->load(flagsPath+"freemind/bookmark.png");
1334 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1336 fo->load(flagsPath+"freemind/penguin.png");
1337 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1339 fo->load(flagsPath+"freemind/licq.png");
1340 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1345 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1348 fo->setToolTip (tooltip);
1349 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1355 fo->setAlwaysVisible(aw);
1356 a->setCheckable(true);
1357 a->setObjectName(fo->getName());
1358 a->setToolTip(tooltip);
1359 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1360 standardFlagsDefault->addFlag (fo);
1364 systemFlagsDefault->addFlag (fo);
1368 void Main::setupNetworkActions()
1370 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1372 QMenu *netMenu = menuBar()->addMenu( "Network" );
1376 a = new QAction( "Start TCPserver for MapEditor",this);
1377 //a->setStatusTip ( "Set application to open pdf files"));
1378 a->setShortcut ( Qt::Key_T ); //New TCP server
1379 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1380 netMenu->addAction (a);
1382 a = new QAction( "Connect MapEditor to server",this);
1383 //a->setStatusTip ( "Set application to open pdf files"));
1384 a->setShortcut ( Qt::Key_C ); // Connect to server
1385 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1386 netMenu->addAction (a);
1390 void Main::setupSettingsActions()
1392 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1396 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1397 a->setStatusTip ( tr( "Set application to open pdf files"));
1398 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1399 settingsMenu->addAction (a);
1401 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1402 a->setStatusTip( tr( "Set application to open external links"));
1403 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1404 settingsMenu->addAction (a);
1406 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1407 a->setStatusTip( tr( "Set path for macros"));
1408 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1409 settingsMenu->addAction (a);
1411 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1412 a->setStatusTip( tr( "Set number of undo levels"));
1413 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1414 settingsMenu->addAction (a);
1416 settingsMenu->addSeparator();
1418 a = new QAction( tr( "Autosave","Settings action"), this);
1419 a->setStatusTip( tr( "Autosave"));
1420 a->setToggleAction(true);
1421 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1422 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1423 settingsMenu->addAction (a);
1424 actionSettingsAutosaveToggle=a;
1426 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1427 a->setStatusTip( tr( "Autosave time"));
1428 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1429 settingsMenu->addAction (a);
1430 actionSettingsAutosaveTime=a;
1432 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1433 a->setStatusTip( tr( "Write backup file on save"));
1434 a->setToggleAction(true);
1435 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1436 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1437 settingsMenu->addAction (a);
1438 actionSettingsWriteBackupFile=a;
1440 settingsMenu->addSeparator();
1442 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1443 a->setStatusTip( tr( "Edit branch after adding it" ));
1444 a->setToggleAction(true);
1445 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1446 settingsMenu->addAction (a);
1447 actionSettingsAutoEditNewBranch=a;
1449 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1450 a->setStatusTip( tr( "Select branch after adding it" ));
1451 a->setToggleAction(true);
1452 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1453 settingsMenu->addAction (a);
1454 actionSettingsAutoSelectNewBranch=a;
1456 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1457 a->setStatusTip( tr( "Select heading before editing" ));
1458 a->setToggleAction(true);
1459 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1460 settingsMenu->addAction (a);
1461 actionSettingsAutoSelectText=a;
1463 a= new QAction( tr( "Delete key","Settings action" ), this);
1464 a->setStatusTip( tr( "Delete key for deleting branches" ));
1465 a->setToggleAction(true);
1466 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1467 settingsMenu->addAction (a);
1468 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1469 actionSettingsUseDelKey=a;
1471 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1472 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1473 a->setToggleAction(true);
1474 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1475 settingsMenu->addAction (a);
1476 actionSettingsUseFlagGroups=a;
1478 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1479 a->setStatusTip( tr( "Use hide flag during exports " ));
1480 a->setToggleAction(true);
1481 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1482 settingsMenu->addAction (a);
1483 actionSettingsUseHideExport=a;
1485 a = new QAction( tr( "Animation","Settings action"), this);
1486 a->setStatusTip( tr( "Animation"));
1487 a->setToggleAction(true);
1488 a->setOn (settings.value("/animation/use",false).toBool() );
1489 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1490 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1492 settingsMenu->addAction (a);
1494 actionSettingsUseAnimation=a;
1498 void Main::setupTestActions()
1500 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1503 a = new QAction( "Test function 1" , this);
1504 a->setStatusTip( "Call test function 1" );
1505 testMenu->addAction (a);
1506 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1508 a = new QAction( "Test function 2" , this);
1509 a->setStatusTip( "Call test function 2" );
1510 testMenu->addAction (a);
1511 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1513 a = new QAction( "Command" , this);
1514 a->setStatusTip( "Enter command to call in editor" );
1515 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1516 testMenu->addAction (a);
1520 void Main::setupHelpActions()
1522 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1525 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1526 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1527 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1528 helpMenu->addAction (a);
1530 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1531 a->setStatusTip( tr( "Open VYM example maps " ));
1532 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1533 helpMenu->addAction (a);
1535 a = new QAction( tr( "About VYM","Help action" ), this);
1536 a->setStatusTip( tr( "About VYM")+vymName);
1537 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1538 helpMenu->addAction (a);
1540 a = new QAction( tr( "About QT","Help action" ), this);
1541 a->setStatusTip( tr( "Information about QT toolkit" ));
1542 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1543 helpMenu->addAction (a);
1547 void Main::setupContextMenus()
1551 // Context Menu for branch or mapcenter
1552 branchContextMenu =new QMenu (this);
1553 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1554 branchContextMenu->addSeparator();
1557 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1558 branchAddContextMenu->addAction (actionEditPaste );
1559 branchAddContextMenu->addAction ( actionEditAddBranch );
1560 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1561 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1562 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1563 branchAddContextMenu->addSeparator();
1564 branchAddContextMenu->addAction ( actionEditImportAdd );
1565 branchAddContextMenu->addAction ( actionEditImportReplace );
1568 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1569 branchRemoveContextMenu->addAction (actionEditCut);
1570 branchRemoveContextMenu->addAction ( actionEditDelete );
1571 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1572 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1575 actionEditSaveBranch->addTo( branchContextMenu );
1576 actionFileNewCopy->addTo (branchContextMenu );
1578 branchContextMenu->addSeparator();
1579 branchContextMenu->addAction ( actionEditLoadImage);
1581 // Submenu for Links (URLs, vymLinks)
1582 branchLinksContextMenu =new QMenu (this);
1584 branchContextMenu->addSeparator();
1585 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1586 branchLinksContextMenu->addAction ( actionEditOpenURL );
1587 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1588 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1589 branchLinksContextMenu->addAction ( actionEditURL );
1590 branchLinksContextMenu->addAction ( actionEditLocalURL );
1591 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1592 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1593 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1595 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1597 branchLinksContextMenu->addSeparator();
1598 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1599 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1600 branchLinksContextMenu->addAction ( actionEditVymLink );
1601 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1604 // Context Menu for XLinks in a branch menu
1605 // This will be populated "on demand" in MapEditor::updateActions
1606 branchContextMenu->addSeparator();
1607 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1608 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1609 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1610 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1613 // Context menu for floatimage
1614 floatimageContextMenu =new QMenu (this);
1615 a= new QAction (tr ("Save image","Context action"),this);
1616 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1617 floatimageContextMenu->addAction (a);
1619 floatimageContextMenu->addSeparator();
1620 actionEditCopy->addTo( floatimageContextMenu );
1621 actionEditCut->addTo( floatimageContextMenu );
1623 floatimageContextMenu->addSeparator();
1624 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1627 // Context menu for canvas
1628 canvasContextMenu =new QMenu (this);
1629 actionEditMapInfo->addTo( canvasContextMenu );
1630 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1631 actionEditAddMapCenter->addTo( canvasContextMenu );
1632 canvasContextMenu->insertSeparator();
1633 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1634 canvasContextMenu->insertSeparator();
1635 actionFormatLinkColorHint->addTo( canvasContextMenu );
1636 actionFormatLinkColor->addTo( canvasContextMenu );
1637 actionFormatSelectionColor->addTo( canvasContextMenu );
1638 actionFormatBackColor->addTo( canvasContextMenu );
1639 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1641 // Menu for last opened files
1643 for (int i = 0; i < MaxRecentFiles; ++i)
1645 recentFileActions[i] = new QAction(this);
1646 recentFileActions[i]->setVisible(false);
1647 fileLastMapsMenu->addAction(recentFileActions[i]);
1648 connect(recentFileActions[i], SIGNAL(triggered()),
1649 this, SLOT(fileLoadRecent()));
1651 setupRecentMapsMenu();
1654 void Main::setupRecentMapsMenu()
1656 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1658 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1660 for (int i = 0; i < numRecentFiles; ++i) {
1661 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1662 recentFileActions[i]->setText(text);
1663 recentFileActions[i]->setData(files[i]);
1664 recentFileActions[i]->setVisible(true);
1666 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1667 recentFileActions[j]->setVisible(false);
1670 void Main::setupMacros()
1672 for (int i = 0; i <= 11; i++)
1674 macroActions[i] = new QAction(this);
1675 macroActions[i]->setData(i);
1676 addAction (macroActions[i]);
1677 connect(macroActions[i], SIGNAL(triggered()),
1678 this, SLOT(callMacro()));
1680 macroActions[0]->setShortcut ( Qt::Key_F1 );
1681 macroActions[1]->setShortcut ( Qt::Key_F2 );
1682 macroActions[2]->setShortcut ( Qt::Key_F3 );
1683 macroActions[3]->setShortcut ( Qt::Key_F4 );
1684 macroActions[4]->setShortcut ( Qt::Key_F5 );
1685 macroActions[5]->setShortcut ( Qt::Key_F6 );
1686 macroActions[6]->setShortcut ( Qt::Key_F7 );
1687 macroActions[7]->setShortcut ( Qt::Key_F8 );
1688 macroActions[8]->setShortcut ( Qt::Key_F9 );
1689 macroActions[9]->setShortcut ( Qt::Key_F10 );
1690 macroActions[10]->setShortcut ( Qt::Key_F11 );
1691 macroActions[11]->setShortcut ( Qt::Key_F12 );
1694 void Main::hideEvent (QHideEvent * )
1696 if (!textEditor->isMinimized() ) textEditor->hide();
1699 void Main::showEvent (QShowEvent * )
1701 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1705 MapEditor* Main::currentMapEditor() const
1707 if ( tabWidget->currentPage() &&
1708 tabWidget->currentPage()->inherits( "MapEditor" ) )
1709 return (MapEditor*)tabWidget->currentPage();
1714 void Main::editorChanged(QWidget *)
1716 // Unselect all possibly selected objects
1717 // (Important to update note editor)
1719 for (int i=0;i<=tabWidget->count() -1;i++)
1721 me=(MapEditor*)tabWidget->page(i);
1724 me=currentMapEditor();
1725 if (me) me->reselect();
1727 // Update actions to in menus and toolbars according to editor
1731 void Main::fileNew()
1733 QString fn="unnamed";
1734 MapEditor* me = new MapEditor ( NULL);
1735 tabWidget->addTab (me,fn);
1736 tabWidget->showPage(me);
1737 me->viewport()->setFocus();
1738 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1739 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1741 // For the very first map we do not have flagrows yet...
1745 void Main::fileNewCopy()
1747 QString fn="unnamed";
1748 MapEditor* oldME =currentMapEditor();
1752 MapEditor* newME = new MapEditor ( NULL);
1755 tabWidget->addTab (newME,fn);
1756 tabWidget->showPage(newME);
1757 newME->viewport()->setFocus();
1758 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1759 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1760 // For the very first map we do not have flagrows yet...
1761 newME->select("mc:");
1762 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1768 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1770 ErrorCode err=success;
1772 // fn is usually the archive, mapfile the file after uncompressing
1775 // Make fn absolute (needed for unzip)
1776 fn=QDir (fn).absPath();
1782 // Check, if map is already loaded
1784 while (i<=tabWidget->count() -1)
1786 me=(MapEditor*)tabWidget->page(i);
1787 if (me->getFilePath() == fn)
1789 // Already there, ask for confirmation
1790 QMessageBox mb( vymName,
1791 tr("The map %1\nis already opened."
1792 "Opening the same map in multiple editors may lead \n"
1793 "to confusion when finishing working with vym."
1794 "Do you want to").arg(fn),
1795 QMessageBox::Warning,
1796 QMessageBox::Yes | QMessageBox::Default,
1797 QMessageBox::Cancel | QMessageBox::Escape,
1798 QMessageBox::NoButton);
1799 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1800 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1803 case QMessageBox::Yes:
1805 i=tabWidget->count();
1807 case QMessageBox::Cancel:
1819 if ( !fn.isEmpty() )
1821 me = currentMapEditor();
1822 int tabIndex=tabWidget->currentPageIndex();
1823 // Check first, if mapeditor exists
1824 // If it is not default AND we want a new map,
1825 // create a new mapeditor in a new tab
1826 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1828 me= new MapEditor ( NULL);
1829 tabWidget->addTab (me,fn);
1830 tabIndex=tabWidget->indexOf (me);
1831 tabWidget->setCurrentPage (tabIndex);
1832 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1833 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1836 // Check, if file exists (important for creating new files
1837 // from command line
1840 if (!QFile(fn).exists() )
1842 QMessageBox mb( vymName,
1843 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1844 QMessageBox::Question,
1846 QMessageBox::Cancel | QMessageBox::Default,
1847 QMessageBox::NoButton );
1849 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1850 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1853 case QMessageBox::Yes:
1855 currentMapEditor()->setFilePath(fn);
1856 tabWidget->setTabLabel (currentMapEditor(),
1857 currentMapEditor()->getFileName() );
1858 statusBar()->message( "Created " + fn , statusbarTime );
1861 case QMessageBox::Cancel:
1862 // don't create new map
1863 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1869 //tabWidget->currentPage() won't be NULL here, because of above...
1870 tabWidget->showPage(me);
1871 me->viewport()->setFocus();
1875 // Save existing filename in case we import
1876 QString fn_org=me->getFilePath();
1878 // Finally load map into mapEditor
1879 me->setFilePath (fn);
1880 err=me->load(fn,lmode,ftype);
1882 // Restore old (maybe empty) filepath, if this is an import
1884 me->setFilePath (fn_org);
1887 // Finally check for errors and go home
1890 if (lmode==NewMap) fileCloseMap();
1891 statusBar()->message( "Could not load " + fn, statusbarTime );
1896 me->setFilePath (fn);
1897 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1898 if (!isInTmpDir (fn))
1900 // Only append to lastMaps if not loaded from a tmpDir
1901 // e.g. imported bookmarks are in a tmpDir
1902 addRecentMap(me->getFilePath() );
1904 actionFilePrint->setEnabled (true);
1906 statusBar()->message( "Loaded " + fn, statusbarTime );
1913 void Main::fileLoad(const LoadMode &lmode)
1915 QStringList filters;
1916 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1917 QFileDialog *fd=new QFileDialog( this);
1918 fd->setDir (lastFileDir);
1919 fd->setFileMode (QFileDialog::ExistingFiles);
1920 fd->setFilters (filters);
1924 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1927 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1930 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1936 if ( fd->exec() == QDialog::Accepted )
1938 lastFileDir=fd->directory().path();
1939 QStringList flist = fd->selectedFiles();
1940 QStringList::Iterator it = flist.begin();
1941 while( it != flist.end() )
1944 fileLoad(*it, lmode);
1951 void Main::fileLoad()
1956 void Main::fileLoadRecent()
1958 QAction *action = qobject_cast<QAction *>(sender());
1960 fileLoad (action->data().toString(), NewMap);
1963 void Main::addRecentMap (const QString &fileName)
1966 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1967 files.removeAll(fileName);
1968 files.prepend(fileName);
1969 while (files.size() > MaxRecentFiles)
1972 settings.setValue("/mainwindow/recentFileList", files);
1974 setupRecentMapsMenu();
1977 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1981 if ( me->getFilePath().isEmpty() )
1983 // We have no filepath yet,
1984 // call fileSaveAs() now, this will call fileSave()
1986 // First switch to editor
1987 tabWidget->setCurrentWidget (me);
1988 fileSaveAs(savemode);
1991 if (me->save (savemode)==success)
1993 statusBar()->message(
1994 tr("Saved %1").arg(me->getFilePath()),
1996 addRecentMap (me->getFilePath() );
1998 statusBar()->message(
1999 tr("Couldn't save ").arg(me->getFilePath()),
2003 void Main::fileSave()
2005 fileSave (currentMapEditor(), CompleteMap);
2008 void Main::fileSave(MapEditor *me)
2010 fileSave (me,CompleteMap);
2013 void Main::fileSaveAs(const SaveMode& savemode)
2017 if (currentMapEditor())
2019 if (savemode==CompleteMap)
2020 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2022 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2023 if ( !fn.isEmpty() )
2025 // Check for existing file
2026 if (QFile (fn).exists())
2028 QMessageBox mb( vymName,
2029 tr("The file %1\nexists already. Do you want to").arg(fn),
2030 QMessageBox::Warning,
2031 QMessageBox::Yes | QMessageBox::Default,
2032 QMessageBox::Cancel | QMessageBox::Escape,
2033 QMessageBox::NoButton);
2034 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2035 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2038 case QMessageBox::Yes:
2041 case QMessageBox::Cancel:
2048 // New file, add extension to filename, if missing
2049 // This is always .vym or .vyp, depending on savemode
2050 if (savemode==CompleteMap)
2052 if (!fn.contains (".vym") && !fn.contains (".xml"))
2056 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2065 currentMapEditor()->setFilePath(fn);
2066 fileSave(currentMapEditor(), savemode);
2069 if (savemode==CompleteMap)
2070 tabWidget->setTabLabel (currentMapEditor(),
2071 currentMapEditor()->getFileName() );
2077 void Main::fileSaveAs()
2079 fileSaveAs (CompleteMap);
2082 void Main::fileImportKDE3Bookmarks()
2084 ImportKDE3Bookmarks im;
2086 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2087 currentMapEditor()->setFilePath ("");
2090 void Main::fileImportKDE4Bookmarks()
2092 ImportKDE4Bookmarks im;
2094 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2095 currentMapEditor()->setFilePath ("");
2098 void Main::fileImportFirefoxBookmarks()
2100 Q3FileDialog *fd=new Q3FileDialog( this);
2101 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2102 fd->setMode (Q3FileDialog::ExistingFiles);
2103 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2104 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2107 if ( fd->exec() == QDialog::Accepted )
2109 ImportFirefoxBookmarks im;
2110 QStringList flist = fd->selectedFiles();
2111 QStringList::Iterator it = flist.begin();
2112 while( it != flist.end() )
2115 if (im.transform() &&
2116 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2117 currentMapEditor() )
2118 currentMapEditor()->setFilePath ("");
2125 void Main::fileImportFreemind()
2127 QStringList filters;
2128 filters <<"Freemind map (*.mm)"<<"All files (*)";
2129 QFileDialog *fd=new QFileDialog( this);
2130 fd->setDir (lastFileDir);
2131 fd->setFileMode (QFileDialog::ExistingFiles);
2132 fd->setFilters (filters);
2133 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2137 if ( fd->exec() == QDialog::Accepted )
2139 lastFileDir=fd->directory().path();
2140 QStringList flist = fd->selectedFiles();
2141 QStringList::Iterator it = flist.begin();
2142 while( it != flist.end() )
2145 if ( fileLoad (fn,NewMap, FreemindMap) )
2147 currentMapEditor()->setFilePath ("");
2156 void Main::fileImportMM()
2160 Q3FileDialog *fd=new Q3FileDialog( this);
2161 fd->setDir (lastFileDir);
2162 fd->setMode (Q3FileDialog::ExistingFiles);
2163 fd->addFilter ("Mind Manager (*.mmap)");
2164 fd->setCaption(tr("Import")+" "+"Mind Manager");
2167 if ( fd->exec() == QDialog::Accepted )
2169 lastFileDir=fd->dirPath();
2170 QStringList flist = fd->selectedFiles();
2171 QStringList::Iterator it = flist.begin();
2172 while( it != flist.end() )
2175 if (im.transform() &&
2176 success==fileLoad (im.getTransformedFile(),NewMap) &&
2177 currentMapEditor() )
2178 currentMapEditor()->setFilePath ("");
2187 void Main::fileImportDir()
2189 if (currentMapEditor())
2190 currentMapEditor()->importDir();
2193 void Main::fileExportXML()
2195 MapEditor *me=currentMapEditor();
2196 if (me) me->exportXML();
2200 void Main::fileExportXHTML()
2202 MapEditor *me=currentMapEditor();
2203 if (me) me->exportXHTML();
2206 void Main::fileExportImage()
2208 MapEditor *me=currentMapEditor();
2209 if (me) me->exportImage();
2212 void Main::fileExportASCII()
2214 MapEditor *me=currentMapEditor();
2215 if (me) me->exportASCII();
2218 void Main::fileExportCSV() //FIXME not scriptable yet
2220 MapEditor *me=currentMapEditor();
2224 ex.setModel (me->getModel());
2225 ex.addFilter ("CSV (*.csv)");
2226 ex.setDir(lastImageDir);
2227 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2228 if (ex.execDialog() )
2230 me->setExportMode(true);
2232 me->setExportMode(false);
2237 void Main::fileExportLaTeX() //FIXME not scriptable yet
2239 MapEditor *me=currentMapEditor();
2243 ex.setModel (me->getModel());
2244 ex.addFilter ("Tex (*.tex)");
2245 ex.setDir(lastImageDir);
2246 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2247 if (ex.execDialog() )
2249 me->setExportMode(true);
2251 me->setExportMode(false);
2256 void Main::fileExportKDE3Bookmarks() //FIXME not scriptable yet
2258 ExportKDE3Bookmarks ex;
2259 MapEditor *me=currentMapEditor();
2262 ex.setModel (me->getModel());
2267 void Main::fileExportKDE4Bookmarks() //FIXME not scriptable yet
2269 ExportKDE4Bookmarks ex;
2270 MapEditor *me=currentMapEditor();
2273 ex.setModel (me->getModel());
2278 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2280 ExportTaskjuggler ex;
2281 MapEditor *me=currentMapEditor();
2284 ex.setModel (me->getModel());
2285 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2286 ex.setDir(lastImageDir);
2287 ex.addFilter ("Taskjuggler (*.tjp)");
2288 if (ex.execDialog() )
2290 me->setExportMode(true);
2292 me->setExportMode(false);
2297 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2299 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2300 // TODO add preview in dialog
2301 //ImagePreview *p =new ImagePreview (fd);
2302 //fd->setContentsPreviewEnabled( TRUE );
2303 //fd->setContentsPreview( p, p );
2304 //fd->setPreviewMode( QFileDialog::Contents );
2305 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2306 fd->setDir (QDir().current());
2307 if (fd->foundConfig())
2311 if ( fd->exec() == QDialog::Accepted )
2313 QString fn=fd->selectedFile();
2314 if (!fn.contains (".odp"))
2317 //lastImageDir=fn.left(fn.findRev ("/"));
2318 if (currentMapEditor())
2319 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2323 QMessageBox::warning(0,
2325 tr("Couldn't find configuration for export to Open Office\n"));
2329 void Main::fileCloseMap()
2331 MapEditor *me = currentMapEditor();
2334 if (me->hasChanged())
2336 QMessageBox mb( vymName,
2337 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
2338 QMessageBox::Warning,
2339 QMessageBox::Yes | QMessageBox::Default,
2341 QMessageBox::Cancel | QMessageBox::Escape );
2342 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2343 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2346 case QMessageBox::Yes:
2348 fileSave(me, CompleteMap);
2350 case QMessageBox::No:
2351 // close without saving
2353 case QMessageBox::Cancel:
2359 tabWidget->removePage(me);
2360 if (tabWidget->count()==0)
2361 actionFilePrint->setEnabled (false);
2364 // Better would be delete (me), but then we have a Qt error:
2365 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2366 // So we only remove data now and call deconstructor when vym closes later
2371 void Main::filePrint()
2373 if (currentMapEditor())
2374 currentMapEditor()->print();
2377 void Main::fileExitVYM()
2379 // Check if one or more editors have changed
2382 for (i=0;i<=tabWidget->count() -1;i++)
2385 me=(MapEditor*)tabWidget->page(i);
2387 // If something changed, ask what to do
2388 if (me->hasChanged())
2390 tabWidget->setCurrentPage(i);
2391 QMessageBox mb( vymName,
2392 tr("This map is not saved yet. Do you want to"),
2393 QMessageBox::Warning,
2394 QMessageBox::Yes | QMessageBox::Default,
2396 QMessageBox::Cancel | QMessageBox::Escape );
2397 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2398 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2401 mb.setActiveWindow();
2402 switch( mb.exec() ) {
2403 case QMessageBox::Yes:
2404 // save (the changed editors) and exit
2405 fileSave(currentMapEditor(), CompleteMap);
2407 case QMessageBox::No:
2408 // exit without saving
2410 case QMessageBox::Cancel:
2411 // don't save and don't exit
2415 me->clear(); // remove and unselect now, before mainWindow has gone...
2416 } // loop over all MEs
2420 void Main::editUndo()
2422 if (currentMapEditor())
2423 currentMapEditor()->undo();
2426 void Main::editRedo()
2428 if (currentMapEditor())
2429 currentMapEditor()->redo();
2432 void Main::gotoHistoryStep (int i)
2434 if (currentMapEditor())
2435 currentMapEditor()->gotoHistoryStep (i);
2438 void Main::editCopy()
2440 if (currentMapEditor())
2441 currentMapEditor()->copy();
2444 void Main::editPaste()
2446 if (currentMapEditor())
2447 currentMapEditor()->paste();
2450 void Main::editCut()
2452 if (currentMapEditor())
2453 currentMapEditor()->cut();
2456 void Main::editOpenFindWindow()
2458 findWindow->popup();
2459 findWindow->raise();
2460 findWindow->setActiveWindow();
2463 void Main::editFind(QString s)
2466 BranchObj *bo=currentMapEditor()->findText(s, cs);
2469 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2472 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2473 tr("No matches found for \"%1\"").arg(s));
2477 void Main::editFindChanged()
2478 { // Notify editor, to abort the current find process
2479 currentMapEditor()->findReset();
2482 void Main::openTabs(QStringList urls)
2484 if (!urls.isEmpty())
2488 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2490 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2492 QString u=urls.takeFirst();
2493 procBrowser = new QProcess( this );
2495 procBrowser->start(browser,args);
2496 if ( !procBrowser->waitForStarted())
2498 // try to set path to browser
2499 QMessageBox::warning(0,
2501 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2502 tr("Please use Settings->")+tr("Set application to open an URL"));
2505 #if defined(Q_OS_WIN32)
2506 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2507 this->thread()->wait(3000);
2512 if (browser.contains("konqueror"))
2514 cout << "Main::openTabs urls="<<urls.join(" ").toStdString()<<endl;
2515 for (int i=0; i<urls.size(); i++)
2518 // Try to open new tab in existing konqueror started previously by vym
2519 p=new QProcess (this);
2521 #if defined(Q_OS_WIN32)
2522 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2523 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2524 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2525 "konqueror-mainwindow#1"<<
2529 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2530 "konqueror-mainwindow#1"<<
2533 // qdbus org.kde.konqueror-15367 /konqueror/MainWindow_1 newTab www.suse.de false
2535 p->start ("dcop",args);
2537 cout << "MainWindo::openURLs i="<<i <<"/"<<urls.size()-1
2538 <<" args="<<args.join(" ").toStdString()<<endl;
2540 if ( !p->waitForStarted() ) success=false;
2543 QMessageBox::warning(0,
2545 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2547 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2549 for (int i=0; i<urls.size(); i++)
2551 // Try to open new tab in firefox
2552 p=new QProcess (this);
2553 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2554 p->start (browser,args);
2555 if ( !p->waitForStarted() ) success=false;
2558 QMessageBox::warning(0,
2560 tr("Couldn't start %1 to open a new tab").arg(browser));
2563 QMessageBox::warning(0,
2565 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2569 void Main::editOpenURL()
2572 if (currentMapEditor())
2574 QString url=currentMapEditor()->getURL();
2576 if (url=="") return;
2577 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2578 procBrowser = new QProcess( this );
2580 procBrowser->start(browser,args);
2581 if ( !procBrowser->waitForStarted())
2583 // try to set path to browser
2584 QMessageBox::warning(0,
2586 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2587 tr("Please use Settings->")+tr("Set application to open an URL"));
2592 void Main::editOpenURLTab()
2594 if (currentMapEditor())
2597 urls.append(currentMapEditor()->getURL());
2601 void Main::editOpenMultipleURLTabs()
2603 if (currentMapEditor())
2606 urls=currentMapEditor()->getURLs();
2613 void Main::editURL()
2615 if (currentMapEditor())
2616 currentMapEditor()->editURL();
2619 void Main::editLocalURL()
2621 if (currentMapEditor())
2622 currentMapEditor()->editLocalURL();
2625 void Main::editHeading2URL()
2627 if (currentMapEditor())
2628 currentMapEditor()->editHeading2URL();
2631 void Main::editBugzilla2URL()
2633 if (currentMapEditor())
2634 currentMapEditor()->editBugzilla2URL();
2637 void Main::editFATE2URL()
2639 if (currentMapEditor())
2640 currentMapEditor()->editFATE2URL();
2643 void Main::editHeadingFinished()
2645 // only called from editHeading(), so there is a currentME
2646 MapEditor *me=currentMapEditor();
2649 me->setStateEditHeading (false);
2650 QPoint p; //Not used here, only to find out pos of branch
2652 QString s=me->getHeading(ok,p);
2654 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2656 if (ok && s!=lineedit->text())
2657 me->setHeading(lineedit->text());
2659 lineedit->releaseKeyboard();
2663 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2664 !prevSelection.isEmpty())
2665 me->select(prevSelection);
2670 void Main::editHeading()
2672 if (currentMapEditor())
2674 MapEditor *me=currentMapEditor();
2675 QString oldSel=me->getSelectString();
2677 if (lineedit->isVisible())
2678 editHeadingFinished();
2683 QString s=me->getHeading(ok,p);
2687 me->setStateEditHeading (true);
2688 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2689 p=me->mapToGlobal (p);
2690 QDialog *d =new QDialog(NULL);
2691 QLineEdit *le=new QLineEdit (d);
2692 d->setWindowFlags (Qt::FramelessWindowHint);
2693 d->setGeometry(p.x(),p.y(),230,25);
2694 le->resize (d->width()-10,d->height());
2697 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2698 d->activateWindow();
2700 me->setHeading (le->text());
2703 editHeadingFinished();
2705 p=me->mapTo (this,p);
2706 lineedit->setGeometry(p.x(),p.y(),230,25);
2707 lineedit->setText(s);
2708 lineedit->setCursorPosition(1);
2709 lineedit->selectAll();
2711 lineedit->grabKeyboard();
2712 lineedit->setFocus();
2716 } // currentMapEditor()
2719 void Main::editAttributeFinished()
2721 // only called from editHeading(), so there is a currentME
2724 MapEditor *me=currentMapEditor();
2727 me->setStateEditHeading (false);
2728 QPoint p; //Not used here, only to find out pos of branch
2730 QString s=me->getHeading(ok,p);
2732 #if defined(Q_OS_MACX)
2734 if (ok && s!=lineedit->text())
2735 me->setHeading(lineedit->text());
2737 lineedit->releaseKeyboard();
2741 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2742 !prevSelection.isEmpty())
2743 me->select(prevSelection);
2749 #include "attribute.h"
2750 #include "attributedialog.h"
2751 void Main::editAttribute()
2753 MapEditor *me=currentMapEditor();
2756 BranchObj *bo=me->getSelectedBranch();
2759 AttributeDialog dia(this);
2760 dia.setTable (me->attributeTable() );
2762 dia.setMode (Definition);
2768 if (currentMapEditor())
2770 MapEditor *me=currentMapEditor();
2771 QString oldSel=me->getSelectString();
2773 if (lineedit->isVisible())
2774 editAttributeFinished();
2779 QString s=me->getHeading(ok,p);
2783 me->setStateEditHeading (true);
2784 #if defined(Q_OS_MACX)
2785 p=me->mapToGlobal (p);
2786 QDialog *d =new QDialog(NULL);
2787 QLineEdit *le=new QLineEdit (d);
2788 d->setWindowFlags (Qt::FramelessWindowHint);
2789 d->setGeometry(p.x(),p.y(),230,25);
2790 le->resize (d->width()-10,d->height());
2793 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2794 d->activateWindow();
2796 me->setHeading (le->text());
2799 editHeadingFinished();
2801 p=me->mapTo (this,p);
2802 lineedit->setGeometry(p.x(),p.y(),230,25);
2803 lineedit->setText(s);
2804 lineedit->setCursorPosition(1);
2805 lineedit->selectAll();
2807 lineedit->grabKeyboard();
2808 lineedit->setFocus();
2812 } // currentMapEditor()
2817 void Main::openVymLinks(const QStringList &vl)
2819 for (int j=0; j<vl.size(); j++)
2821 // compare path with already loaded maps
2825 for (i=0;i<=tabWidget->count() -1;i++)
2827 me=(MapEditor*)tabWidget->page(i);
2828 if (vl.at(j)==me->getFilePath() )
2837 if (!QFile(vl.at(j)).exists() )
2838 QMessageBox::critical( 0, tr( "Critical Error" ),
2839 tr("Couldn't open map %1").arg(vl.at(j)));
2842 fileLoad (vl.at(j), NewMap);
2843 tabWidget->setCurrentPage (tabWidget->count()-1);
2846 // Go to tab containing the map
2847 tabWidget->setCurrentPage (index);
2851 void Main::editOpenVymLink()
2853 if (currentMapEditor())
2856 vl.append(currentMapEditor()->getVymLink());
2861 void Main::editOpenMultipleVymLinks()
2863 QString currentVymLink;
2864 if (currentMapEditor())
2866 QStringList vl=currentMapEditor()->getVymLinks();
2871 void Main::editVymLink()
2873 if (currentMapEditor())
2874 currentMapEditor()->editVymLink();
2877 void Main::editDeleteVymLink()
2879 if (currentMapEditor())
2880 currentMapEditor()->deleteVymLink();
2883 void Main::editToggleHideExport()
2885 if (currentMapEditor())
2886 currentMapEditor()->toggleHideExport();
2889 void Main::editMapInfo()
2891 if (currentMapEditor())
2892 currentMapEditor()->editMapInfo();
2895 void Main::editMoveUp()
2897 if (currentMapEditor())
2898 currentMapEditor()->moveBranchUp();
2901 void Main::editMoveDown()
2903 if (currentMapEditor())
2904 currentMapEditor()->moveBranchDown();
2907 void Main::editSortChildren()
2909 if (currentMapEditor())
2910 currentMapEditor()->sortChildren();
2913 void Main::editToggleScroll()
2915 if (currentMapEditor())
2917 currentMapEditor()->toggleScroll();
2921 void Main::editUnscrollChilds()
2923 if (currentMapEditor())
2924 currentMapEditor()->unscrollChilds();
2927 void Main::editAddMapCenter()
2929 MapEditor *me=currentMapEditor();
2930 if (!lineedit->isVisible() && me)
2932 me->addMapCenter ();
2936 void Main::editNewBranch()
2938 MapEditor *me=currentMapEditor();
2939 if (!lineedit->isVisible() && me)
2941 BranchObj *bo=(BranchObj*)me->getSelection();
2942 BranchObj *newbo=me->addNewBranch(0);
2944 prevSelection=me->getModel()->getSelectString(bo);
2950 if (actionSettingsAutoEditNewBranch->isOn())
2955 if (!prevSelection.isEmpty())
2957 me->select(prevSelection);
2964 void Main::editNewBranchBefore()
2966 MapEditor *me=currentMapEditor();
2967 if (!lineedit->isVisible() && me)
2969 BranchObj *bo=(BranchObj*)me->getSelection();
2970 BranchObj *newbo=me->addNewBranchBefore();
2977 if (actionSettingsAutoEditNewBranch->isOn())
2979 if (!actionSettingsAutoSelectNewBranch->isOn())
2980 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2986 void Main::editNewBranchAbove()
2988 MapEditor *me=currentMapEditor();
2989 if (!lineedit->isVisible() && me)
2991 BranchObj *bo=(BranchObj*)me->getSelection();
2992 BranchObj *newbo=me->addNewBranch (-1);
2999 if (actionSettingsAutoEditNewBranch->isOn())
3001 if (!actionSettingsAutoSelectNewBranch->isOn())
3002 prevSelection=me->getModel()->getSelectString (bo); // TODO access directly
3008 void Main::editNewBranchBelow()
3010 MapEditor *me=currentMapEditor();
3011 if (!lineedit->isVisible() && me)
3013 BranchObj *bo=(BranchObj*)me->getSelection();
3014 BranchObj *newbo=me->addNewBranch (1);
3021 if (actionSettingsAutoEditNewBranch->isOn())
3023 if (!actionSettingsAutoSelectNewBranch->isOn())
3024 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
3030 void Main::editImportAdd()
3032 fileLoad (ImportAdd);
3035 void Main::editImportReplace()
3037 fileLoad (ImportReplace);
3040 void Main::editSaveBranch()
3042 fileSaveAs (PartOfMap);
3045 void Main::editDeleteKeepChilds()
3047 if (currentMapEditor())
3048 currentMapEditor()->deleteKeepChilds();
3051 void Main::editDeleteChilds()
3053 if (currentMapEditor())
3054 currentMapEditor()->deleteChilds();
3057 void Main::editDeleteSelection()
3059 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3060 currentMapEditor()->deleteSelection();
3063 void Main::editUpperBranch()
3065 if (currentMapEditor())
3066 currentMapEditor()->selectUpperBranch();
3069 void Main::editLowerBranch()
3071 if (currentMapEditor())
3072 currentMapEditor()->selectLowerBranch();
3075 void Main::editLeftBranch()
3077 if (currentMapEditor())
3078 currentMapEditor()->selectLeftBranch();
3081 void Main::editRightBranch()
3083 if (currentMapEditor())
3084 currentMapEditor()->selectRightBranch();
3087 void Main::editFirstBranch()
3089 if (currentMapEditor())
3090 currentMapEditor()->selectFirstBranch();
3093 void Main::editLastBranch()
3095 if (currentMapEditor())
3096 currentMapEditor()->selectLastBranch();
3099 void Main::editLoadImage()
3101 if (currentMapEditor())
3102 currentMapEditor()->loadFloatImage();
3105 void Main::editSaveImage()
3107 if (currentMapEditor())
3108 currentMapEditor()->saveFloatImage();
3111 void Main::editFollowXLink(QAction *a)
3114 if (currentMapEditor())
3115 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3118 void Main::editEditXLink(QAction *a)
3120 if (currentMapEditor())
3121 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3124 void Main::formatSelectColor()
3126 if (currentMapEditor())
3128 QColor col = QColorDialog::getColor((currentColor ), this );
3129 if ( !col.isValid() ) return;
3130 colorChanged( col );
3134 void Main::formatPickColor()
3136 if (currentMapEditor())
3137 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3140 void Main::colorChanged(QColor c)
3142 QPixmap pix( 16, 16 );
3144 actionFormatColor->setIconSet( pix );
3148 void Main::formatColorBranch()
3150 if (currentMapEditor())
3151 currentMapEditor()->colorBranch(currentColor);
3154 void Main::formatColorSubtree()
3156 if (currentMapEditor())
3157 currentMapEditor()->colorSubtree (currentColor);
3160 void Main::formatLinkStyleLine()
3162 if (currentMapEditor())
3164 currentMapEditor()->setMapLinkStyle("StyleLine");
3165 actionFormatLinkStyleLine->setOn(true);
3169 void Main::formatLinkStyleParabel()
3171 if (currentMapEditor())
3173 currentMapEditor()->setMapLinkStyle("StyleParabel");
3174 actionFormatLinkStyleParabel->setOn(true);
3178 void Main::formatLinkStylePolyLine()
3180 if (currentMapEditor())
3182 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3183 actionFormatLinkStylePolyLine->setOn(true);
3187 void Main::formatLinkStylePolyParabel()
3189 if (currentMapEditor())
3191 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3192 actionFormatLinkStylePolyParabel->setOn(true);
3196 void Main::formatSelectBackColor()
3198 if (currentMapEditor())
3199 currentMapEditor()->selectMapBackgroundColor();
3202 void Main::formatSelectBackImage()
3204 if (currentMapEditor())
3205 currentMapEditor()->selectMapBackgroundImage();
3208 void Main::formatSelectLinkColor()
3210 if (currentMapEditor())
3211 currentMapEditor()->selectMapLinkColor();
3214 void Main::formatSelectSelectionColor()
3216 if (currentMapEditor())
3217 currentMapEditor()->selectMapSelectionColor();
3220 void Main::formatToggleLinkColorHint()
3222 currentMapEditor()->toggleMapLinkColorHint();
3226 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3228 if (currentMapEditor())
3229 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3232 void Main::viewZoomReset()
3234 if (currentMapEditor())
3238 currentMapEditor()->setMatrix( m );
3242 void Main::viewZoomIn()
3244 if (currentMapEditor())
3246 QMatrix m = currentMapEditor()->matrix();
3247 m.scale( 1.25, 1.25 );
3248 currentMapEditor()->setMatrix( m );
3252 void Main::viewZoomOut()
3254 if (currentMapEditor())
3256 QMatrix m = currentMapEditor()->matrix();
3257 m.scale( 0.8, 0.8 );
3258 currentMapEditor()->setMatrix( m );
3262 void Main::viewCenter()
3264 MapEditor *me=currentMapEditor();
3267 me->ensureSelectionVisible();
3271 void Main::networkStartServer()
3273 MapEditor *me=currentMapEditor();
3274 if (me) me->newServer();
3277 void Main::networkConnect()
3279 MapEditor *me=currentMapEditor();
3280 if (me) me->connectToServer();
3283 bool Main::settingsPDF()
3285 // Default browser is set in constructor
3287 QString text = QInputDialog::getText(
3288 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3289 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3291 settings.setValue ("/mainwindow/readerPDF",text);
3296 bool Main::settingsURL()
3298 // Default browser is set in constructor
3300 QString text = QInputDialog::getText(
3301 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3302 settings.value("/mainwindow/readerURL").toString()
3305 settings.setValue ("/mainwindow/readerURL",text);
3309 void Main::settingsMacroDir()
3311 QDir defdir(vymBaseDir.path() + "/macros");
3312 if (!defdir.exists())
3314 QDir dir=QFileDialog::getExistingDirectory (
3316 tr ("Directory with vym macros:"),
3317 settings.value ("/macros/macroDir",defdir.path()).toString()
3320 settings.setValue ("/macros/macroDir",dir.absolutePath());
3323 void Main::settingsUndoLevels()
3326 int i = QInputDialog::getInteger(
3328 tr("QInputDialog::getInteger()"),
3329 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3332 settings.setValue ("/mapeditor/stepsTotal",i);
3333 QMessageBox::information( this, tr( "VYM -Information:" ),
3334 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3338 void Main::settingsAutosaveToggle()
3340 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3343 void Main::settingsAutosaveTime()
3346 int i = QInputDialog::getInteger(
3348 tr("QInputDialog::getInteger()"),
3349 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3351 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3354 void Main::settingsWriteBackupFileToggle()
3356 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3359 void Main::settingsToggleAnimation()
3361 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3364 void Main::settingsToggleDelKey()
3366 if (actionSettingsUseDelKey->isOn())
3368 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3371 actionEditDelete->setAccel (QKeySequence (""));
3375 void Main::windowToggleNoteEditor()
3377 if (textEditor->isVisible() )
3378 windowHideNoteEditor();
3380 windowShowNoteEditor();
3383 void Main::windowToggleHistory()
3385 if (historyWindow->isVisible())
3386 historyWindow->hide();
3388 historyWindow->show();
3392 void Main::windowToggleProperty()
3394 if (branchPropertyWindow->isVisible())
3395 branchPropertyWindow->hide();
3397 branchPropertyWindow->show();
3399 if(currentMapEditor())
3401 BranchObj *bo=currentMapEditor()->getSelectedBranch();
3404 branchPropertyWindow->setMapEditor(currentMapEditor());
3405 branchPropertyWindow->setBranch(bo);
3410 branchPropertyWindow->setBranch(NULL);
3413 void Main::windowToggleAntiAlias()
3415 bool b=actionViewToggleAntiAlias->isOn();
3417 for (int i=0;i<tabWidget->count();i++)
3420 me=(MapEditor*)tabWidget->page(i);
3421 me->setAntiAlias(b);
3426 void Main::windowToggleSmoothPixmap()
3428 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3430 for (int i=0;i<tabWidget->count();i++)
3433 me=(MapEditor*)tabWidget->page(i);
3434 me->setSmoothPixmap(b);
3438 void Main::updateHistory(SimpleSettings &undoSet)
3440 historyWindow->update (undoSet);
3443 void Main::updateNoteFlag()
3445 if (currentMapEditor())
3446 currentMapEditor()->updateNoteFlag();
3449 void Main::updateSatellites(MapEditor *me)
3451 branchPropertyWindow->setMapEditor (me);
3454 void Main::updateActions()
3456 MapEditor *me=currentMapEditor();
3459 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3461 // updateActions is also called when NoteEditor is closed
3462 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3463 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3464 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3466 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3467 actionFormatLinkColorHint->setOn(true);
3469 actionFormatLinkColorHint->setOn(false);
3471 switch (me->getMapLinkStyle())
3473 case LinkableMapObj::Line:
3474 actionFormatLinkStyleLine->setOn(true);
3476 case LinkableMapObj::Parabel:
3477 actionFormatLinkStyleParabel->setOn(true);
3479 case LinkableMapObj::PolyLine:
3480 actionFormatLinkStylePolyLine->setOn(true);
3482 case LinkableMapObj::PolyParabel:
3483 actionFormatLinkStylePolyParabel->setOn(true);
3490 QPixmap pix( 16, 16 );
3491 pix.fill( me->getMapBackgroundColor() );
3492 actionFormatBackColor->setIconSet( pix );
3493 pix.fill( me->getSelectionColor() );
3494 actionFormatSelectionColor->setIconSet( pix );
3495 pix.fill( me->getMapDefLinkColor() );
3496 actionFormatLinkColor->setIconSet( pix );
3499 actionFileSave->setEnabled( me->hasChanged() );
3500 if (me->isUndoAvailable())
3501 actionEditUndo->setEnabled( true);
3503 actionEditUndo->setEnabled( false);
3505 if (me->isRedoAvailable())
3506 actionEditRedo->setEnabled( true);
3508 actionEditRedo->setEnabled( false);
3510 LinkableMapObj *selection=me->getSelection();
3513 if ( (typeid(*selection) == typeid(BranchObj)) ||
3514 (typeid(*selection) == typeid(MapCenterObj)) )
3516 BranchObj *bo=(BranchObj*)selection;
3517 // Take care of links
3518 if (bo->countXLinks()==0)
3520 branchXLinksContextMenuEdit->clear();
3521 branchXLinksContextMenuFollow->clear();
3526 branchXLinksContextMenuEdit->clear();
3527 branchXLinksContextMenuFollow->clear();
3528 for (int i=0; i<=bo->countXLinks();i++)
3530 bot=bo->XLinkTargetAt(i);
3533 s=bot->getHeading();
3534 if (s.length()>xLinkMenuWidth)
3535 s=s.left(xLinkMenuWidth)+"...";
3536 branchXLinksContextMenuFollow->addAction (s);
3537 branchXLinksContextMenuEdit->addAction (s);
3542 standardFlagsDefault->setEnabled (true);
3544 actionEditToggleScroll->setEnabled (true);
3545 if ( bo->isScrolled() )
3546 actionEditToggleScroll->setOn(true);
3548 actionEditToggleScroll->setOn(false);
3550 if ( bo->getURL().isEmpty() )
3552 actionEditOpenURL->setEnabled (false);
3553 actionEditOpenURLTab->setEnabled (false);
3557 actionEditOpenURL->setEnabled (true);
3558 actionEditOpenURLTab->setEnabled (true);
3560 if ( bo->getVymLink().isEmpty() )
3562 actionEditOpenVymLink->setEnabled (false);
3563 actionEditDeleteVymLink->setEnabled (false);
3566 actionEditOpenVymLink->setEnabled (true);
3567 actionEditDeleteVymLink->setEnabled (true);
3570 if (bo->canMoveBranchUp())
3571 actionEditMoveUp->setEnabled (true);
3573 actionEditMoveUp->setEnabled (false);
3574 if (bo->canMoveBranchDown())
3575 actionEditMoveDown->setEnabled (true);
3577 actionEditMoveDown->setEnabled (false);
3580 actionEditToggleHideExport->setEnabled (true);
3581 actionEditToggleHideExport->setOn (bo->hideInExport() );
3583 actionEditCopy->setEnabled (true);
3584 actionEditCut->setEnabled (true);
3585 if (!clipboardEmpty)
3586 actionEditPaste->setEnabled (true);
3588 actionEditPaste->setEnabled (false);
3589 for (int i=0; i<actionListBranches.size(); ++i)
3590 actionListBranches.at(i)->setEnabled(true);
3591 actionEditDelete->setEnabled (true);
3592 actionFormatHideLinkUnselected->setOn
3593 (selection->getHideLinkUnselected());
3595 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3597 FloatObj *fo=(FloatImageObj*)selection;
3599 actionEditOpenURL->setEnabled (false);
3600 actionEditOpenVymLink->setEnabled (false);
3601 actionEditDeleteVymLink->setEnabled (false);
3602 actionEditToggleHideExport->setEnabled (true);
3603 actionEditToggleHideExport->setOn (fo->hideInExport() );
3606 actionEditCopy->setEnabled (true);
3607 actionEditCut->setEnabled (true);
3608 actionEditPaste->setEnabled (false);
3609 for (int i=0; i<actionListBranches.size(); ++i)
3610 actionListBranches.at(i)->setEnabled(false);
3611 actionEditDelete->setEnabled (true);
3612 actionFormatHideLinkUnselected->setOn
3613 ( selection->getHideLinkUnselected());
3614 actionEditMoveUp->setEnabled (false);
3615 actionEditMoveDown->setEnabled (false);
3620 actionEditCopy->setEnabled (false);
3621 actionEditCut->setEnabled (false);
3622 actionEditPaste->setEnabled (false);
3623 for (int i=0; i<actionListBranches.size(); ++i)
3624 actionListBranches.at(i)->setEnabled(false);
3626 actionEditToggleScroll->setEnabled (false);
3627 actionEditOpenURL->setEnabled (false);
3628 actionEditOpenVymLink->setEnabled (false);
3629 actionEditDeleteVymLink->setEnabled (false);
3630 actionEditHeading2URL->setEnabled (false);
3631 actionEditDelete->setEnabled (false);
3632 actionEditMoveUp->setEnabled (false);
3633 actionEditMoveDown->setEnabled (false);
3634 actionEditToggleHideExport->setEnabled (false);
3638 Main::ModMode Main::getModMode()
3640 if (actionModModeColor->isOn()) return ModModeColor;
3641 if (actionModModeCopy->isOn()) return ModModeCopy;
3642 if (actionModModeXLink->isOn()) return ModModeXLink;
3646 bool Main::autoEditNewBranch()
3648 return actionSettingsAutoEditNewBranch->isOn();
3651 bool Main::autoSelectNewBranch()
3653 return actionSettingsAutoSelectNewBranch->isOn();
3656 bool Main::useFlagGroups()
3658 return actionSettingsUseFlagGroups->isOn();
3661 void Main::windowShowNoteEditor()
3663 textEditor->setShowWithMain(true);
3665 actionViewToggleNoteEditor->setOn (true);
3668 void Main::windowHideNoteEditor()
3670 textEditor->setShowWithMain(false);
3672 actionViewToggleNoteEditor->setOn (false);
3675 void Main::setScript (const QString &script)
3677 scriptEditor->setScript (script);
3680 void Main::runScript (const QString &script)
3682 if (currentMapEditor())
3683 currentMapEditor()->runScript (script);
3686 void Main::runScriptEverywhere (const QString &script)
3689 for (int i=0;i<=tabWidget->count() -1;i++)
3691 me=(MapEditor*)tabWidget->page(i);
3692 if (me) me->runScript (script);
3696 void Main::windowNextEditor()
3698 if (tabWidget->currentPageIndex() < tabWidget->count())
3699 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3702 void Main::windowPreviousEditor()
3704 if (tabWidget->currentPageIndex() >0)
3705 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3708 void Main::standardFlagChanged()
3710 if (currentMapEditor())
3711 currentMapEditor()->toggleStandardFlag(sender()->name());
3714 void Main::testFunction1()
3716 if (!currentMapEditor()) return;
3717 currentMapEditor()->testFunction1();
3721 void Main::testFunction2()
3723 if (!currentMapEditor()) return;
3724 currentMapEditor()->testFunction2();
3727 void Main::testCommand()
3729 if (!currentMapEditor()) return;
3730 scriptEditor->show();
3733 QString com = QInputDialog::getText(
3734 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3735 if (ok) currentMapEditor()->parseAtom(com);
3739 void Main::helpDoc()
3741 QString locale = QLocale::system().name();
3743 if (locale.left(2)=="es")
3744 docname="vym_es.pdf";
3748 QStringList searchList;
3750 #if defined(Q_OS_MACX)
3751 searchList << "./vym.app/Contents/Resources/doc";
3752 #elif defined(Q_OS_WIN32)
3753 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3755 #if defined(VYM_DOCDIR)
3756 searchList << VYM_DOCDIR;
3758 // default path in SUSE LINUX
3759 searchList << "/usr/share/doc/packages/vym";
3762 searchList << "doc"; // relative path for easy testing in tarball
3763 searchList << "doc/tex"; // Easy testing working on vym.tex
3764 searchList << "/usr/share/doc/vym"; // Debian
3765 searchList << "/usr/share/doc/packages";// Knoppix
3769 for (int i=0; i<searchList.count(); ++i)
3771 docfile.setFileName(searchList.at(i)+"/"+docname);
3772 if (docfile.exists())
3781 QMessageBox::critical(0,
3782 tr("Critcal error"),
3783 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3788 Process *pdfProc = new Process();
3789 args << QDir::toNativeSeparators(docfile.fileName());
3791 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3792 if ( !pdfProc->waitForStarted() )
3795 QMessageBox::warning(0,
3797 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3798 tr("Please use Settings->")+tr("Set application to open PDF files"));
3805 void Main::helpDemo()
3807 QStringList filters;
3808 filters <<"VYM example map (*.vym)";
3809 QFileDialog *fd=new QFileDialog( this);
3810 #if defined(Q_OS_MACX)
3811 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3813 // default path in SUSE LINUX
3814 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3817 fd->setFileMode (QFileDialog::ExistingFiles);
3818 fd->setFilters (filters);
3819 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3823 if ( fd->exec() == QDialog::Accepted )
3825 lastFileDir=fd->directory().path();
3826 QStringList flist = fd->selectedFiles();
3827 QStringList::Iterator it = flist.begin();
3828 while( it != flist.end() )
3831 fileLoad(*it, NewMap);
3839 void Main::helpAbout()
3842 ad.setName ("aboutwindow");
3843 ad.setMinimumSize(500,500);
3844 ad.resize (QSize (500,500));
3848 void Main::helpAboutQT()
3850 QMessageBox::aboutQt( this, "Qt Application Example" );
3853 void Main::callMacro ()
3855 QAction *action = qobject_cast<QAction *>(sender());
3859 i=action->data().toInt();
3860 QString mDir (settings.value ("macros/macroDir").toString() );
3862 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3864 if ( !f.open( QIODevice::ReadOnly ) )
3866 QMessageBox::warning(0,
3868 tr("Couldn't find a macro at %1.\n").arg(fn)+
3869 tr("Please use Settings->")+tr("Set directory for vym macros"));
3873 QTextStream ts( &f );
3874 QString m= ts.read();
3878 //cout <<"Main::callMacro m="<<qPrintable (m)<<endl;
3879 currentMapEditor()->runScript (m);
3886 //////////////////////////////////
3888 @@ -2544,18 +2576,27 @@
3889 // Try to open new tab in existing konqueror started previously by vym
3890 p=new QProcess (this);
3892 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3893 - "konqueror-mainwindow#1"<<
3895 +#if defined(Q_OS_WIN32)
3896 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3897 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3898 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3899 + "konqueror-mainwindow#1"<<
3903 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3904 + "konqueror-mainwindow#1"<<
3908 p->start ("dcop",args);
3909 if ( !p->waitForStarted() ) success=false;