From eb4a66480356356b19969f13553e4179b24c4041 Mon Sep 17 00:00:00 2001
From: Shawn Rutledge <shawn.rutledge@qt.io>
Date: Sat, 29 Feb 2020 23:29:43 +0100
Subject: [PATCH] Render PDF link decorations as dashed underlines rather than
 boxes

So they look more like (old-school) web links.
The underlines are always horizontal and underneath the area of
occurrence though; rotated link text has not been tested.

Change-Id: I4fc01d88367b0cc9bbc23e9f85a3b42efb271fb8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
---
 src/pdf/quick/qml/PdfMultiPageView.qml      | 12 +++++++++---
 src/pdf/quick/qml/PdfScrollablePageView.qml | 12 +++++++++---
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml
index de61f1782..9d9e2800a 100644
--- a/src/pdf/quick/qml/PdfMultiPageView.qml
+++ b/src/pdf/quick/qml/PdfMultiPageView.qml
@@ -282,13 +282,19 @@ Item {
                         document: root.document
                         page: image.currentFrame
                     }
-                    delegate: Rectangle {
-                        color: "transparent"
-                        border.color: "lightgrey"
+                    delegate: Shape {
                         x: rect.x * paper.pageScale
                         y: rect.y * paper.pageScale
                         width: rect.width * paper.pageScale
                         height: rect.height * paper.pageScale
+                        ShapePath {
+                            strokeWidth: 1
+                            strokeColor: "steelblue"
+                            strokeStyle: ShapePath.DashLine
+                            dashPattern: [ 1, 4 ]
+                            startX: 0; startY: height
+                            PathLine { x: width; y: height }
+                        }
                         MouseArea { // TODO switch to TapHandler / HoverHandler in 5.15
                             id: linkMA
                             anchors.fill: parent
diff --git a/src/pdf/quick/qml/PdfScrollablePageView.qml b/src/pdf/quick/qml/PdfScrollablePageView.qml
index e27b21d14..2d335849d 100644
--- a/src/pdf/quick/qml/PdfScrollablePageView.qml
+++ b/src/pdf/quick/qml/PdfScrollablePageView.qml
@@ -213,13 +213,19 @@ Flickable {
                     document: root.document
                     page: navigationStack.currentPage
                 }
-                delegate: Rectangle {
-                    color: "transparent"
-                    border.color: "lightgrey"
+                delegate: Shape {
                     x: rect.x * image.pageScale
                     y: rect.y * image.pageScale
                     width: rect.width * image.pageScale
                     height: rect.height * image.pageScale
+                    ShapePath {
+                        strokeWidth: 1
+                        strokeColor: "steelblue"
+                        strokeStyle: ShapePath.DashLine
+                        dashPattern: [ 1, 4 ]
+                        startX: 0; startY: height
+                        PathLine { x: width; y: height }
+                    }
                     MouseArea { // TODO switch to TapHandler / HoverHandler in 5.15
                         anchors.fill: parent
                         cursorShape: Qt.PointingHandCursor
-- 
GitLab