diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-01-20 18:29:05 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-01-30 16:26:27 +0100 |
commit | bc1d6ddeb5076f68e0a758725a20c3f2a6d081f0 (patch) | |
tree | c730d9ffbe79b262fbe6962fa2daa3f14adf0fc5 /src/pdf/quick/qml | |
parent | 4f5f0705bc161ff95899fdb2c5fcdb4581bf15bb (diff) |
Add QPdfSelection and QQuickPdfSelection
So now you can select text by mouse-drag and copy it to the clipboard.
Task-number: QTBUG-77509
Change-Id: I689ee4158974de8bc541c319a5a5cc2f8f3c2ae6
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/pdf/quick/qml')
-rw-r--r-- | src/pdf/quick/qml/PdfPageView.qml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pdf/quick/qml/PdfPageView.qml b/src/pdf/quick/qml/PdfPageView.qml index b7f75f4c2..2f9c5ef99 100644 --- a/src/pdf/quick/qml/PdfPageView.qml +++ b/src/pdf/quick/qml/PdfPageView.qml @@ -51,10 +51,23 @@ Rectangle { property alias currentPage: image.currentFrame property alias pageCount: image.frameCount property alias searchString: searchModel.searchString + property alias selectedText: selection.text property alias status: image.status property real __pageScale: image.paintedWidth / document.pagePointSize(image.currentFrame).width + PdfSelection { + id: selection + document: paper.document + page: image.currentFrame + fromPoint: Qt.point(textSelectionDrag.centroid.pressPosition.x / paper.__pageScale, textSelectionDrag.centroid.pressPosition.y / paper.__pageScale) + toPoint: Qt.point(textSelectionDrag.centroid.position.x / paper.__pageScale, textSelectionDrag.centroid.position.y / paper.__pageScale) + hold: !textSelectionDrag.active && !tapHandler.pressed + } + function copySelectionToClipboard() { + selection.copyToClipboard() + } + PdfSearchModel { id: searchModel document: paper.document @@ -96,6 +109,14 @@ Rectangle { paths: searchModel.matchGeometry } } + ShapePath { + fillColor: "orange" + scale: Qt.size(paper.__pageScale, paper.__pageScale) + PathMultiline { + id: selectionBoundaries + paths: selection.geometry + } + } } PinchHandler { id: pinch @@ -116,4 +137,13 @@ Rectangle { acceptedButtons: Qt.MiddleButton snapMode: DragHandler.NoSnap } + DragHandler { + id: textSelectionDrag + acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus + target: null + } + TapHandler { + id: tapHandler + acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus + } } |