From bc1d6ddeb5076f68e0a758725a20c3f2a6d081f0 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 20 Jan 2020 18:29:05 +0100 Subject: 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 --- tests/manual/quick/pdf/withdoc.qml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/manual/quick/pdf/withdoc.qml b/tests/manual/quick/pdf/withdoc.qml index 0fed5b16e..fe3297ee8 100644 --- a/tests/manual/quick/pdf/withdoc.qml +++ b/tests/manual/quick/pdf/withdoc.qml @@ -51,6 +51,7 @@ import QtQuick 2.14 import QtQuick.Controls 2.14 import Qt.labs.platform 1.1 as Platform import QtQuick.Pdf 5.15 +import QtQuick.Shapes 1.14 import QtQuick.Window 2.14 Window { @@ -72,6 +73,15 @@ Window { onAccepted: doc.source = file } + PdfSelection { + id: selection + document: doc + page: image.currentFrame + fromPoint: dragHandler.centroid.pressPosition + toPoint: dragHandler.centroid.position + hold: !dragHandler.active + } + Column { id: column anchors.fill: parent @@ -149,6 +159,18 @@ Window { onActivated: Qt.quit() } } + + Shape { + anchors.fill: parent + opacity: 0.25 + ShapePath { + fillColor: "cyan" + PathMultiline { + id: selectionBoundaries + paths: selection.geometry + } + } + } } } } -- cgit v1.2.3 From ccbd6fbdbe071f42e1c060ca579786758701f358 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 15 Jan 2020 09:44:10 +0100 Subject: Add PdfLinkModel Internal links and web links populate the QALM, which can then be used to drive a Repeater to position highlight rectangles with TapHandlers, which will handle a click by jumping to the link destination. Fixes: QTBUG-77511 Change-Id: I3b5b96d6e82bfd578f31f631f24279173036a080 Reviewed-by: Leena Miettinen Reviewed-by: Michal Klocek --- tests/manual/quick/pdf/withdoc.qml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/manual/quick/pdf/withdoc.qml b/tests/manual/quick/pdf/withdoc.qml index fe3297ee8..2d82a6abf 100644 --- a/tests/manual/quick/pdf/withdoc.qml +++ b/tests/manual/quick/pdf/withdoc.qml @@ -171,6 +171,31 @@ Window { } } } + + Repeater { + model: PdfLinkModel { + id: linkModel + document: doc + page: image.currentFrame + } + delegate: Rectangle { + color: "transparent" + border.color: "lightgrey" + x: rect.x + y: rect.y + width: rect.width + height: rect.height +// HoverHandler { cursorShape: Qt.PointingHandCursor } // 5.15 onward (QTBUG-68073) + TapHandler { + onTapped: { + if (page >= 0) + image.currentFrame = page + else + Qt.openUrlExternally(url) + } + } + } + } } } } -- cgit v1.2.3