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 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
741 actionEditBugzilla2URL=a;
743 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
744 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
745 a->setEnabled (false);
746 actionListBranches.append(a);
747 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
748 actionEditFATE2URL=a;
750 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
751 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
753 a->setEnabled (false);
754 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
755 actionEditOpenVymLink=a;
757 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
758 a->setStatusTip ( tr( "Open all vym links in subtree" ));
759 a->setEnabled (false);
760 actionListBranches.append(a);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
762 actionEditOpenMultipleVymLinks=a;
765 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
766 a->setEnabled (false);
767 a->setStatusTip ( tr( "Edit link to another vym map" ));
768 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
769 actionListBranches.append(a);
772 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
773 a->setStatusTip ( tr( "Delete link to another vym map" ));
774 a->setEnabled (false);
775 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
776 actionEditDeleteVymLink=a;
778 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
779 a->setStatusTip ( tr( "Hide object in exports" ) );
780 a->setShortcut (Qt::Key_H );
781 a->setToggleAction(true);
783 a->setEnabled (false);
784 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
785 actionEditToggleHideExport=a;
787 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
788 a->setStatusTip ( tr( "Edit Map Info" ));
789 a->setEnabled (true);
790 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
793 // Import at selection (adding to selection)
794 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
795 a->setStatusTip (tr( "Add map at selection" ));
796 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
797 a->setEnabled (false);
798 actionListBranches.append(a);
799 actionEditImportAdd=a;
801 // Import at selection (replacing selection)
802 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
803 a->setStatusTip (tr( "Replace selection with map" ));
804 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
805 a->setEnabled (false);
806 actionListBranches.append(a);
807 actionEditImportReplace=a;
810 a = new QAction( tr( "Save selection","Edit menu" ), this);
811 a->setStatusTip (tr( "Save selection" ));
812 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
813 a->setEnabled (false);
814 actionListBranches.append(a);
815 actionEditSaveBranch=a;
817 // Only remove branch, not its childs
818 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
819 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
820 a->setShortcut (Qt::ALT + Qt::Key_Delete );
821 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
822 a->setEnabled (false);
824 actionListBranches.append(a);
825 actionEditDeleteKeepChilds=a;
827 // Only remove childs of a branch
828 a = new QAction( tr( "Remove childs","Edit menu" ), this);
829 a->setStatusTip (tr( "Remove childs of branch" ));
830 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
831 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
832 a->setEnabled (false);
833 actionListBranches.append(a);
834 actionEditDeleteChilds=a;
836 // Shortcuts for navigating with cursor:
837 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
838 a->setStatusTip ( tr( "Select upper branch" ));
839 a->setShortcut (Qt::Key_Up );
840 a->setShortcutContext (Qt::WindowShortcut);
842 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
843 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
844 a->setStatusTip (tr( "Select lower branch" ));
845 a->setShortcut ( Qt::Key_Down );
846 a->setShortcutContext (Qt::WindowShortcut);
848 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
849 a = new QAction(tr( "Select left branch","Edit menu" ), this);
850 a->setStatusTip ( tr( "Select left branch" ));
851 a->setShortcut (Qt::Key_Left );
852 a->setShortcutContext (Qt::WindowShortcut);
854 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
855 a = new QAction( tr( "Select child branch","Edit menu" ), this);
856 a->setStatusTip (tr( "Select right branch" ));
857 a->setShortcut (Qt::Key_Right);
858 a->setShortcutContext (Qt::WindowShortcut);
860 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
861 a = new QAction( tr( "Select first branch","Edit menu" ), this);
862 a->setStatusTip (tr( "Select first branch" ));
863 a->setShortcut (Qt::Key_Home );
864 a->setShortcutContext (Qt::WindowShortcut);
866 a->setEnabled (false);
867 editMenu->addAction (a);
868 actionListBranches.append(a);
869 actionEditSelectFirst=a;
870 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
871 a = new QAction( tr( "Select last branch","Edit menu" ),this);
872 a->setStatusTip (tr( "Select last branch" ));
873 a->setShortcut ( Qt::Key_End );
874 a->setShortcutContext (Qt::WindowShortcut);
876 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
877 a->setEnabled (false);
878 editMenu->addAction (a);
879 actionListBranches.append(a);
880 actionEditSelectLast=a;
882 a = new QAction( tr( "Add Image...","Edit menu" ), this);
883 a->setStatusTip (tr( "Add Image" ));
884 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
885 actionEditLoadImage=a;
887 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
888 a->setStatusTip (tr( "Set properties for selection" ));
889 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
890 a->setShortcutContext (Qt::WindowShortcut);
891 a->setToggleAction (true);
893 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
894 actionViewTogglePropertyWindow=a;
898 void Main::setupFormatActions()
900 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
902 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
903 tb->setObjectName ("formatTB");
906 pix.fill (Qt::black);
907 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
908 a->setStatusTip ( tr( "Set Color" ));
909 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
911 formatMenu->addAction (a);
913 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
914 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
915 a->setShortcut (Qt::CTRL + Qt::Key_K );
916 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
917 a->setEnabled (false);
919 formatMenu->addAction (a);
920 actionListBranches.append(a);
921 actionFormatPickColor=a;
923 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
924 a->setStatusTip ( tr( "Color branch" ) );
925 a->setShortcut (Qt::CTRL + Qt::Key_B);
926 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
927 a->setEnabled (false);
929 formatMenu->addAction (a);
930 actionListBranches.append(a);
931 actionFormatColorSubtree=a;
933 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
934 a->setStatusTip ( tr( "Color Subtree" ));
935 a->setShortcut (Qt::CTRL + Qt::Key_T);
936 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
937 a->setEnabled (false);
938 formatMenu->addAction (a);
940 actionListBranches.append(a);
941 actionFormatColorSubtree=a;
943 formatMenu->addSeparator();
944 actionGroupFormatLinkStyles=new QActionGroup ( this);
945 actionGroupFormatLinkStyles->setExclusive (true);
946 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
947 a->setStatusTip (tr( "Line" ));
948 a->setToggleAction(true);
949 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
950 formatMenu->addAction (a);
951 actionFormatLinkStyleLine=a;
952 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
953 a->setStatusTip (tr( "Line" ));
954 a->setToggleAction(true);
955 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
956 formatMenu->addAction (a);
957 actionFormatLinkStyleParabel=a;
958 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
959 a->setStatusTip (tr( "PolyLine" ));
960 a->setToggleAction(true);
961 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
962 formatMenu->addAction (a);
963 actionFormatLinkStylePolyLine=a;
964 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
965 a->setStatusTip (tr( "PolyParabel" ) );
966 a->setToggleAction(true);
967 a->setChecked (true);
968 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
969 formatMenu->addAction (a);
970 actionFormatLinkStylePolyParabel=a;
972 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
973 a->setStatusTip (tr( "Hide link" ));
974 a->setToggleAction(true);
975 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
976 actionFormatHideLinkUnselected=a;
978 formatMenu->addSeparator();
979 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
980 a->setStatusTip (tr( "Use same color for links and headings" ));
981 a->setToggleAction(true);
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
983 formatMenu->addAction (a);
984 actionFormatLinkColorHint=a;
986 pix.fill (Qt::white);
987 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
988 a->setStatusTip (tr( "Set Link Color" ));
989 formatMenu->addAction (a);
990 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
991 actionFormatLinkColor=a;
993 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
994 a->setStatusTip (tr( "Set Selection Color" ));
995 formatMenu->addAction (a);
996 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
997 actionFormatSelectionColor=a;
999 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1000 a->setStatusTip (tr( "Set Background Color" ));
1001 formatMenu->addAction (a);
1002 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1003 actionFormatBackColor=a;
1005 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1006 a->setStatusTip (tr( "Set Background image" ));
1007 formatMenu->addAction (a);
1008 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1009 actionFormatBackImage=a;
1013 void Main::setupViewActions()
1015 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1016 tb->setLabel( "View Actions" );
1017 tb->setObjectName ("viewTB");
1018 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1021 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1022 a->setStatusTip ( tr( "Zoom reset" ) );
1023 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1025 viewMenu->addAction (a);
1026 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1028 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1029 a->setStatusTip (tr( "Zoom in" ));
1030 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1032 viewMenu->addAction (a);
1033 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1035 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1036 a->setStatusTip (tr( "Zoom out" ));
1037 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1039 viewMenu->addAction (a);
1040 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1042 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1043 a->setStatusTip (tr( "Show selection" ));
1044 a->setShortcut (Qt::Key_Period);
1046 viewMenu->addAction (a);
1047 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1049 viewMenu->addSeparator();
1051 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1052 a->setStatusTip ( tr( "Show Note Editor" ));
1053 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1054 a->setToggleAction(true);
1056 viewMenu->addAction (a);
1057 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1058 actionViewToggleNoteEditor=a;
1060 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1061 a->setStatusTip ( tr( "Show History Window" ));
1062 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1063 a->setToggleAction(true);
1065 viewMenu->addAction (a);
1066 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1067 actionViewToggleHistoryWindow=a;
1069 viewMenu->addAction (actionViewTogglePropertyWindow);
1071 viewMenu->addSeparator();
1073 a = new QAction(tr( "Antialiasing","View action" ),this );
1074 a->setStatusTip ( tr( "Antialiasing" ));
1075 a->setToggleAction(true);
1076 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1077 viewMenu->addAction (a);
1078 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1079 actionViewToggleAntiAlias=a;
1081 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1082 a->setStatusTip (a->text());
1083 a->setToggleAction(true);
1084 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1085 viewMenu->addAction (a);
1086 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1087 actionViewToggleSmoothPixmapTransform=a;
1089 a = new QAction(tr( "Next Map","View action" ), this);
1090 a->setStatusTip (a->text());
1091 a->setShortcut (Qt::ALT + Qt::Key_N );
1092 viewMenu->addAction (a);
1093 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1095 a = new QAction (tr( "Previous Map","View action" ), this );
1096 a->setStatusTip (a->text());
1097 a->setShortcut (Qt::ALT + Qt::Key_P );
1098 viewMenu->addAction (a);
1099 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1103 void Main::setupModeActions()
1105 //QPopupMenu *menu = new QPopupMenu( this );
1106 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1108 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1109 tb->setObjectName ("modesTB");
1111 actionGroupModModes=new QActionGroup ( this);
1112 actionGroupModModes->setExclusive (true);
1113 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1114 a->setShortcut (Qt::Key_J);
1115 a->setStatusTip ( tr( "Use modifier to color branches" ));
1116 a->setToggleAction(true);
1119 actionModModeColor=a;
1121 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1122 a->setShortcut( Qt::Key_K);
1123 a->setStatusTip( tr( "Use modifier to copy" ));
1124 a->setToggleAction(true);
1126 actionModModeCopy=a;
1128 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1129 a->setShortcut (Qt::Key_L);
1130 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1131 a->setToggleAction(true);
1133 actionModModeXLink=a;
1137 void Main::setupFlagActions()
1139 // Create System Flags
1143 systemFlagsDefault = new FlagRowObj ();
1144 systemFlagsDefault->setVisibility (false);
1145 systemFlagsDefault->setName ("systemFlagsDef");
1147 FlagObj *fo = new FlagObj ();
1148 fo->load(QPixmap(flagsPath+"flag-note.png"));
1149 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1151 fo->load(QPixmap(flagsPath+"flag-url.png"));
1152 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1154 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1155 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1157 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1158 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1160 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1161 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1163 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1164 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1166 // Create Standard Flags
1167 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1168 tb->setObjectName ("standardFlagTB");
1170 standardFlagsDefault = new FlagRowObj ();
1171 standardFlagsDefault->setVisibility (false);
1172 standardFlagsDefault->setName ("standardFlagsDef");
1173 standardFlagsDefault->setToolBar (tb);
1175 fo->load(flagsPath+"flag-exclamationmark.png");
1176 fo->setGroup("standard-mark");
1177 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1179 fo->load(flagsPath+"flag-questionmark.png");
1180 fo->setGroup("standard-mark");
1181 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1183 fo->load(flagsPath+"flag-hook-green.png");
1184 fo->setGroup("standard-hook");
1185 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1187 fo->load(flagsPath+"flag-cross-red.png");
1188 fo->setGroup("standard-hook");
1189 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1192 fo->load(flagsPath+"flag-stopsign.png");
1193 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1195 fo->load(flagsPath+"flag-smiley-good.png");
1196 fo->setGroup("standard-smiley");
1197 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1199 fo->load(flagsPath+"flag-smiley-sad.png");
1200 fo->setGroup("standard-smiley");
1201 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1203 fo->load(flagsPath+"flag-smiley-omg.png");
1204 fo->setGroup("standard-smiley");
1205 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1206 // Original omg.png (in KDE emoticons)
1209 fo->load(flagsPath+"flag-kalarm.png");
1210 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1212 fo->load(flagsPath+"flag-phone.png");
1213 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1215 fo->load(flagsPath+"flag-lamp.png");
1216 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1218 fo->load(flagsPath+"flag-arrow-up.png");
1219 fo->setGroup("standard-arrow");
1220 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1222 fo->load(flagsPath+"flag-arrow-down.png");
1223 fo->setGroup("standard-arrow");
1224 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1226 fo->load(flagsPath+"flag-arrow-2up.png");
1227 fo->setGroup("standard-arrow");
1228 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1230 fo->load(flagsPath+"flag-arrow-2down.png");
1231 fo->setGroup("standard-arrow");
1232 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1235 fo->load(flagsPath+"flag-thumb-up.png");
1236 fo->setGroup("standard-thumb");
1237 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1239 fo->load(flagsPath+"flag-thumb-down.png");
1240 fo->setGroup("standard-thumb");
1241 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1244 fo->load(flagsPath+"flag-rose.png");
1245 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1247 fo->load(flagsPath+"flag-heart.png");
1248 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1250 fo->load(flagsPath+"flag-present.png");
1251 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1253 fo->load(flagsPath+"flag-flash.png");
1254 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1256 // Original: xsldbg_output.png
1257 fo->load(flagsPath+"flag-info.png");
1258 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1260 // Original khelpcenter.png
1261 fo->load(flagsPath+"flag-lifebelt.png");
1262 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1268 fo->load(flagsPath+"freemind/warning.png");
1269 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1271 for (int i=1; i<8; i++)
1273 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1274 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1277 fo->load(flagsPath+"freemind/back.png");
1278 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1280 fo->load(flagsPath+"freemind/forward.png");
1281 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1283 fo->load(flagsPath+"freemind/attach.png");
1284 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1286 fo->load(flagsPath+"freemind/clanbomber.png");
1287 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1289 fo->load(flagsPath+"freemind/desktopnew.png");
1290 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1292 fo->load(flagsPath+"freemind/flag.png");
1293 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1296 fo->load(flagsPath+"freemind/gohome.png");
1297 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1300 fo->load(flagsPath+"freemind/kaddressbook.png");
1301 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1303 fo->load(flagsPath+"freemind/knotify.png");
1304 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1306 fo->load(flagsPath+"freemind/korn.png");
1307 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1309 fo->load(flagsPath+"freemind/mail.png");
1310 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1312 fo->load(flagsPath+"freemind/password.png");
1313 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1315 fo->load(flagsPath+"freemind/pencil.png");
1316 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1318 fo->load(flagsPath+"freemind/stop.png");
1319 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1321 fo->load(flagsPath+"freemind/wizard.png");
1322 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1324 fo->load(flagsPath+"freemind/xmag.png");
1325 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1327 fo->load(flagsPath+"freemind/bell.png");
1328 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1330 fo->load(flagsPath+"freemind/bookmark.png");
1331 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1333 fo->load(flagsPath+"freemind/penguin.png");
1334 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1336 fo->load(flagsPath+"freemind/licq.png");
1337 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1342 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1345 fo->setToolTip (tooltip);
1346 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1352 fo->setAlwaysVisible(aw);
1353 a->setCheckable(true);
1354 a->setObjectName(fo->getName());
1355 a->setToolTip(tooltip);
1356 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1357 standardFlagsDefault->addFlag (fo);
1361 systemFlagsDefault->addFlag (fo);
1365 void Main::setupNetworkActions()
1367 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1369 QMenu *netMenu = menuBar()->addMenu( "Network" );
1373 a = new QAction( "Start TCPserver for MapEditor",this);
1374 //a->setStatusTip ( "Set application to open pdf files"));
1375 a->setShortcut ( Qt::Key_T ); //New TCP server
1376 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1377 netMenu->addAction (a);
1379 a = new QAction( "Connect MapEditor to server",this);
1380 //a->setStatusTip ( "Set application to open pdf files"));
1381 a->setShortcut ( Qt::Key_C ); // Connect to server
1382 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1383 netMenu->addAction (a);
1387 void Main::setupSettingsActions()
1389 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1393 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1394 a->setStatusTip ( tr( "Set application to open pdf files"));
1395 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1396 settingsMenu->addAction (a);
1398 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1399 a->setStatusTip( tr( "Set application to open external links"));
1400 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1401 settingsMenu->addAction (a);
1403 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1404 a->setStatusTip( tr( "Set path for macros"));
1405 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1406 settingsMenu->addAction (a);
1408 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1409 a->setStatusTip( tr( "Set number of undo levels"));
1410 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1411 settingsMenu->addAction (a);
1413 settingsMenu->addSeparator();
1415 a = new QAction( tr( "Autosave","Settings action"), this);
1416 a->setStatusTip( tr( "Autosave"));
1417 a->setToggleAction(true);
1418 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1419 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1420 settingsMenu->addAction (a);
1421 actionSettingsAutosaveToggle=a;
1423 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1424 a->setStatusTip( tr( "Autosave time"));
1425 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1426 settingsMenu->addAction (a);
1427 actionSettingsAutosaveTime=a;
1429 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1430 a->setStatusTip( tr( "Write backup file on save"));
1431 a->setToggleAction(true);
1432 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1433 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1434 settingsMenu->addAction (a);
1435 actionSettingsWriteBackupFile=a;
1437 settingsMenu->addSeparator();
1439 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1440 a->setStatusTip( tr( "Edit branch after adding it" ));
1441 a->setToggleAction(true);
1442 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1443 settingsMenu->addAction (a);
1444 actionSettingsAutoEditNewBranch=a;
1446 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1447 a->setStatusTip( tr( "Select branch after adding it" ));
1448 a->setToggleAction(true);
1449 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1450 settingsMenu->addAction (a);
1451 actionSettingsAutoSelectNewBranch=a;
1453 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1454 a->setStatusTip( tr( "Select heading before editing" ));
1455 a->setToggleAction(true);
1456 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1457 settingsMenu->addAction (a);
1458 actionSettingsAutoSelectText=a;
1460 a= new QAction( tr( "Delete key","Settings action" ), this);
1461 a->setStatusTip( tr( "Delete key for deleting branches" ));
1462 a->setToggleAction(true);
1463 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1464 settingsMenu->addAction (a);
1465 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1466 actionSettingsUseDelKey=a;
1468 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1469 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1470 a->setToggleAction(true);
1471 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1472 settingsMenu->addAction (a);
1473 actionSettingsUseFlagGroups=a;
1475 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1476 a->setStatusTip( tr( "Use hide flag during exports " ));
1477 a->setToggleAction(true);
1478 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1479 settingsMenu->addAction (a);
1480 actionSettingsUseHideExport=a;
1482 a = new QAction( tr( "Animation","Settings action"), this);
1483 a->setStatusTip( tr( "Animation"));
1484 a->setToggleAction(true);
1485 a->setOn (settings.value("/animation/use",false).toBool() );
1486 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1487 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1489 settingsMenu->addAction (a);
1491 actionSettingsUseAnimation=a;
1495 void Main::setupTestActions()
1497 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1500 a = new QAction( "Test function 1" , this);
1501 a->setStatusTip( "Call test function 1" );
1502 testMenu->addAction (a);
1503 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1505 a = new QAction( "Test function 2" , this);
1506 a->setStatusTip( "Call test function 2" );
1507 testMenu->addAction (a);
1508 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1510 a = new QAction( "Command" , this);
1511 a->setStatusTip( "Enter command to call in editor" );
1512 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1513 testMenu->addAction (a);
1517 void Main::setupHelpActions()
1519 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1522 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1523 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1524 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1525 helpMenu->addAction (a);
1527 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1528 a->setStatusTip( tr( "Open VYM example maps " ));
1529 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1530 helpMenu->addAction (a);
1532 a = new QAction( tr( "About VYM","Help action" ), this);
1533 a->setStatusTip( tr( "About VYM")+vymName);
1534 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1535 helpMenu->addAction (a);
1537 a = new QAction( tr( "About QT","Help action" ), this);
1538 a->setStatusTip( tr( "Information about QT toolkit" ));
1539 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1540 helpMenu->addAction (a);
1544 void Main::setupContextMenus()
1548 // Context Menu for branch or mapcenter
1549 branchContextMenu =new QMenu (this);
1550 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1551 branchContextMenu->addSeparator();
1554 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1555 branchAddContextMenu->addAction (actionEditPaste );
1556 branchAddContextMenu->addAction ( actionEditAddBranch );
1557 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1558 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1559 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1560 branchAddContextMenu->addSeparator();
1561 branchAddContextMenu->addAction ( actionEditImportAdd );
1562 branchAddContextMenu->addAction ( actionEditImportReplace );
1565 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1566 branchRemoveContextMenu->addAction (actionEditCut);
1567 branchRemoveContextMenu->addAction ( actionEditDelete );
1568 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1569 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1572 actionEditSaveBranch->addTo( branchContextMenu );
1573 actionFileNewCopy->addTo (branchContextMenu );
1575 branchContextMenu->addSeparator();
1576 branchContextMenu->addAction ( actionEditLoadImage);
1578 // Submenu for Links (URLs, vymLinks)
1579 branchLinksContextMenu =new QMenu (this);
1581 branchContextMenu->addSeparator();
1582 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1583 branchLinksContextMenu->addAction ( actionEditOpenURL );
1584 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1585 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1586 branchLinksContextMenu->addAction ( actionEditURL );
1587 branchLinksContextMenu->addAction ( actionEditLocalURL );
1588 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1589 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1590 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1592 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1594 branchLinksContextMenu->addSeparator();
1595 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1596 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1597 branchLinksContextMenu->addAction ( actionEditVymLink );
1598 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1601 // Context Menu for XLinks in a branch menu
1602 // This will be populated "on demand" in MapEditor::updateActions
1603 branchContextMenu->addSeparator();
1604 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1605 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1606 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1607 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1610 // Context menu for floatimage
1611 floatimageContextMenu =new QMenu (this);
1612 a= new QAction (tr ("Save image","Context action"),this);
1613 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1614 floatimageContextMenu->addAction (a);
1616 floatimageContextMenu->addSeparator();
1617 actionEditCopy->addTo( floatimageContextMenu );
1618 actionEditCut->addTo( floatimageContextMenu );
1620 floatimageContextMenu->addSeparator();
1621 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1624 // Context menu for canvas
1625 canvasContextMenu =new QMenu (this);
1626 actionEditMapInfo->addTo( canvasContextMenu );
1627 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1628 actionEditAddMapCenter->addTo( canvasContextMenu );
1629 canvasContextMenu->insertSeparator();
1630 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1631 canvasContextMenu->insertSeparator();
1632 actionFormatLinkColorHint->addTo( canvasContextMenu );
1633 actionFormatLinkColor->addTo( canvasContextMenu );
1634 actionFormatSelectionColor->addTo( canvasContextMenu );
1635 actionFormatBackColor->addTo( canvasContextMenu );
1636 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1638 // Menu for last opened files
1640 for (int i = 0; i < MaxRecentFiles; ++i)
1642 recentFileActions[i] = new QAction(this);
1643 recentFileActions[i]->setVisible(false);
1644 fileLastMapsMenu->addAction(recentFileActions[i]);
1645 connect(recentFileActions[i], SIGNAL(triggered()),
1646 this, SLOT(fileLoadRecent()));
1648 setupRecentMapsMenu();
1651 void Main::setupRecentMapsMenu()
1653 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1655 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1657 for (int i = 0; i < numRecentFiles; ++i) {
1658 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1659 recentFileActions[i]->setText(text);
1660 recentFileActions[i]->setData(files[i]);
1661 recentFileActions[i]->setVisible(true);
1663 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1664 recentFileActions[j]->setVisible(false);
1667 void Main::setupMacros()
1669 for (int i = 0; i <= 11; i++)
1671 macroActions[i] = new QAction(this);
1672 macroActions[i]->setData(i);
1673 addAction (macroActions[i]);
1674 connect(macroActions[i], SIGNAL(triggered()),
1675 this, SLOT(callMacro()));
1677 macroActions[0]->setShortcut ( Qt::Key_F1 );
1678 macroActions[1]->setShortcut ( Qt::Key_F2 );
1679 macroActions[2]->setShortcut ( Qt::Key_F3 );
1680 macroActions[3]->setShortcut ( Qt::Key_F4 );
1681 macroActions[4]->setShortcut ( Qt::Key_F5 );
1682 macroActions[5]->setShortcut ( Qt::Key_F6 );
1683 macroActions[6]->setShortcut ( Qt::Key_F7 );
1684 macroActions[7]->setShortcut ( Qt::Key_F8 );
1685 macroActions[8]->setShortcut ( Qt::Key_F9 );
1686 macroActions[9]->setShortcut ( Qt::Key_F10 );
1687 macroActions[10]->setShortcut ( Qt::Key_F11 );
1688 macroActions[11]->setShortcut ( Qt::Key_F12 );
1691 void Main::hideEvent (QHideEvent * )
1693 if (!textEditor->isMinimized() ) textEditor->hide();
1696 void Main::showEvent (QShowEvent * )
1698 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1702 MapEditor* Main::currentMapEditor() const
1704 if ( tabWidget->currentPage() &&
1705 tabWidget->currentPage()->inherits( "MapEditor" ) )
1706 return (MapEditor*)tabWidget->currentPage();
1711 void Main::editorChanged(QWidget *)
1713 // Unselect all possibly selected objects
1714 // (Important to update note editor)
1716 for (int i=0;i<=tabWidget->count() -1;i++)
1718 me=(MapEditor*)tabWidget->page(i);
1721 me=currentMapEditor();
1722 if (me) me->reselect();
1724 // Update actions to in menus and toolbars according to editor
1728 void Main::fileNew()
1730 QString fn="unnamed";
1731 MapEditor* me = new MapEditor ( NULL);
1732 tabWidget->addTab (me,fn);
1733 tabWidget->showPage(me);
1734 me->viewport()->setFocus();
1735 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1736 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1738 // For the very first map we do not have flagrows yet...
1742 void Main::fileNewCopy()
1744 QString fn="unnamed";
1745 MapEditor* oldME =currentMapEditor();
1749 MapEditor* newME = new MapEditor ( NULL);
1752 tabWidget->addTab (newME,fn);
1753 tabWidget->showPage(newME);
1754 newME->viewport()->setFocus();
1755 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1756 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1757 // For the very first map we do not have flagrows yet...
1758 newME->select("mc:");
1759 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1765 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1767 ErrorCode err=success;
1769 // fn is usually the archive, mapfile the file after uncompressing
1772 // Make fn absolute (needed for unzip)
1773 fn=QDir (fn).absPath();
1779 // Check, if map is already loaded
1781 while (i<=tabWidget->count() -1)
1783 me=(MapEditor*)tabWidget->page(i);
1784 if (me->getFilePath() == fn)
1786 // Already there, ask for confirmation
1787 QMessageBox mb( vymName,
1788 tr("The map %1\nis already opened."
1789 "Opening the same map in multiple editors may lead \n"
1790 "to confusion when finishing working with vym."
1791 "Do you want to").arg(fn),
1792 QMessageBox::Warning,
1793 QMessageBox::Yes | QMessageBox::Default,
1794 QMessageBox::Cancel | QMessageBox::Escape,
1795 QMessageBox::NoButton);
1796 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1797 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1800 case QMessageBox::Yes:
1802 i=tabWidget->count();
1804 case QMessageBox::Cancel:
1816 if ( !fn.isEmpty() )
1818 me = currentMapEditor();
1819 int tabIndex=tabWidget->currentPageIndex();
1820 // Check first, if mapeditor exists
1821 // If it is not default AND we want a new map,
1822 // create a new mapeditor in a new tab
1823 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1825 me= new MapEditor ( NULL);
1826 tabWidget->addTab (me,fn);
1827 tabIndex=tabWidget->indexOf (me);
1828 tabWidget->setCurrentPage (tabIndex);
1829 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1830 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1833 // Check, if file exists (important for creating new files
1834 // from command line
1837 if (!QFile(fn).exists() )
1839 QMessageBox mb( vymName,
1840 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1841 QMessageBox::Question,
1843 QMessageBox::Cancel | QMessageBox::Default,
1844 QMessageBox::NoButton );
1846 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1847 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1850 case QMessageBox::Yes:
1852 currentMapEditor()->setFilePath(fn);
1853 tabWidget->setTabLabel (currentMapEditor(),
1854 currentMapEditor()->getFileName() );
1855 statusBar()->message( "Created " + fn , statusbarTime );
1858 case QMessageBox::Cancel:
1859 // don't create new map
1860 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1866 //tabWidget->currentPage() won't be NULL here, because of above...
1867 tabWidget->showPage(me);
1868 me->viewport()->setFocus();
1872 // Save existing filename in case we import
1873 QString fn_org=me->getFilePath();
1875 // Finally load map into mapEditor
1876 me->setFilePath (fn);
1877 err=me->load(fn,lmode,ftype);
1879 // Restore old (maybe empty) filepath, if this is an import
1881 me->setFilePath (fn_org);
1884 // Finally check for errors and go home
1887 if (lmode==NewMap) fileCloseMap();
1888 statusBar()->message( "Could not load " + fn, statusbarTime );
1893 me->setFilePath (fn);
1894 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1895 if (!isInTmpDir (fn))
1897 // Only append to lastMaps if not loaded from a tmpDir
1898 // e.g. imported bookmarks are in a tmpDir
1899 addRecentMap(me->getFilePath() );
1901 actionFilePrint->setEnabled (true);
1903 statusBar()->message( "Loaded " + fn, statusbarTime );
1910 void Main::fileLoad(const LoadMode &lmode)
1912 QStringList filters;
1913 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1914 QFileDialog *fd=new QFileDialog( this);
1915 fd->setDir (lastFileDir);
1916 fd->setFileMode (QFileDialog::ExistingFiles);
1917 fd->setFilters (filters);
1921 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1924 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1927 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1933 if ( fd->exec() == QDialog::Accepted )
1935 lastFileDir=fd->directory().path();
1936 QStringList flist = fd->selectedFiles();
1937 QStringList::Iterator it = flist.begin();
1938 while( it != flist.end() )
1941 fileLoad(*it, lmode);
1948 void Main::fileLoad()
1953 void Main::fileLoadRecent()
1955 QAction *action = qobject_cast<QAction *>(sender());
1957 fileLoad (action->data().toString(), NewMap);
1960 void Main::addRecentMap (const QString &fileName)
1963 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1964 files.removeAll(fileName);
1965 files.prepend(fileName);
1966 while (files.size() > MaxRecentFiles)
1969 settings.setValue("/mainwindow/recentFileList", files);
1971 setupRecentMapsMenu();
1974 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1978 if ( me->getFilePath().isEmpty() )
1980 // We have no filepath yet,
1981 // call fileSaveAs() now, this will call fileSave()
1983 // First switch to editor
1984 tabWidget->setCurrentWidget (me);
1985 fileSaveAs(savemode);
1988 if (me->save (savemode)==success)
1990 statusBar()->message(
1991 tr("Saved %1").arg(me->getFilePath()),
1993 addRecentMap (me->getFilePath() );
1995 statusBar()->message(
1996 tr("Couldn't save ").arg(me->getFilePath()),
2000 void Main::fileSave()
2002 fileSave (currentMapEditor(), CompleteMap);
2005 void Main::fileSave(MapEditor *me)
2007 fileSave (me,CompleteMap);
2010 void Main::fileSaveAs(const SaveMode& savemode)
2014 if (currentMapEditor())
2016 if (savemode==CompleteMap)
2017 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2019 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2020 if ( !fn.isEmpty() )
2022 // Check for existing file
2023 if (QFile (fn).exists())
2025 QMessageBox mb( vymName,
2026 tr("The file %1\nexists already. Do you want to").arg(fn),
2027 QMessageBox::Warning,
2028 QMessageBox::Yes | QMessageBox::Default,
2029 QMessageBox::Cancel | QMessageBox::Escape,
2030 QMessageBox::NoButton);
2031 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2032 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2035 case QMessageBox::Yes:
2038 case QMessageBox::Cancel:
2045 // New file, add extension to filename, if missing
2046 // This is always .vym or .vyp, depending on savemode
2047 if (savemode==CompleteMap)
2049 if (!fn.contains (".vym") && !fn.contains (".xml"))
2053 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2062 currentMapEditor()->setFilePath(fn);
2063 fileSave(currentMapEditor(), savemode);
2066 if (savemode==CompleteMap)
2067 tabWidget->setTabLabel (currentMapEditor(),
2068 currentMapEditor()->getFileName() );
2074 void Main::fileSaveAs()
2076 fileSaveAs (CompleteMap);
2079 void Main::fileImportKDE3Bookmarks()
2081 ImportKDE3Bookmarks im;
2083 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2084 currentMapEditor()->setFilePath ("");
2087 void Main::fileImportKDE4Bookmarks()
2089 ImportKDE4Bookmarks im;
2091 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2092 currentMapEditor()->setFilePath ("");
2095 void Main::fileImportFirefoxBookmarks()
2097 Q3FileDialog *fd=new Q3FileDialog( this);
2098 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2099 fd->setMode (Q3FileDialog::ExistingFiles);
2100 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2101 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2104 if ( fd->exec() == QDialog::Accepted )
2106 ImportFirefoxBookmarks im;
2107 QStringList flist = fd->selectedFiles();
2108 QStringList::Iterator it = flist.begin();
2109 while( it != flist.end() )
2112 if (im.transform() &&
2113 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2114 currentMapEditor() )
2115 currentMapEditor()->setFilePath ("");
2122 void Main::fileImportFreemind()
2124 QStringList filters;
2125 filters <<"Freemind map (*.mm)"<<"All files (*)";
2126 QFileDialog *fd=new QFileDialog( this);
2127 fd->setDir (lastFileDir);
2128 fd->setFileMode (QFileDialog::ExistingFiles);
2129 fd->setFilters (filters);
2130 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2134 if ( fd->exec() == QDialog::Accepted )
2136 lastFileDir=fd->directory().path();
2137 QStringList flist = fd->selectedFiles();
2138 QStringList::Iterator it = flist.begin();
2139 while( it != flist.end() )
2142 if ( fileLoad (fn,NewMap, FreemindMap) )
2144 currentMapEditor()->setFilePath ("");
2153 void Main::fileImportMM()
2157 Q3FileDialog *fd=new Q3FileDialog( this);
2158 fd->setDir (lastFileDir);
2159 fd->setMode (Q3FileDialog::ExistingFiles);
2160 fd->addFilter ("Mind Manager (*.mmap)");
2161 fd->setCaption(tr("Import")+" "+"Mind Manager");
2164 if ( fd->exec() == QDialog::Accepted )
2166 lastFileDir=fd->dirPath();
2167 QStringList flist = fd->selectedFiles();
2168 QStringList::Iterator it = flist.begin();
2169 while( it != flist.end() )
2172 if (im.transform() &&
2173 success==fileLoad (im.getTransformedFile(),NewMap) &&
2174 currentMapEditor() )
2175 currentMapEditor()->setFilePath ("");
2184 void Main::fileImportDir()
2186 if (currentMapEditor())
2187 currentMapEditor()->importDir();
2190 void Main::fileExportXML()
2192 MapEditor *me=currentMapEditor();
2193 if (me) me->exportXML();
2197 void Main::fileExportXHTML()
2199 MapEditor *me=currentMapEditor();
2200 if (me) me->exportXHTML();
2203 void Main::fileExportImage()
2205 MapEditor *me=currentMapEditor();
2206 if (me) me->exportImage();
2209 void Main::fileExportASCII()
2211 MapEditor *me=currentMapEditor();
2212 if (me) me->exportASCII();
2215 void Main::fileExportCSV() //FIXME not scriptable yet
2217 MapEditor *me=currentMapEditor();
2221 ex.setModel (me->getModel());
2222 ex.addFilter ("CSV (*.csv)");
2223 ex.setDir(lastImageDir);
2224 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2225 if (ex.execDialog() )
2227 me->setExportMode(true);
2229 me->setExportMode(false);
2234 void Main::fileExportLaTeX() //FIXME not scriptable yet
2236 MapEditor *me=currentMapEditor();
2240 ex.setModel (me->getModel());
2241 ex.addFilter ("Tex (*.tex)");
2242 ex.setDir(lastImageDir);
2243 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2244 if (ex.execDialog() )
2246 me->setExportMode(true);
2248 me->setExportMode(false);
2253 void Main::fileExportKDE3Bookmarks() //FIXME not scriptable yet
2255 ExportKDE3Bookmarks ex;
2256 MapEditor *me=currentMapEditor();
2259 ex.setModel (me->getModel());
2264 void Main::fileExportKDE4Bookmarks() //FIXME not scriptable yet
2266 ExportKDE4Bookmarks ex;
2267 MapEditor *me=currentMapEditor();
2270 ex.setModel (me->getModel());
2275 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2277 ExportTaskjuggler ex;
2278 MapEditor *me=currentMapEditor();
2281 ex.setModel (me->getModel());
2282 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2283 ex.setDir(lastImageDir);
2284 ex.addFilter ("Taskjuggler (*.tjp)");
2285 if (ex.execDialog() )
2287 me->setExportMode(true);
2289 me->setExportMode(false);
2294 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2296 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2297 // TODO add preview in dialog
2298 //ImagePreview *p =new ImagePreview (fd);
2299 //fd->setContentsPreviewEnabled( TRUE );
2300 //fd->setContentsPreview( p, p );
2301 //fd->setPreviewMode( QFileDialog::Contents );
2302 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2303 fd->setDir (QDir().current());
2304 if (fd->foundConfig())
2308 if ( fd->exec() == QDialog::Accepted )
2310 QString fn=fd->selectedFile();
2311 if (!fn.contains (".odp"))
2314 //lastImageDir=fn.left(fn.findRev ("/"));
2315 if (currentMapEditor())
2316 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2320 QMessageBox::warning(0,
2322 tr("Couldn't find configuration for export to Open Office\n"));
2326 void Main::fileCloseMap()
2328 MapEditor *me = currentMapEditor();
2331 if (me->hasChanged())
2333 QMessageBox mb( vymName,
2334 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
2335 QMessageBox::Warning,
2336 QMessageBox::Yes | QMessageBox::Default,
2338 QMessageBox::Cancel | QMessageBox::Escape );
2339 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2340 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2343 case QMessageBox::Yes:
2345 fileSave(me, CompleteMap);
2347 case QMessageBox::No:
2348 // close without saving
2350 case QMessageBox::Cancel:
2356 tabWidget->removePage(me);
2357 if (tabWidget->count()==0)
2358 actionFilePrint->setEnabled (false);
2361 // Better would be delete (me), but then we have a Qt error:
2362 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2363 // So we only remove data now and call deconstructor when vym closes later
2368 void Main::filePrint()
2370 if (currentMapEditor())
2371 currentMapEditor()->print();
2374 void Main::fileExitVYM()
2376 // Check if one or more editors have changed
2379 for (i=0;i<=tabWidget->count() -1;i++)
2382 me=(MapEditor*)tabWidget->page(i);
2384 // If something changed, ask what to do
2385 if (me->hasChanged())
2387 tabWidget->setCurrentPage(i);
2388 QMessageBox mb( vymName,
2389 tr("This map is not saved yet. Do you want to"),
2390 QMessageBox::Warning,
2391 QMessageBox::Yes | QMessageBox::Default,
2393 QMessageBox::Cancel | QMessageBox::Escape );
2394 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2395 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2398 mb.setActiveWindow();
2399 switch( mb.exec() ) {
2400 case QMessageBox::Yes:
2401 // save (the changed editors) and exit
2402 fileSave(currentMapEditor(), CompleteMap);
2404 case QMessageBox::No:
2405 // exit without saving
2407 case QMessageBox::Cancel:
2408 // don't save and don't exit
2412 me->clear(); // remove and unselect now, before mainWindow has gone...
2413 } // loop over all MEs
2417 void Main::editUndo()
2419 if (currentMapEditor())
2420 currentMapEditor()->undo();
2423 void Main::editRedo()
2425 if (currentMapEditor())
2426 currentMapEditor()->redo();
2429 void Main::gotoHistoryStep (int i)
2431 if (currentMapEditor())
2432 currentMapEditor()->gotoHistoryStep (i);
2435 void Main::editCopy()
2437 if (currentMapEditor())
2438 currentMapEditor()->copy();
2441 void Main::editPaste()
2443 if (currentMapEditor())
2444 currentMapEditor()->paste();
2447 void Main::editCut()
2449 if (currentMapEditor())
2450 currentMapEditor()->cut();
2453 void Main::editOpenFindWindow()
2455 findWindow->popup();
2456 findWindow->raise();
2457 findWindow->setActiveWindow();
2460 void Main::editFind(QString s)
2463 BranchObj *bo=currentMapEditor()->findText(s, cs);
2466 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2469 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2470 tr("No matches found for \"%1\"").arg(s));
2474 void Main::editFindChanged()
2475 { // Notify editor, to abort the current find process
2476 currentMapEditor()->findReset();
2479 void Main::openTabs(QStringList urls)
2481 if (!urls.isEmpty())
2485 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2487 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2489 QString u=urls.takeFirst();
2490 procBrowser = new QProcess( this );
2492 procBrowser->start(browser,args);
2493 if ( !procBrowser->waitForStarted())
2495 // try to set path to browser
2496 QMessageBox::warning(0,
2498 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2499 tr("Please use Settings->")+tr("Set application to open an URL"));
2502 #if defined(Q_OS_WIN32)
2503 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2504 this->thread()->wait(3000);
2509 if (browser.contains("konqueror"))
2511 cout << "Main::openTabs urls="<<urls.join(" ").toStdString()<<endl;
2512 for (int i=0; i<urls.size(); i++)
2515 // Try to open new tab in existing konqueror started previously by vym
2516 p=new QProcess (this);
2518 #if defined(Q_OS_WIN32)
2519 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2520 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2521 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2522 "konqueror-mainwindow#1"<<
2526 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2527 "konqueror-mainwindow#1"<<
2530 // qdbus org.kde.konqueror-15367 /konqueror/MainWindow_1 newTab www.suse.de false
2532 p->start ("dcop",args);
2534 cout << "MainWindo::openURLs i="<<i <<"/"<<urls.size()-1
2535 <<" args="<<args.join(" ").toStdString()<<endl;
2537 if ( !p->waitForStarted() ) success=false;
2540 QMessageBox::warning(0,
2542 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2544 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2546 for (int i=0; i<urls.size(); i++)
2548 // Try to open new tab in firefox
2549 p=new QProcess (this);
2550 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2551 p->start (browser,args);
2552 if ( !p->waitForStarted() ) success=false;
2555 QMessageBox::warning(0,
2557 tr("Couldn't start %1 to open a new tab").arg(browser));
2560 QMessageBox::warning(0,
2562 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2566 void Main::editOpenURL()
2569 if (currentMapEditor())
2571 QString url=currentMapEditor()->getURL();
2573 if (url=="") return;
2574 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2575 procBrowser = new QProcess( this );
2577 procBrowser->start(browser,args);
2578 if ( !procBrowser->waitForStarted())
2580 // try to set path to browser
2581 QMessageBox::warning(0,
2583 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2584 tr("Please use Settings->")+tr("Set application to open an URL"));
2589 void Main::editOpenURLTab()
2591 if (currentMapEditor())
2594 urls.append(currentMapEditor()->getURL());
2598 void Main::editOpenMultipleURLTabs()
2600 if (currentMapEditor())
2603 urls=currentMapEditor()->getURLs();
2610 void Main::editURL()
2612 if (currentMapEditor())
2613 currentMapEditor()->editURL();
2616 void Main::editLocalURL()
2618 if (currentMapEditor())
2619 currentMapEditor()->editLocalURL();
2622 void Main::editHeading2URL()
2624 if (currentMapEditor())
2625 currentMapEditor()->editHeading2URL();
2628 void Main::editBugzilla2URL()
2630 if (currentMapEditor())
2631 currentMapEditor()->editBugzilla2URL();
2634 void Main::editFATE2URL()
2636 if (currentMapEditor())
2637 currentMapEditor()->editFATE2URL();
2640 void Main::editHeadingFinished()
2642 // only called from editHeading(), so there is a currentME
2643 MapEditor *me=currentMapEditor();
2646 me->setStateEditHeading (false);
2647 QPoint p; //Not used here, only to find out pos of branch
2649 QString s=me->getHeading(ok,p);
2651 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2653 if (ok && s!=lineedit->text())
2654 me->setHeading(lineedit->text());
2656 lineedit->releaseKeyboard();
2660 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2661 !prevSelection.isEmpty())
2662 me->select(prevSelection);
2667 void Main::editHeading()
2669 if (currentMapEditor())
2671 MapEditor *me=currentMapEditor();
2672 QString oldSel=me->getSelectString();
2674 if (lineedit->isVisible())
2675 editHeadingFinished();
2680 QString s=me->getHeading(ok,p);
2684 me->setStateEditHeading (true);
2685 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2686 p=me->mapToGlobal (p);
2687 QDialog *d =new QDialog(NULL);
2688 QLineEdit *le=new QLineEdit (d);
2689 d->setWindowFlags (Qt::FramelessWindowHint);
2690 d->setGeometry(p.x(),p.y(),230,25);
2691 le->resize (d->width()-10,d->height());
2694 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2695 d->activateWindow();
2697 me->setHeading (le->text());
2700 editHeadingFinished();
2702 p=me->mapTo (this,p);
2703 lineedit->setGeometry(p.x(),p.y(),230,25);
2704 lineedit->setText(s);
2705 lineedit->setCursorPosition(1);
2706 lineedit->selectAll();
2708 lineedit->grabKeyboard();
2709 lineedit->setFocus();
2713 } // currentMapEditor()
2716 void Main::editAttributeFinished()
2718 // only called from editHeading(), so there is a currentME
2721 MapEditor *me=currentMapEditor();
2724 me->setStateEditHeading (false);
2725 QPoint p; //Not used here, only to find out pos of branch
2727 QString s=me->getHeading(ok,p);
2729 #if defined(Q_OS_MACX)
2731 if (ok && s!=lineedit->text())
2732 me->setHeading(lineedit->text());
2734 lineedit->releaseKeyboard();
2738 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2739 !prevSelection.isEmpty())
2740 me->select(prevSelection);
2746 #include "attribute.h"
2747 #include "attributedialog.h"
2748 void Main::editAttribute()
2750 MapEditor *me=currentMapEditor();
2753 BranchObj *bo=me->getSelectedBranch();
2756 AttributeDialog dia(this);
2757 dia.setTable (me->attributeTable() );
2759 dia.setMode (Definition);
2765 if (currentMapEditor())
2767 MapEditor *me=currentMapEditor();
2768 QString oldSel=me->getSelectString();
2770 if (lineedit->isVisible())
2771 editAttributeFinished();
2776 QString s=me->getHeading(ok,p);
2780 me->setStateEditHeading (true);
2781 #if defined(Q_OS_MACX)
2782 p=me->mapToGlobal (p);
2783 QDialog *d =new QDialog(NULL);
2784 QLineEdit *le=new QLineEdit (d);
2785 d->setWindowFlags (Qt::FramelessWindowHint);
2786 d->setGeometry(p.x(),p.y(),230,25);
2787 le->resize (d->width()-10,d->height());
2790 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2791 d->activateWindow();
2793 me->setHeading (le->text());
2796 editHeadingFinished();
2798 p=me->mapTo (this,p);
2799 lineedit->setGeometry(p.x(),p.y(),230,25);
2800 lineedit->setText(s);
2801 lineedit->setCursorPosition(1);
2802 lineedit->selectAll();
2804 lineedit->grabKeyboard();
2805 lineedit->setFocus();
2809 } // currentMapEditor()
2814 void Main::openVymLinks(const QStringList &vl)
2816 for (int j=0; j<vl.size(); j++)
2818 // compare path with already loaded maps
2822 for (i=0;i<=tabWidget->count() -1;i++)
2824 me=(MapEditor*)tabWidget->page(i);
2825 if (vl.at(j)==me->getFilePath() )
2834 if (!QFile(vl.at(j)).exists() )
2835 QMessageBox::critical( 0, tr( "Critical Error" ),
2836 tr("Couldn't open map %1").arg(vl.at(j)));
2839 fileLoad (vl.at(j), NewMap);
2840 tabWidget->setCurrentPage (tabWidget->count()-1);
2843 // Go to tab containing the map
2844 tabWidget->setCurrentPage (index);
2848 void Main::editOpenVymLink()
2850 if (currentMapEditor())
2853 vl.append(currentMapEditor()->getVymLink());
2858 void Main::editOpenMultipleVymLinks()
2860 QString currentVymLink;
2861 if (currentMapEditor())
2863 QStringList vl=currentMapEditor()->getVymLinks();
2868 void Main::editVymLink()
2870 if (currentMapEditor())
2871 currentMapEditor()->editVymLink();
2874 void Main::editDeleteVymLink()
2876 if (currentMapEditor())
2877 currentMapEditor()->deleteVymLink();
2880 void Main::editToggleHideExport()
2882 if (currentMapEditor())
2883 currentMapEditor()->toggleHideExport();
2886 void Main::editMapInfo()
2888 if (currentMapEditor())
2889 currentMapEditor()->editMapInfo();
2892 void Main::editMoveUp()
2894 if (currentMapEditor())
2895 currentMapEditor()->moveBranchUp();
2898 void Main::editMoveDown()
2900 if (currentMapEditor())
2901 currentMapEditor()->moveBranchDown();
2904 void Main::editSortChildren()
2906 if (currentMapEditor())
2907 currentMapEditor()->sortChildren();
2910 void Main::editToggleScroll()
2912 if (currentMapEditor())
2914 currentMapEditor()->toggleScroll();
2918 void Main::editUnscrollChilds()
2920 if (currentMapEditor())
2921 currentMapEditor()->unscrollChilds();
2924 void Main::editAddMapCenter()
2926 MapEditor *me=currentMapEditor();
2927 if (!lineedit->isVisible() && me)
2929 me->addMapCenter ();
2933 void Main::editNewBranch()
2935 MapEditor *me=currentMapEditor();
2936 if (!lineedit->isVisible() && me)
2938 BranchObj *bo=(BranchObj*)me->getSelection();
2939 BranchObj *newbo=me->addNewBranch(0);
2941 prevSelection=me->getModel()->getSelectString(bo);
2947 if (actionSettingsAutoEditNewBranch->isOn())
2952 if (!prevSelection.isEmpty())
2954 me->select(prevSelection);
2961 void Main::editNewBranchBefore()
2963 MapEditor *me=currentMapEditor();
2964 if (!lineedit->isVisible() && me)
2966 BranchObj *bo=(BranchObj*)me->getSelection();
2967 BranchObj *newbo=me->addNewBranchBefore();
2974 if (actionSettingsAutoEditNewBranch->isOn())
2976 if (!actionSettingsAutoSelectNewBranch->isOn())
2977 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2983 void Main::editNewBranchAbove()
2985 MapEditor *me=currentMapEditor();
2986 if (!lineedit->isVisible() && me)
2988 BranchObj *bo=(BranchObj*)me->getSelection();
2989 BranchObj *newbo=me->addNewBranch (-1);
2996 if (actionSettingsAutoEditNewBranch->isOn())
2998 if (!actionSettingsAutoSelectNewBranch->isOn())
2999 prevSelection=me->getModel()->getSelectString (bo); // TODO access directly
3005 void Main::editNewBranchBelow()
3007 MapEditor *me=currentMapEditor();
3008 if (!lineedit->isVisible() && me)
3010 BranchObj *bo=(BranchObj*)me->getSelection();
3011 BranchObj *newbo=me->addNewBranch (1);
3018 if (actionSettingsAutoEditNewBranch->isOn())
3020 if (!actionSettingsAutoSelectNewBranch->isOn())
3021 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
3027 void Main::editImportAdd()
3029 fileLoad (ImportAdd);
3032 void Main::editImportReplace()
3034 fileLoad (ImportReplace);
3037 void Main::editSaveBranch()
3039 fileSaveAs (PartOfMap);
3042 void Main::editDeleteKeepChilds()
3044 if (currentMapEditor())
3045 currentMapEditor()->deleteKeepChilds();
3048 void Main::editDeleteChilds()
3050 if (currentMapEditor())
3051 currentMapEditor()->deleteChilds();
3054 void Main::editDeleteSelection()
3056 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3057 currentMapEditor()->deleteSelection();
3060 void Main::editUpperBranch()
3062 if (currentMapEditor())
3063 currentMapEditor()->selectUpperBranch();
3066 void Main::editLowerBranch()
3068 if (currentMapEditor())
3069 currentMapEditor()->selectLowerBranch();
3072 void Main::editLeftBranch()
3074 if (currentMapEditor())
3075 currentMapEditor()->selectLeftBranch();
3078 void Main::editRightBranch()
3080 if (currentMapEditor())
3081 currentMapEditor()->selectRightBranch();
3084 void Main::editFirstBranch()
3086 if (currentMapEditor())
3087 currentMapEditor()->selectFirstBranch();
3090 void Main::editLastBranch()
3092 if (currentMapEditor())
3093 currentMapEditor()->selectLastBranch();
3096 void Main::editLoadImage()
3098 if (currentMapEditor())
3099 currentMapEditor()->loadFloatImage();
3102 void Main::editSaveImage()
3104 if (currentMapEditor())
3105 currentMapEditor()->saveFloatImage();
3108 void Main::editFollowXLink(QAction *a)
3111 if (currentMapEditor())
3112 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3115 void Main::editEditXLink(QAction *a)
3117 if (currentMapEditor())
3118 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3121 void Main::formatSelectColor()
3123 if (currentMapEditor())
3125 QColor col = QColorDialog::getColor((currentColor ), this );
3126 if ( !col.isValid() ) return;
3127 colorChanged( col );
3131 void Main::formatPickColor()
3133 if (currentMapEditor())
3134 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3137 void Main::colorChanged(QColor c)
3139 QPixmap pix( 16, 16 );
3141 actionFormatColor->setIconSet( pix );
3145 void Main::formatColorBranch()
3147 if (currentMapEditor())
3148 currentMapEditor()->colorBranch(currentColor);
3151 void Main::formatColorSubtree()
3153 if (currentMapEditor())
3154 currentMapEditor()->colorSubtree (currentColor);
3157 void Main::formatLinkStyleLine()
3159 if (currentMapEditor())
3161 currentMapEditor()->setMapLinkStyle("StyleLine");
3162 actionFormatLinkStyleLine->setOn(true);
3166 void Main::formatLinkStyleParabel()
3168 if (currentMapEditor())
3170 currentMapEditor()->setMapLinkStyle("StyleParabel");
3171 actionFormatLinkStyleParabel->setOn(true);
3175 void Main::formatLinkStylePolyLine()
3177 if (currentMapEditor())
3179 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3180 actionFormatLinkStylePolyLine->setOn(true);
3184 void Main::formatLinkStylePolyParabel()
3186 if (currentMapEditor())
3188 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3189 actionFormatLinkStylePolyParabel->setOn(true);
3193 void Main::formatSelectBackColor()
3195 if (currentMapEditor())
3196 currentMapEditor()->selectMapBackgroundColor();
3199 void Main::formatSelectBackImage()
3201 if (currentMapEditor())
3202 currentMapEditor()->selectMapBackgroundImage();
3205 void Main::formatSelectLinkColor()
3207 if (currentMapEditor())
3208 currentMapEditor()->selectMapLinkColor();
3211 void Main::formatSelectSelectionColor()
3213 if (currentMapEditor())
3214 currentMapEditor()->selectMapSelectionColor();
3217 void Main::formatToggleLinkColorHint()
3219 currentMapEditor()->toggleMapLinkColorHint();
3223 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3225 if (currentMapEditor())
3226 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3229 void Main::viewZoomReset()
3231 if (currentMapEditor())
3235 currentMapEditor()->setMatrix( m );
3239 void Main::viewZoomIn()
3241 if (currentMapEditor())
3243 QMatrix m = currentMapEditor()->matrix();
3244 m.scale( 1.25, 1.25 );
3245 currentMapEditor()->setMatrix( m );
3249 void Main::viewZoomOut()
3251 if (currentMapEditor())
3253 QMatrix m = currentMapEditor()->matrix();
3254 m.scale( 0.8, 0.8 );
3255 currentMapEditor()->setMatrix( m );
3259 void Main::viewCenter()
3261 MapEditor *me=currentMapEditor();
3264 me->ensureSelectionVisible();
3268 void Main::networkStartServer()
3270 MapEditor *me=currentMapEditor();
3271 if (me) me->newServer();
3274 void Main::networkConnect()
3276 MapEditor *me=currentMapEditor();
3277 if (me) me->connectToServer();
3280 bool Main::settingsPDF()
3282 // Default browser is set in constructor
3284 QString text = QInputDialog::getText(
3285 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3286 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3288 settings.setValue ("/mainwindow/readerPDF",text);
3293 bool Main::settingsURL()
3295 // Default browser is set in constructor
3297 QString text = QInputDialog::getText(
3298 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3299 settings.value("/mainwindow/readerURL").toString()
3302 settings.setValue ("/mainwindow/readerURL",text);
3306 void Main::settingsMacroDir()
3308 QDir defdir(vymBaseDir.path() + "/macros");
3309 if (!defdir.exists())
3311 QDir dir=QFileDialog::getExistingDirectory (
3313 tr ("Directory with vym macros:"),
3314 settings.value ("/macros/macroDir",defdir.path()).toString()
3317 settings.setValue ("/macros/macroDir",dir.absolutePath());
3320 void Main::settingsUndoLevels()
3323 int i = QInputDialog::getInteger(
3325 tr("QInputDialog::getInteger()"),
3326 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3329 settings.setValue ("/mapeditor/stepsTotal",i);
3330 QMessageBox::information( this, tr( "VYM -Information:" ),
3331 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3335 void Main::settingsAutosaveToggle()
3337 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3340 void Main::settingsAutosaveTime()
3343 int i = QInputDialog::getInteger(
3345 tr("QInputDialog::getInteger()"),
3346 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3348 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3351 void Main::settingsWriteBackupFileToggle()
3353 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3356 void Main::settingsToggleAnimation()
3358 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3361 void Main::settingsToggleDelKey()
3363 if (actionSettingsUseDelKey->isOn())
3365 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3368 actionEditDelete->setAccel (QKeySequence (""));
3372 void Main::windowToggleNoteEditor()
3374 if (textEditor->isVisible() )
3375 windowHideNoteEditor();
3377 windowShowNoteEditor();
3380 void Main::windowToggleHistory()
3382 if (historyWindow->isVisible())
3383 historyWindow->hide();
3385 historyWindow->show();
3389 void Main::windowToggleProperty()
3391 if (branchPropertyWindow->isVisible())
3392 branchPropertyWindow->hide();
3394 branchPropertyWindow->show();
3396 if(currentMapEditor())
3398 BranchObj *bo=currentMapEditor()->getSelectedBranch();
3401 branchPropertyWindow->setMapEditor(currentMapEditor());
3402 branchPropertyWindow->setBranch(bo);
3407 branchPropertyWindow->setBranch(NULL);
3410 void Main::windowToggleAntiAlias()
3412 bool b=actionViewToggleAntiAlias->isOn();
3414 for (int i=0;i<tabWidget->count();i++)
3417 me=(MapEditor*)tabWidget->page(i);
3418 me->setAntiAlias(b);
3423 void Main::windowToggleSmoothPixmap()
3425 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3427 for (int i=0;i<tabWidget->count();i++)
3430 me=(MapEditor*)tabWidget->page(i);
3431 me->setSmoothPixmap(b);
3435 void Main::updateHistory(SimpleSettings &undoSet)
3437 historyWindow->update (undoSet);
3440 void Main::updateNoteFlag()
3442 if (currentMapEditor())
3443 currentMapEditor()->updateNoteFlag();
3446 void Main::updateSatellites(MapEditor *me)
3448 branchPropertyWindow->setMapEditor (me);
3451 void Main::updateActions()
3453 MapEditor *me=currentMapEditor();
3456 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3458 // updateActions is also called when NoteEditor is closed
3459 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3460 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3461 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3463 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3464 actionFormatLinkColorHint->setOn(true);
3466 actionFormatLinkColorHint->setOn(false);
3468 switch (me->getMapLinkStyle())
3470 case LinkableMapObj::Line:
3471 actionFormatLinkStyleLine->setOn(true);
3473 case LinkableMapObj::Parabel:
3474 actionFormatLinkStyleParabel->setOn(true);
3476 case LinkableMapObj::PolyLine:
3477 actionFormatLinkStylePolyLine->setOn(true);
3479 case LinkableMapObj::PolyParabel:
3480 actionFormatLinkStylePolyParabel->setOn(true);
3487 QPixmap pix( 16, 16 );
3488 pix.fill( me->getMapBackgroundColor() );
3489 actionFormatBackColor->setIconSet( pix );
3490 pix.fill( me->getSelectionColor() );
3491 actionFormatSelectionColor->setIconSet( pix );
3492 pix.fill( me->getMapDefLinkColor() );
3493 actionFormatLinkColor->setIconSet( pix );
3496 actionFileSave->setEnabled( me->hasChanged() );
3497 if (me->isUndoAvailable())
3498 actionEditUndo->setEnabled( true);
3500 actionEditUndo->setEnabled( false);
3502 if (me->isRedoAvailable())
3503 actionEditRedo->setEnabled( true);
3505 actionEditRedo->setEnabled( false);
3507 LinkableMapObj *selection=me->getSelection();
3510 if ( (typeid(*selection) == typeid(BranchObj)) ||
3511 (typeid(*selection) == typeid(MapCenterObj)) )
3513 BranchObj *bo=(BranchObj*)selection;
3514 // Take care of links
3515 if (bo->countXLinks()==0)
3517 branchXLinksContextMenuEdit->clear();
3518 branchXLinksContextMenuFollow->clear();
3523 branchXLinksContextMenuEdit->clear();
3524 branchXLinksContextMenuFollow->clear();
3525 for (int i=0; i<=bo->countXLinks();i++)
3527 bot=bo->XLinkTargetAt(i);
3530 s=bot->getHeading();
3531 if (s.length()>xLinkMenuWidth)
3532 s=s.left(xLinkMenuWidth)+"...";
3533 branchXLinksContextMenuFollow->addAction (s);
3534 branchXLinksContextMenuEdit->addAction (s);
3539 standardFlagsDefault->setEnabled (true);
3541 actionEditToggleScroll->setEnabled (true);
3542 if ( bo->isScrolled() )
3543 actionEditToggleScroll->setOn(true);
3545 actionEditToggleScroll->setOn(false);
3547 if ( bo->getURL().isEmpty() )
3549 actionEditOpenURL->setEnabled (false);
3550 actionEditOpenURLTab->setEnabled (false);
3554 actionEditOpenURL->setEnabled (true);
3555 actionEditOpenURLTab->setEnabled (true);
3557 if ( bo->getVymLink().isEmpty() )
3559 actionEditOpenVymLink->setEnabled (false);
3560 actionEditDeleteVymLink->setEnabled (false);
3563 actionEditOpenVymLink->setEnabled (true);
3564 actionEditDeleteVymLink->setEnabled (true);
3567 if (bo->canMoveBranchUp())
3568 actionEditMoveUp->setEnabled (true);
3570 actionEditMoveUp->setEnabled (false);
3571 if (bo->canMoveBranchDown())
3572 actionEditMoveDown->setEnabled (true);
3574 actionEditMoveDown->setEnabled (false);
3577 actionEditToggleHideExport->setEnabled (true);
3578 actionEditToggleHideExport->setOn (bo->hideInExport() );
3580 actionEditCopy->setEnabled (true);
3581 actionEditCut->setEnabled (true);
3582 if (!clipboardEmpty)
3583 actionEditPaste->setEnabled (true);
3585 actionEditPaste->setEnabled (false);
3586 for (int i=0; i<actionListBranches.size(); ++i)
3587 actionListBranches.at(i)->setEnabled(true);
3588 actionEditDelete->setEnabled (true);
3589 actionFormatHideLinkUnselected->setOn
3590 (selection->getHideLinkUnselected());
3592 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3594 FloatObj *fo=(FloatImageObj*)selection;
3596 actionEditOpenURL->setEnabled (false);
3597 actionEditOpenVymLink->setEnabled (false);
3598 actionEditDeleteVymLink->setEnabled (false);
3599 actionEditToggleHideExport->setEnabled (true);
3600 actionEditToggleHideExport->setOn (fo->hideInExport() );
3603 actionEditCopy->setEnabled (true);
3604 actionEditCut->setEnabled (true);
3605 actionEditPaste->setEnabled (false);
3606 for (int i=0; i<actionListBranches.size(); ++i)
3607 actionListBranches.at(i)->setEnabled(false);
3608 actionEditDelete->setEnabled (true);
3609 actionFormatHideLinkUnselected->setOn
3610 ( selection->getHideLinkUnselected());
3611 actionEditMoveUp->setEnabled (false);
3612 actionEditMoveDown->setEnabled (false);
3617 actionEditCopy->setEnabled (false);
3618 actionEditCut->setEnabled (false);
3619 actionEditPaste->setEnabled (false);
3620 for (int i=0; i<actionListBranches.size(); ++i)
3621 actionListBranches.at(i)->setEnabled(false);
3623 actionEditToggleScroll->setEnabled (false);
3624 actionEditOpenURL->setEnabled (false);
3625 actionEditOpenVymLink->setEnabled (false);
3626 actionEditDeleteVymLink->setEnabled (false);
3627 actionEditHeading2URL->setEnabled (false);
3628 actionEditDelete->setEnabled (false);
3629 actionEditMoveUp->setEnabled (false);
3630 actionEditMoveDown->setEnabled (false);
3631 actionEditToggleHideExport->setEnabled (false);
3635 Main::ModMode Main::getModMode()
3637 if (actionModModeColor->isOn()) return ModModeColor;
3638 if (actionModModeCopy->isOn()) return ModModeCopy;
3639 if (actionModModeXLink->isOn()) return ModModeXLink;
3643 bool Main::autoEditNewBranch()
3645 return actionSettingsAutoEditNewBranch->isOn();
3648 bool Main::autoSelectNewBranch()
3650 return actionSettingsAutoSelectNewBranch->isOn();
3653 bool Main::useFlagGroups()
3655 return actionSettingsUseFlagGroups->isOn();
3658 void Main::windowShowNoteEditor()
3660 textEditor->setShowWithMain(true);
3662 actionViewToggleNoteEditor->setOn (true);
3665 void Main::windowHideNoteEditor()
3667 textEditor->setShowWithMain(false);
3669 actionViewToggleNoteEditor->setOn (false);
3672 void Main::setScript (const QString &script)
3674 scriptEditor->setScript (script);
3677 void Main::runScript (const QString &script)
3679 if (currentMapEditor())
3680 currentMapEditor()->runScript (script);
3683 void Main::runScriptEverywhere (const QString &script)
3686 for (int i=0;i<=tabWidget->count() -1;i++)
3688 me=(MapEditor*)tabWidget->page(i);
3689 if (me) me->runScript (script);
3693 void Main::windowNextEditor()
3695 if (tabWidget->currentPageIndex() < tabWidget->count())
3696 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3699 void Main::windowPreviousEditor()
3701 if (tabWidget->currentPageIndex() >0)
3702 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3705 void Main::standardFlagChanged()
3707 if (currentMapEditor())
3708 currentMapEditor()->toggleStandardFlag(sender()->name());
3711 void Main::testFunction1()
3713 if (!currentMapEditor()) return;
3714 currentMapEditor()->testFunction1();
3718 void Main::testFunction2()
3720 if (!currentMapEditor()) return;
3721 currentMapEditor()->testFunction2();
3724 void Main::testCommand()
3726 if (!currentMapEditor()) return;
3727 scriptEditor->show();
3730 QString com = QInputDialog::getText(
3731 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3732 if (ok) currentMapEditor()->parseAtom(com);
3736 void Main::helpDoc()
3738 QString locale = QLocale::system().name();
3740 if (locale.left(2)=="es")
3741 docname="vym_es.pdf";
3745 QStringList searchList;
3747 #if defined(Q_OS_MACX)
3748 searchList << "./vym.app/Contents/Resources/doc";
3749 #elif defined(Q_OS_WIN32)
3750 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3752 #if defined(VYM_DOCDIR)
3753 searchList << VYM_DOCDIR;
3755 // default path in SUSE LINUX
3756 searchList << "/usr/share/doc/packages/vym";
3759 searchList << "doc"; // relative path for easy testing in tarball
3760 searchList << "doc/tex"; // Easy testing working on vym.tex
3761 searchList << "/usr/share/doc/vym"; // Debian
3762 searchList << "/usr/share/doc/packages";// Knoppix
3766 for (int i=0; i<searchList.count(); ++i)
3768 docfile.setFileName(searchList.at(i)+"/"+docname);
3769 if (docfile.exists())
3778 QMessageBox::critical(0,
3779 tr("Critcal error"),
3780 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3785 Process *pdfProc = new Process();
3786 args << QDir::toNativeSeparators(docfile.fileName());
3788 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3789 if ( !pdfProc->waitForStarted() )
3792 QMessageBox::warning(0,
3794 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3795 tr("Please use Settings->")+tr("Set application to open PDF files"));
3802 void Main::helpDemo()
3804 QStringList filters;
3805 filters <<"VYM example map (*.vym)";
3806 QFileDialog *fd=new QFileDialog( this);
3807 #if defined(Q_OS_MACX)
3808 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3810 // default path in SUSE LINUX
3811 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3814 fd->setFileMode (QFileDialog::ExistingFiles);
3815 fd->setFilters (filters);
3816 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3820 if ( fd->exec() == QDialog::Accepted )
3822 lastFileDir=fd->directory().path();
3823 QStringList flist = fd->selectedFiles();
3824 QStringList::Iterator it = flist.begin();
3825 while( it != flist.end() )
3828 fileLoad(*it, NewMap);
3836 void Main::helpAbout()
3839 ad.setName ("aboutwindow");
3840 ad.setMinimumSize(500,500);
3841 ad.resize (QSize (500,500));
3845 void Main::helpAboutQT()
3847 QMessageBox::aboutQt( this, "Qt Application Example" );
3850 void Main::callMacro ()
3852 QAction *action = qobject_cast<QAction *>(sender());
3856 i=action->data().toInt();
3857 QString mDir (settings.value ("macros/macroDir").toString() );
3859 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3861 if ( !f.open( QIODevice::ReadOnly ) )
3863 QMessageBox::warning(0,
3865 tr("Couldn't find a macro at %1.\n").arg(fn)+
3866 tr("Please use Settings->")+tr("Set directory for vym macros"));
3870 QTextStream ts( &f );
3871 QString m= ts.read();
3875 //cout <<"Main::callMacro m="<<qPrintable (m)<<endl;
3876 currentMapEditor()->runScript (m);
3883 //////////////////////////////////
3885 @@ -2544,18 +2576,27 @@
3886 // Try to open new tab in existing konqueror started previously by vym
3887 p=new QProcess (this);
3889 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3890 - "konqueror-mainwindow#1"<<
3892 +#if defined(Q_OS_WIN32)
3893 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3894 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3895 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3896 + "konqueror-mainwindow#1"<<
3900 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3901 + "konqueror-mainwindow#1"<<
3905 p->start ("dcop",args);
3906 if ( !p->waitForStarted() ) success=false;