Skip to content

Commit

Permalink
Fix GitHub Issue #10: Zoom level changes on undo/redo
Browse files Browse the repository at this point in the history
  • Loading branch information
juzzlin committed Dec 11, 2018
1 parent 8d1bf5f commit 4ae1e8f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/editorview.cpp
Expand Up @@ -430,6 +430,8 @@ void EditorView::zoomToFit(QRectF nodeBoundingRect)
updateScale(m_scaleValue);

centerOn(nodeBoundingRect.center());

m_nodeBoundingRect = nodeBoundingRect;
}

EditorView::~EditorView()
Expand Down
2 changes: 2 additions & 0 deletions src/editorview.hpp
Expand Up @@ -144,6 +144,8 @@ public slots:

// Width for the dummy drag edge
double m_edgeWidth = 1.5;

QRectF m_nodeBoundingRect;
};

#endif // EDITORVIEW_HPP
6 changes: 5 additions & 1 deletion src/mediator.cpp
Expand Up @@ -411,6 +411,9 @@ void Mediator::setTextSize(int textSize)

void Mediator::setupMindMapAfterUndoOrRedo()
{
auto oldSceneRect = m_editorScene->sceneRect();
auto oldCenter = m_editorView->mapToScene(m_editorView->viewport()->rect()).boundingRect().center();

m_editorScene.reset(new EditorScene);
m_editorScene->initialize();

Expand All @@ -421,7 +424,8 @@ void Mediator::setupMindMapAfterUndoOrRedo()

connectGraphToUndoMechanism();

zoomToFit();
m_editorScene->setSceneRect(oldSceneRect);
m_editorView->centerOn(oldCenter);
}

void Mediator::undo()
Expand Down

0 comments on commit 4ae1e8f

Please sign in to comment.