diff options
author | Jochen Becher <jochen_becher@gmx.de> | 2016-06-21 21:27:43 +0200 |
---|---|---|
committer | Jochen Becher <jochen_becher@gmx.de> | 2016-06-24 16:58:30 +0000 |
commit | 80e5259999e1fc02a59c7529bdf457c504e25867 (patch) | |
tree | df95647160aa8cdbaa03f7dbc30c5cb4864e36a9 /src/plugins/modeleditor/actionhandler.cpp | |
parent | 9ccb08987043b82ccec3e545f1556fa2f4fb32ec (diff) |
ModelEditor: Implement zoom of diagrams.
All elements of a zoomed diagram must be dran anti-aliased. This change
removes the extra handling of drawing vertical or horizontal lines
without anti-alias. The complete graphics view is drawn anti-aliased
instead.
Change-Id: I6fc041b6d70da5a7a7bcb8e97d07990517380b90
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/modeleditor/actionhandler.cpp')
-rw-r--r-- | src/plugins/modeleditor/actionhandler.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/plugins/modeleditor/actionhandler.cpp b/src/plugins/modeleditor/actionhandler.cpp index 97b5829552..a2dabcfdcd 100644 --- a/src/plugins/modeleditor/actionhandler.cpp +++ b/src/plugins/modeleditor/actionhandler.cpp @@ -54,6 +54,9 @@ public: QAction *selectAllAction = 0; QAction *openParentDiagramAction = 0; QAction *exportDiagramAction = 0; + QAction *zoomInAction = 0; + QAction *zoomOutAction = 0; + QAction *resetZoomAction = 0; }; ActionHandler::ActionHandler(const Core::Context &context, QObject *parent) @@ -118,6 +121,21 @@ QAction *ActionHandler::exportDiagramAction() const return d->exportDiagramAction; } +QAction *ActionHandler::zoomInAction() const +{ + return d->zoomInAction; +} + +QAction *ActionHandler::zoomOutAction() const +{ + return d->zoomOutAction; +} + +QAction *ActionHandler::resetZoom() const +{ + return d->resetZoomAction; +} + void ActionHandler::createActions() { Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT); @@ -150,6 +168,26 @@ void ActionHandler::createActions() menuModelEditor->addAction(exportDiagramCommand); d->exportDiagramAction = exportDiagramCommand->action(); + menuModelEditor->addSeparator(d->context); + + Core::Command *zoomInCommand = registerCommand( + Constants::ZOOM_IN, [this]() { zoomIn(); }, d->context, true, + tr("Zoom In"), QKeySequence(QStringLiteral("Ctrl++"))); + menuModelEditor->addAction(zoomInCommand); + d->zoomInAction = zoomInCommand->action(); + + Core::Command *zoomOutCommand = registerCommand( + Constants::ZOOM_OUT, [this]() { zoomOut(); }, d->context, true, + tr("Zoom Out"), QKeySequence(QStringLiteral("Ctrl+-"))); + menuModelEditor->addAction(zoomOutCommand); + d->zoomOutAction = zoomOutCommand->action(); + + Core::Command *resetZoomCommand = registerCommand( + Constants::RESET_ZOOM, [this]() { resetZoom(); }, d->context, true, + tr("Reset Zoom"), QKeySequence(QStringLiteral("Ctrl+0"))); + menuModelEditor->addAction(resetZoomCommand); + d->zoomOutAction = resetZoomCommand->action(); + d->openParentDiagramAction = registerCommand( Constants::OPEN_PARENT_DIAGRAM, [this]() { openParentDiagram(); }, Core::Context(), true, tr("Open Parent Diagram"), QKeySequence(QStringLiteral("Ctrl+Shift+P")))->action(); @@ -256,6 +294,27 @@ void ActionHandler::exportDiagram() editor->exportDiagram(); } +void ActionHandler::zoomIn() +{ + auto editor = qobject_cast<ModelEditor *>(Core::EditorManager::currentEditor()); + if (editor) + editor->zoomIn(); +} + +void ActionHandler::zoomOut() +{ + auto editor = qobject_cast<ModelEditor *>(Core::EditorManager::currentEditor()); + if (editor) + editor->zoomOut(); +} + +void ActionHandler::resetZoom() +{ + auto editor = qobject_cast<ModelEditor *>(Core::EditorManager::currentEditor()); + if (editor) + editor->resetZoom(); +} + Core::Command *ActionHandler::registerCommand(const Core::Id &id, const std::function<void()> &slot, const Core::Context &context, bool scriptable, const QString &title, const QKeySequence &keySequence) |