mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-01 15:24:13 +02:00
Merge pull request #1190 from ispyisail/feature/center-on-cursor
Add a Centre on cursor command to move around a zoomed-in folio
This commit is contained in:
@@ -509,6 +509,22 @@ void DiagramView::zoomToRect(const QRectF &rect)
|
||||
adjustGridToZoom();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief DiagramView::centerOnCursor
|
||||
Scroll the view so the point under the mouse cursor becomes the centre
|
||||
of the view, keeping the current zoom.
|
||||
Does nothing when the cursor is not over the view, e.g. when the action
|
||||
is triggered from a menu.
|
||||
*/
|
||||
void DiagramView::centerOnCursor()
|
||||
{
|
||||
const QPoint local = viewport()->mapFromGlobal(QCursor::pos());
|
||||
if (!viewport()->rect().contains(local)) {
|
||||
return;
|
||||
}
|
||||
centerOn(mapToScene(local));
|
||||
}
|
||||
|
||||
/**
|
||||
Copie les elements selectionnes du schema dans le presse-papier puis les supprime
|
||||
Copies the selected elements from the diagram to the clipboard and then deletes them
|
||||
|
||||
@@ -185,6 +185,7 @@ class DiagramView : public PaletteGraphicsView
|
||||
void zoomContent();
|
||||
void zoomReset();
|
||||
void zoomToRect(const QRectF &rect);
|
||||
void centerOnCursor();
|
||||
void cut();
|
||||
void copy();
|
||||
void paste(const QPointF & = QPointF(), QClipboard::Mode = QClipboard::Clipboard);
|
||||
|
||||
@@ -1000,6 +1000,7 @@ void QETDiagramEditor::setUpActions()
|
||||
QAction *zoom_content = m_zoom_actions_group.addAction( QET::Icons::ZoomDraw, tr("Zoom sur le contenu"));
|
||||
QAction *zoom_fit = m_zoom_actions_group.addAction( QET::Icons::ZoomFitBest, tr("Zoom adapté"));
|
||||
QAction *zoom_reset = m_zoom_actions_group.addAction( QET::Icons::ZoomOriginal, tr("Pas de zoom"));
|
||||
QAction *center_on_cursor = m_zoom_actions_group.addAction(tr("Centrer sur le curseur"));
|
||||
m_zoom_action_toolBar << zoom_content << zoom_fit << zoom_reset;
|
||||
|
||||
ShortcutManager::instance().registerAction(zoom_in, "diagrameditor.zoom_in", tr("Éditeur de schémas"), QKeySequence::ZoomIn);
|
||||
@@ -1007,18 +1008,21 @@ void QETDiagramEditor::setUpActions()
|
||||
ShortcutManager::instance().registerAction(zoom_content, "diagrameditor.zoom_content", tr("Éditeur de schémas"), Qt::CTRL | Qt::Key_8);
|
||||
ShortcutManager::instance().registerAction(zoom_fit, "diagrameditor.zoom_fit", tr("Éditeur de schémas"), Qt::CTRL | Qt::Key_9);
|
||||
ShortcutManager::instance().registerAction(zoom_reset, "diagrameditor.zoom_reset", tr("Éditeur de schémas"), Qt::CTRL | Qt::Key_0);
|
||||
ShortcutManager::instance().registerAction(center_on_cursor, "diagrameditor.center_on_cursor", tr("Éditeur de schémas"), QKeySequence());
|
||||
|
||||
zoom_in ->setStatusTip(tr("Agrandit le folio", "status bar tip"));
|
||||
zoom_out ->setStatusTip(tr("Rétrécit le folio", "status bar tip"));
|
||||
zoom_content->setStatusTip(tr("Adapte le zoom de façon à afficher tout le contenu du folio indépendamment du cadre"));
|
||||
zoom_fit ->setStatusTip(tr("Adapte le zoom exactement sur le cadre du folio", "status bar tip"));
|
||||
zoom_reset ->setStatusTip(tr("Restaure le zoom par défaut", "status bar tip"));
|
||||
center_on_cursor->setStatusTip(tr("Centre le folio sur le point sous le curseur de la souris, sans changer le zoom", "status bar tip"));
|
||||
|
||||
zoom_in ->setData("zoom_in");
|
||||
zoom_out ->setData("zoom_out");
|
||||
zoom_content->setData("zoom_content");
|
||||
zoom_fit ->setData("zoom_fit");
|
||||
zoom_reset ->setData("zoom_reset");
|
||||
center_on_cursor->setData("center_on_cursor");
|
||||
|
||||
connect(&m_zoom_actions_group, &QActionGroup::triggered, this, &QETDiagramEditor::zoomGroupTriggered);
|
||||
|
||||
@@ -1944,6 +1948,8 @@ void QETDiagramEditor::zoomGroupTriggered(QAction *action)
|
||||
dv->zoomFit();
|
||||
else if (value == "zoom_reset")
|
||||
dv->zoomReset();
|
||||
else if (value == "center_on_cursor")
|
||||
dv->centerOnCursor();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user