diff -r 918417b015e0 -r dfbc371b7280 mainwindow.cpp --- a/mainwindow.cpp Wed Mar 21 11:51:38 2007 +0000 +++ b/mainwindow.cpp Sat Mar 31 09:28:27 2007 +0000 @@ -19,6 +19,7 @@ #include "process.h" #include "settings.h" #include "texteditor.h" +#include "warningdialog.h" extern TextEditor *textEditor; extern Main *mainWindow; @@ -160,6 +161,8 @@ restoreState (settings.value("/mainwindow/state",0).toByteArray()); + // Satellite windows ////////////////////////////////////////// + // Initialize Find window findWindow=new FindWindow(NULL); findWindow->move (x(),y()+70); @@ -170,7 +173,10 @@ // Connect TextEditor, so that we can update flags if text changes connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); - connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions())); + connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions())); + + // Connect HistoryWindow, so that we can update flags + connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); updateGeometry(); } @@ -198,7 +204,7 @@ //FIXME save scriptEditor settings // call the destructors - delete (textEditor); + delete textEditor; delete historyWindow; // Remove temporary directory @@ -244,25 +250,24 @@ QAction *a; a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this); a->setStatusTip ( tr( "New map","Status tip File menu" ) ); - a->setShortcut ( Qt::CTRL + Qt::Key_N ); + a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map a->addTo( tb ); fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) ); a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this); a->setStatusTip (tr( "Open","Status tip File menu" ) ); - a->setShortcut ( Qt::CTRL + Qt::Key_O ); + a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map a->addTo( tb ); fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) ); fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu")); - fileLastMapsMenu->menuAction()->setShortcut ( Qt::CTRL + +Qt::SHIFT + Qt::Key_O ); fileMenu->addSeparator(); a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this); a->setStatusTip ( tr( "Save","Status tip file menu" )); - a->setShortcut (Qt::CTRL + Qt::Key_S ); + a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map a->addTo( tb ); fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); @@ -313,7 +318,7 @@ fileExportMenu->addAction (a); a = new QAction( "Webpage (XHTML)...",this ); - a->setShortcut (Qt::ALT + Qt::Key_X); + a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu"))); connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) ); fileExportMenu->addAction (a); @@ -347,7 +352,7 @@ a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this); a->setStatusTip ( tr( "Print" ,"File menu") ); - a->setShortcut (Qt::CTRL + Qt::Key_P ); + a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map a->addTo( tb ); fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) ); @@ -355,13 +360,13 @@ a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this); a->setStatusTip (tr( "Close Map" ) ); - a->setShortcut (Qt::ALT + Qt::Key_C ); + a->setShortcut (Qt::ALT + Qt::Key_C ); //Close map fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this); a->setStatusTip ( tr( "Exit")+" "+vymName ); - a->setShortcut (Qt::CTRL + Qt::Key_Q ); + a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) ); } @@ -380,7 +385,7 @@ a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this); connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) ); a->setStatusTip (tr( "Undo" ) ); - a->setShortcut ( Qt::CTRL + Qt::Key_Z ); + a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action a->setEnabled (false); tb->addAction (a); editMenu->addAction (a); @@ -388,7 +393,7 @@ a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); a->setStatusTip (tr( "Redo" )); - a->setShortcut (Qt::CTRL + Qt::Key_Y ); + a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action tb->addAction (a); editMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); @@ -397,7 +402,7 @@ editMenu->addSeparator(); a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this); a->setStatusTip ( tr( "Copy" ) ); - a->setShortcut (Qt::CTRL + Qt::Key_C ); + a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy a->setEnabled (false); tb->addAction (a); editMenu->addAction (a); @@ -406,7 +411,7 @@ a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this); a->setStatusTip ( tr( "Cut" ) ); - a->setShortcut (Qt::CTRL + Qt::Key_X ); + a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut a->setEnabled (false); tb->addAction (a); editMenu->addAction (a); @@ -416,7 +421,7 @@ a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this); connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) ); a->setStatusTip ( tr( "Paste" ) ); - a->setShortcut ( Qt::CTRL + Qt::Key_V ); + a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste a->setEnabled (false); tb->addAction (a); editMenu->addAction (a); @@ -425,14 +430,14 @@ // Shortcuts to modify heading: a = new QAction(tr( "Edit heading","Edit menu" ),this); a->setStatusTip ( tr( "edit Heading" )); - a->setShortcut ( Qt::Key_Enter); + a->setShortcut ( Qt::Key_Enter); //Edit heading // a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); a = new QAction( tr( "Edit heading","Edit menu" ), this); a->setStatusTip (tr( "edit Heading" )); - a->setShortcut (Qt::Key_Return ); + a->setShortcut (Qt::Key_Return ); //Edit heading //a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); @@ -441,7 +446,7 @@ actionEditHeading=a; a = new QAction( tr( "Edit heading","Edit menu" ), this); a->setStatusTip (tr( "edit Heading" )); - a->setShortcut ( Qt::Key_F2 ); + a->setShortcut ( Qt::Key_F2 ); //Edit heading a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); @@ -450,7 +455,7 @@ // Shortcut to delete selection a = new QAction( tr( "Delete Selection","Edit menu" ),this); a->setStatusTip (tr( "Delete Selection" )); - a->setShortcut ( Qt::Key_Delete); + a->setShortcut ( Qt::Key_Delete); //Delete selection a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) ); @@ -459,13 +464,13 @@ // Shortcut to add branch alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); alt->setStatusTip ( tr( "Add a branch as child of selection" )); - alt->setShortcut (Qt::Key_A); + alt->setShortcut (Qt::Key_A); //Add branch alt->setShortcutContext (Qt::WindowShortcut); addAction (alt); connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); a->setStatusTip ( tr( "Add a branch as child of selection" )); - a->setShortcut (Qt::Key_Insert); + a->setShortcut (Qt::Key_Insert); //Add branch connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); actionListBranches.append(a); #if defined (Q_OS_MACX) @@ -481,7 +486,7 @@ // Add branch by inserting it at selection a = new QAction(tr( "Add branch (insert)","Edit menu" ), this); a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); - a->setShortcut (Qt::ALT + Qt::Key_Insert ); + a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); @@ -490,7 +495,7 @@ actionEditAddBranchBefore=a; a = new QAction(tr( "Add branch (insert)","Edit menu" ),this); a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); - a->setShortcut ( Qt::ALT + Qt::Key_A ); + a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); @@ -499,7 +504,7 @@ // Add branch above a = new QAction(tr( "Add branch above","Edit menu" ), this); a->setStatusTip ( tr( "Add a branch above selection" )); - a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); + a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); @@ -508,7 +513,7 @@ actionEditAddBranchAbove=a; a = new QAction(tr( "Add branch above","Edit menu" ), this); a->setStatusTip ( tr( "Add a branch above selection" )); - a->setShortcut (Qt::SHIFT+Qt::Key_A ); + a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); @@ -517,7 +522,7 @@ // Add branch below a = new QAction(tr( "Add branch below","Edit menu" ), this); a->setStatusTip ( tr( "Add a branch below selection" )); - a->setShortcut (Qt::CTRL +Qt::Key_Insert ); + a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); @@ -526,7 +531,7 @@ actionEditAddBranchBelow=a; a = new QAction(tr( "Add branch below","Edit menu" ), this); a->setStatusTip ( tr( "Add a branch below selection" )); - a->setShortcut (Qt::CTRL +Qt::Key_A ); + a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); @@ -534,7 +539,7 @@ a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this); a->setStatusTip ( tr( "Move branch up" ) ); - a->setShortcut (Qt::Key_PageUp ); + a->setShortcut (Qt::Key_PageUp ); // Move branch up a->setEnabled (false); tb->addAction (a); editMenu->addAction (a); @@ -544,7 +549,7 @@ a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this); connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) ); a->setStatusTip (tr( "Move branch down" ) ); - a->setShortcut ( Qt::Key_PageDown ); + a->setShortcut ( Qt::Key_PageDown ); // Move branch down a->setEnabled (false); tb->addAction (a); editMenu->addAction (a); @@ -557,7 +562,7 @@ connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this); - alt->setShortcut ( Qt::Key_S ); + alt->setShortcut ( Qt::Key_S ); // Scroll branch alt->setStatusTip (tr( "Scroll branch" )); connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); #if defined(Q_OS_MACX) @@ -583,7 +588,7 @@ a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this); a->setStatusTip (tr( "Find" ) ); - a->setShortcut (Qt::CTRL + Qt::Key_F ); + a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find editMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) ); @@ -779,10 +784,13 @@ connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); actionEditLoadImage=a; - a = new QAction( tr( "Properties","Context menu for images and branches" )+QString ("..."), this); - a->setStatusTip (tr( "Set properties for object" )); + a = new QAction( tr( "Property Dialog","Dialog to edit properties of selection" )+QString ("..."), this); + a->setStatusTip (tr( "Set properties for selection" )); + a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( showPropertyDialog() ) ); - actionOpenPropertyDialog=a; + actionTogglePropertyDialog=a; } // Format Actions @@ -813,7 +821,7 @@ a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this); a->setStatusTip ( tr( "Color branch" ) ); - a->setShortcut (Qt::CTRL + Qt::Key_I); + a->setShortcut (Qt::CTRL + Qt::Key_B); connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) ); a->setEnabled (false); a->addTo( tb ); @@ -893,6 +901,12 @@ connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) ); actionFormatLinkColor=a; + a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this ); + a->setStatusTip (tr( "Set Selection Color" )); + formatMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) ); + actionFormatSelectionColor=a; + a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this ); a->setStatusTip (tr( "Set Background Color" )); formatMenu->addAction (a); @@ -950,8 +964,8 @@ connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) ); actionViewToggleNoteEditor=a; - a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this ); - a->setStatusTip ( tr( "Show history window" )); + a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this ); + a->setStatusTip ( tr( "Show History Window" )); a->setShortcut ( Qt::CTRL + Qt::Key_H ); a->setToggleAction(true); a->addTo( tb ); @@ -959,6 +973,8 @@ connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); actionViewToggleHistoryWindow=a; + viewMenu->addAction (actionTogglePropertyDialog ); + a = new QAction(tr( "Antialiasing","View action" ),this ); a->setStatusTip ( tr( "Antialiasing" )); a->setToggleAction(true); @@ -1450,8 +1466,7 @@ // Context Menu for branch or mapcenter branchContextMenu =new QMenu (this); - - actionOpenPropertyDialog->addTo (branchContextMenu); + branchContextMenu->addAction (actionTogglePropertyDialog); branchContextMenu->addSeparator(); // Submenu "Add" @@ -1533,6 +1548,7 @@ canvasContextMenu->insertSeparator(); actionFormatLinkColorHint->addTo( canvasContextMenu ); actionFormatLinkColor->addTo( canvasContextMenu ); + actionFormatSelectionColor->addTo( canvasContextMenu ); actionFormatBackColor->addTo( canvasContextMenu ); actionFormatBackImage->addTo( canvasContextMenu ); @@ -2215,13 +2231,14 @@ QString dir=dia.getDir(); // Check, if warnings should be used before overwriting // the output directory - bool ok; - if (dia.warnings()) - ok=reallyWriteDirectory(dir); - else - ok=true; - - if (ok) + WarningDialog warn; + warn.showCancelButton (true); + warn.setText(QString( + "The directory %1 is not empty.\n" + "Do you risk to overwrite some of its contents?").arg(dir)); + warn.setCaption("Warning: Directory not empty"); + warn.setShowAgainName("mainwindow/overwrite-dir-xhtml"); + if (warn.exec()==QDialog::Accepted) { me->exportXML (dia.getDir() ); dia.doExport(me->getMapName() ); @@ -3067,6 +3084,12 @@ currentMapEditor()->selectMapLinkColor(); } +void Main::formatSelectSelectionColor() +{ + if (currentMapEditor()) + currentMapEditor()->selectMapSelectionColor(); +} + void Main::formatToggleLinkColorHint() { currentMapEditor()->toggleMapLinkColorHint(); @@ -3211,6 +3234,11 @@ currentMapEditor()->updateNoteFlag(); } +void Main::updateSatellites(MapEditor *me) +{ + branchPropertyWindow->setMapEditor (me); +} + void Main::updateActions() { MapEditor *me=currentMapEditor(); @@ -3220,6 +3248,7 @@ // updateActions is also called when NoteEditor is closed actionViewToggleNoteEditor->setOn (textEditor->showWithMain()); + actionViewToggleHistoryWindow->setOn (historyWindow->showWithMain()); if (me->getMapLinkColorHint()==HeadingColor) actionFormatLinkColorHint->setOn(true); @@ -3244,12 +3273,16 @@ break; } + // Update colors QPixmap pix( 16, 16 ); pix.fill( me->getMapBackgroundColor() ); actionFormatBackColor->setIconSet( pix ); + pix.fill( me->getSelectionColor() ); + actionFormatSelectionColor->setIconSet( pix ); pix.fill( me->getMapDefLinkColor() ); actionFormatLinkColor->setIconSet( pix ); + actionFileSave->setEnabled( me->isUnsaved() ); if (me->isUndoAvailable()) actionEditUndo->setEnabled( true);