MCPcopy Create free account
hub / github.com/TeXworks/texworks / contextMenuEvent

Method contextMenuEvent

src/PDFDocumentWindow.cpp:958–992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

956}
957
958void PDFDocumentWindow::contextMenuEvent(QContextMenuEvent *event)
959{
960 Q_ASSERT(pdfWidget);
961
962 // If initiated with the mouse, only show the context menu if the user
963 // clicked inside the pdfWidget area
964 if (event->reason() == QContextMenuEvent::Mouse && !pdfWidget->rect().contains(pdfWidget->mapFrom(this, event->pos()))) {
965 TWScriptableWindow::contextMenuEvent(event);
966 return;
967 }
968
969 QMenu menu(this);
970
971 // Disarm the active tool (if any) as the menu will be highjacking all
972 // events. This will, e.g., close an open magnifier view, which would
973 // otherwise not receive a proper mouseReleaseEvent
974 pdfWidget->disarmTool();
975
976 if (_synchronizer && _synchronizer->isValid()) {
977 QAction *act = new QAction(tr("Jump to Source"), &menu);
978 act->setData(QVariant(event->pos()));
979 connect(act, &QAction::triggered, this, &PDFDocumentWindow::jumpToSource);
980 menu.addAction(act);
981 menu.addSeparator();
982 }
983
984 menu.addAction(actionZoom_In);
985 menu.addAction(actionZoom_Out);
986 menu.addAction(actionActual_Size);
987 menu.addAction(actionFit_to_Width);
988 menu.addAction(actionFit_to_Window);
989 menu.addAction(actionFit_to_Content_Width);
990
991 menu.exec(event->globalPos());
992}
993
994void PDFDocumentWindow::mouseMoveEvent(QMouseEvent *event)
995{

Callers

nothing calls this directly

Calls 6

containsMethod · 0.80
disarmToolMethod · 0.80
setDataMethod · 0.80
execMethod · 0.80
rectMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected