|
20 | 20 | */ |
21 | 21 |
|
22 | 22 | #ifndef NO_POPPLER_PREVIEW |
23 | | - |
24 | 23 | #include "PDFDocument.h" |
25 | 24 | #include "PDFDocks.h" |
26 | 25 | //#include "FindDialog.h" |
@@ -1059,6 +1058,13 @@ void PDFWidget::openAnnotationDialog(const PDFAnnotation *annon) |
1059 | 1058 | dlg->show(); |
1060 | 1059 | } |
1061 | 1060 |
|
| 1061 | +void PDFWidget::callGetPosFromClick(const QPoint &p){ |
| 1062 | + int page = pageFromPos(p); |
| 1063 | + if (page < 0) return; |
| 1064 | + QRect r = pageRect(page); |
| 1065 | + emit getPosFromCLick(QPointF(p - r.topLeft()) / totalScaleFactor()); |
| 1066 | +} |
| 1067 | + |
1062 | 1068 | void PDFWidget::mouseReleaseEvent(QMouseEvent *event) |
1063 | 1069 | { |
1064 | 1070 | if (pdfdocument && pdfdocument->embeddedMode) |
@@ -1092,11 +1098,17 @@ void PDFWidget::mouseReleaseEvent(QMouseEvent *event) |
1092 | 1098 | else if (event->button() == Qt::RightButton) goPrev(); |
1093 | 1099 | break; |
1094 | 1100 | } |
| 1101 | + // ctrl-shift-click to get position |
| 1102 | + if ((mouseDownModifiers & Qt::ControlModifier) && (mouseDownModifiers & Qt::ShiftModifier)) { |
| 1103 | + if ((event->modifiers() & Qt::ControlModifier) && (event->modifiers() & Qt::ShiftModifier)) { |
| 1104 | + callGetPosFromClick(event->pos()); |
| 1105 | + } |
| 1106 | + break; |
| 1107 | + } |
1095 | 1108 | // Ctrl-click to sync |
1096 | 1109 | if (mouseDownModifiers & Qt::ControlModifier) { |
1097 | 1110 | if (event->modifiers() & Qt::ControlModifier) |
1098 | 1111 | syncWindowClick(event->pos(), true); |
1099 | | - |
1100 | 1112 | break; |
1101 | 1113 | } |
1102 | 1114 | // check whether to zoom |
@@ -1498,6 +1510,8 @@ void PDFWidget::syncWindowClick(const QPoint &p, bool activate) |
1498 | 1510 |
|
1499 | 1511 | } |
1500 | 1512 |
|
| 1513 | + |
| 1514 | + |
1501 | 1515 | void PDFWidget::syncCurrentPage(bool activate) |
1502 | 1516 | { |
1503 | 1517 | if (pages.isEmpty()) return; |
@@ -2733,7 +2747,21 @@ void PDFDocument::setupMenus(bool embedded) |
2733 | 2747 |
|
2734 | 2748 | configManager->modifyManagedShortcuts("pdf"); |
2735 | 2749 | } |
2736 | | - |
| 2750 | +/* |
| 2751 | + * Copies to clipboard position in cm captured from the pdf viewer (w.r.t. south west corner) |
| 2752 | + */ |
| 2753 | +void PDFDocument::getPosFromCLick(const QPointF &pos) |
| 2754 | +{ |
| 2755 | + int page = pdfWidget->pageFromPos(pos.toPoint()); |
| 2756 | + if (page < 0) return; |
| 2757 | + float height = (pdfWidget->pageRect(page).height()/pdfWidget->totalScaleFactor()) / 28.45; |
| 2758 | + QClipboard *clipboard = QGuiApplication::clipboard(); |
| 2759 | + QString tmp; |
| 2760 | + QTextStream(&tmp) << "" << pos.x() / 28.45 << "," << height- pos.y() / 28.45; |
| 2761 | + clipboard->setText(tmp); |
| 2762 | + //qDebug() << "Position: " << qPrintable(tmp) << "\n"; |
| 2763 | + |
| 2764 | +} |
2737 | 2765 | /*! |
2738 | 2766 | * \brief the shortcuts will only be triggered if this widget has focus (used in embedded mode) |
2739 | 2767 | * \param actions |
@@ -2994,6 +3022,7 @@ void PDFDocument::init(bool embedded) |
2994 | 3022 | connect(pdfWidget, SIGNAL(changedZoom(qreal)), this, SLOT(enableZoomActions(qreal))); |
2995 | 3023 | connect(pdfWidget, SIGNAL(changedScaleOption(autoScaleOption)), this, SLOT(adjustScaleActions(autoScaleOption))); |
2996 | 3024 | connect(pdfWidget, SIGNAL(syncClick(int,const QPointF&,bool)), this, SLOT(syncClick(int,const QPointF&,bool))); |
| 3025 | + connect(pdfWidget, SIGNAL(getPosFromCLick(const QPointF&)), this, SLOT(getPosFromCLick(const QPointF&))); |
2997 | 3026 |
|
2998 | 3027 | if (actionZoom_In->shortcut() == QKeySequence("Ctrl++")) |
2999 | 3028 | new QShortcut(QKeySequence("Ctrl+="), pdfWidget, SLOT(zoomIn()), Q_NULLPTR, Qt::WidgetShortcut); |
|
0 commit comments