diff -r 83a3be747ad9 -r 8b9cfc26638c mainwindow.cpp --- a/mainwindow.cpp Wed Apr 25 16:02:54 2007 +0000 +++ b/mainwindow.cpp Wed Apr 25 16:02:54 2007 +0000 @@ -98,6 +98,9 @@ // Initialize properties window branchPropertyWindow = new BranchPropertyWindow(); branchPropertyWindow->move (20,20); + branchPropertyWindow->resize (settings.value( "/branchpropertywindow/geometry/size",QSize (150,100)).toSize()); + branchPropertyWindow->move (settings.value( "/branchpropertywindow/geometry/pos", QPoint(20,20)).toPoint()); + // Initialize script editor scriptEditor = new SimpleScriptEditor(); @@ -201,12 +204,12 @@ settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); - //FIXME save branchPropWindow settings - //FIXME save scriptEditor settings + //TODO save scriptEditor settings // call the destructors delete textEditor; delete historyWindow; + delete branchPropertyWindow; // Remove temporary directory removeDir (QDir(tmpVymDir)); @@ -361,7 +364,7 @@ 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 ); //Close map + a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map fileMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); @@ -580,10 +583,10 @@ addAction (alt); actionListBranches.append(actionEditToggleScroll); - a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this); - a->setStatusTip (tr( "Unscroll all" )); + a = new QAction( tr( "Unscroll childs","Edit menu" ), this); + a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" )); editMenu->addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) ); editMenu->addSeparator(); @@ -785,13 +788,13 @@ connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); actionEditLoadImage=a; - a = new QAction( tr( "Property Dialog","Dialog to edit properties of selection" )+QString ("..."), this); + a = new QAction( tr( "Property window","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() ) ); - actionTogglePropertyDialog=a; + connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) ); + actionTogglePropertyWindow=a; } // Format Actions @@ -869,18 +872,6 @@ formatMenu->addAction (a); actionFormatLinkStylePolyParabel=a; - a = new QAction( tr( "Include images vertically","Branch attribute" ), this); - a->setStatusTip ( tr ("Include top and bottom position of images into branch")); - a->setToggleAction(true); - connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) ); - actionFormatIncludeImagesVer=a; - - a = new QAction( tr( "Include images horizontally","Branch attribute" ), this); - a->setStatusTip ( tr ("Include left and right position of images into branch")); - a->setToggleAction(true); - connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) ); - actionFormatIncludeImagesHor=a; - a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this); a->setStatusTip (tr( "Hide link" )); a->setToggleAction(true); @@ -974,7 +965,7 @@ connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); actionViewToggleHistoryWindow=a; - viewMenu->addAction (actionTogglePropertyDialog ); + viewMenu->addAction (actionTogglePropertyWindow); a = new QAction(tr( "Antialiasing","View action" ),this ); a->setStatusTip ( tr( "Antialiasing" )); @@ -992,13 +983,13 @@ connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) ); actionViewToggleSmoothPixmapTransform=a; - a = new QAction(tr( "Next Window","View action" ), this); + a = new QAction(tr( "Next Map","View action" ), this); a->setStatusTip (a->text()); a->setShortcut (Qt::ALT + Qt::Key_N ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) ); - a = new QAction (tr( "Previous Window","View action" ), this ); + a = new QAction (tr( "Previous Map","View action" ), this ); a->setStatusTip (a->text()); a->setShortcut (Qt::ALT + Qt::Key_P ); viewMenu->addAction (a); @@ -1375,12 +1366,34 @@ connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) ); settingsMenu->addAction (a); - a = new QAction( tr( "Set path for macros","Settings action"), this); + a = new QAction( tr( "Set path for macros","Settings action")+"...", this); a->setStatusTip( tr( "Set path for macros")); connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) ); settingsMenu->addAction (a); + a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this); + a->setStatusTip( tr( "Set number of undo levels")); + connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) ); + settingsMenu->addAction (a); + settingsMenu->addSeparator(); + + a = new QAction( tr( "Autosave","Settings action"), this); + a->setStatusTip( tr( "Autosave")); + a->setToggleAction(true); + a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool()); + connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) ); + settingsMenu->addAction (a); + actionSettingsAutosaveToggle=a; + + a = new QAction( tr( "Autosave time","Settings action")+"...", this); + a->setStatusTip( tr( "Autosave time")); + connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) ); + settingsMenu->addAction (a); + actionSettingsAutosaveTime=a; + + settingsMenu->addSeparator(); + a = new QAction( tr( "Edit branch after adding it","Settings action" ), this ); a->setStatusTip( tr( "Edit branch after adding it" )); a->setToggleAction(true); @@ -1472,7 +1485,7 @@ // Context Menu for branch or mapcenter branchContextMenu =new QMenu (this); - branchContextMenu->addAction (actionTogglePropertyDialog); + branchContextMenu->addAction (actionTogglePropertyWindow); branchContextMenu->addSeparator(); // Submenu "Add" @@ -1498,14 +1511,12 @@ branchContextMenu->addSeparator(); branchContextMenu->addAction ( actionEditLoadImage); - branchContextMenu->addAction ( actionFormatIncludeImagesVer ); - branchContextMenu->addAction ( actionFormatIncludeImagesHor ); // Submenu for Links (URLs, vymLinks) branchLinksContextMenu =new QMenu (this); branchContextMenu->addSeparator(); - branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name")); + branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name")); branchLinksContextMenu->addAction ( actionEditOpenURL ); branchLinksContextMenu->addAction ( actionEditOpenURLTab ); branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs ); @@ -1677,9 +1688,8 @@ { // Unselect all possibly selected objects // (Important to update note editor) - int i; MapEditor *me; - for (i=0;i<=tabWidget->count() -1;i++) + for (int i=0;i<=tabWidget->count() -1;i++) { me=(MapEditor*)tabWidget->page(i); @@ -1972,7 +1982,7 @@ setupRecentMapsMenu(); } -void Main::fileSave(const SaveMode &savemode) +void Main::fileSave(MapEditor *me, const SaveMode &savemode) { // tmp dir for zipping QString tmpMapDir; @@ -1982,13 +1992,12 @@ QString safeFilePath; - bool saveZipped=currentMapEditor()->saveZipped(); - - MapEditor * me=currentMapEditor(); + bool saveZipped=me->saveZipped(); + if (me) { QString fn=me->getFilePath(); - // filename=unnamed, filepath="" in constructor... + // filename=unnamed, filepath="" in constructor of mapEditor if ( !fn.isEmpty() ) { // We have a filepath, go on saving @@ -2067,6 +2076,8 @@ // We have no filepath yet, // call fileSaveAs() now, this will call fileSave() // again. + // First switch to editor + tabWidget->setCurrentWidget (me); fileSaveAs(savemode); } } @@ -2089,7 +2100,12 @@ void Main::fileSave() { - fileSave (CompleteMap); + fileSave (currentMapEditor(), CompleteMap); +} + +void Main::fileSave(MapEditor *me) +{ + fileSave (me,CompleteMap); } void Main::fileSaveAs(const SaveMode& savemode) @@ -2145,7 +2161,7 @@ // Save now currentMapEditor()->setFilePath(fn); - fileSave(savemode); + fileSave(currentMapEditor(), savemode); // Set name of tab if (savemode==CompleteMap) @@ -2415,7 +2431,7 @@ { case QMessageBox::Yes: // save and close - fileSave(CompleteMap); + fileSave(currentMapEditor(), CompleteMap); break; case QMessageBox::No: // close without saving @@ -2466,7 +2482,7 @@ switch( mb.exec() ) { case QMessageBox::Yes: // save (the changed editors) and exit - fileSave(CompleteMap); + fileSave(currentMapEditor(), CompleteMap); break; case QMessageBox::No: // exit without saving @@ -2846,7 +2862,7 @@ } } -void Main::editUnScrollAll() +void Main::editUnscrollChilds() { if (currentMapEditor()) currentMapEditor()->unscrollChilds(); @@ -3124,18 +3140,6 @@ } -void Main::formatIncludeImagesVer() -{ - if (currentMapEditor()) - currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn()); -} - -void Main::formatIncludeImagesHor() -{ - if (currentMapEditor()) - currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn()); -} - void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog { if (currentMapEditor()) @@ -3213,6 +3217,39 @@ settings.setValue ("/macros/macroDir",dir.path()); } +void Main::settingsUndoLevels() +{ + bool ok; + int i = QInputDialog::getInteger( + this, + tr("QInputDialog::getInteger()"), + tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok); + if (ok) + { + settings.setValue ("/mapeditor/stepsTotal",i); + QMessageBox::information( this, tr( "VYM -Information:" ), + tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); + } +} + +void Main::settingsAutosaveToggle() +{ + settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() ); +} + +void Main::settingsAutosaveTime() +{ + bool ok; + int i = QInputDialog::getInteger( + this, + tr("QInputDialog::getInteger()"), + tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok); + if (ok) + { + settings.setValue ("/mapeditor/autosave/ms",i * 1000); + } +} + void Main::settingsToggleDelKey() { if (actionSettingsUseDelKey->isOn()) @@ -3241,6 +3278,27 @@ } +void Main::windowToggleProperty() +{ + if (branchPropertyWindow->isVisible()) + branchPropertyWindow->hide(); + else + branchPropertyWindow->show(); + if(currentMapEditor()) + { + LinkableMapObj *sel=currentMapEditor()->getSelection(); + if (sel && (typeid(*sel) == typeid(BranchObj) || + typeid(*sel) == typeid(MapCenterObj))) + { + branchPropertyWindow->setMapEditor(currentMapEditor()); + branchPropertyWindow->setBranch((BranchObj*)sel); + return; + } + + } + branchPropertyWindow->setBranch(NULL); +} + void Main::windowToggleAntiAlias() { bool b=actionViewToggleAntiAlias->isOn(); @@ -3293,23 +3351,23 @@ actionViewToggleNoteEditor->setOn (textEditor->showWithMain()); actionViewToggleHistoryWindow->setOn (historyWindow->showWithMain()); - if (me->getMapLinkColorHint()==HeadingColor) + if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor) actionFormatLinkColorHint->setOn(true); else actionFormatLinkColorHint->setOn(false); switch (me->getMapLinkStyle()) { - case StyleLine: + case LinkableMapObj::Line: actionFormatLinkStyleLine->setOn(true); break; - case StyleParabel: + case LinkableMapObj::Parabel: actionFormatLinkStyleParabel->setOn(true); break; - case StylePolyLine: + case LinkableMapObj::PolyLine: actionFormatLinkStylePolyLine->setOn(true); break; - case StylePolyParabel: + case LinkableMapObj::PolyParabel: actionFormatLinkStylePolyParabel->setOn(true); break; default: @@ -3419,10 +3477,6 @@ for (int i=0; isetEnabled(true); actionEditDelete->setEnabled (true); - actionFormatIncludeImagesVer->setOn - ( ((BranchObj*)selection)->getIncludeImagesVer()); - actionFormatIncludeImagesHor->setOn - ( ((BranchObj*)selection)->getIncludeImagesHor()); actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected()); } @@ -3469,7 +3523,7 @@ } } -ModMode Main::getModMode() +Main::ModMode Main::getModMode() { if (actionModModeColor->isOn()) return ModModeColor; if (actionModModeCopy->isOn()) return ModModeCopy; @@ -3517,24 +3571,6 @@ currentMapEditor()->runScript (script); } -void Main::showPropertyDialog() -{ - if(currentMapEditor()) - { - LinkableMapObj *sel=currentMapEditor()->getSelection(); - if (sel && (typeid(*sel) == typeid(BranchObj) || - typeid(*sel) == typeid(MapCenterObj))) - { - branchPropertyWindow->show(); - branchPropertyWindow->setMapEditor(currentMapEditor()); - branchPropertyWindow->setBranch((BranchObj*)sel); - return; - } - - } - branchPropertyWindow->setBranch(NULL); -} - void Main::windowNextEditor() { if (tabWidget->currentPageIndex() < tabWidget->count())