diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-04-06 13:45:54 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-04-20 02:36:55 +0200 |
commit | 8a636811fc2478c836988793766006b99b821ea4 (patch) | |
tree | 815a587dc69b5db91306409b5ab88e7653dc906e /src/pdfquick | |
parent | 4ca817f60373576b54330161357efce099147bb0 (diff) | |
download | qtwebengine-8a636811fc2478c836988793766006b99b821ea4.tar.gz |
QtPDF: Get styles working again; remove visible hyperlink adornments
Update to versionless imports. The color type comes from the QtQuick
import now. Add the styles to CMakeLists.txt so they get installed.
Use SystemPalette rather than instantiating a Control.
We'd probably better just assume that the PDF has hyperlinks decorated
however the author wanted, rather than risking redundant underlines.
Declare linkUnderscoreStrokeWidth: -1 since the ShapePath.strokeWidth
docs tell us "When set to a negative value, no stroking occurs."
But the user can turn them back on using a custom style.
Update the screenshot: avoid showing off how bad the underscores looked.
PdfPageView doesn't depend on Controls and doesn't import styles:
it simply loses the light-grey rectangles around links. The cursor
change still informs the user when the mouse is hovering a link.
Pick-to: 6.3
Fixes: QTBUG-102303
Change-Id: Ifa4f9982bfaaf0e2e46230e8dbe30a5db7c9f592
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/pdfquick')
-rw-r--r-- | src/pdfquick/+Material/PdfStyle.qml | 19 | ||||
-rw-r--r-- | src/pdfquick/+Universal/PdfStyle.qml | 20 | ||||
-rw-r--r-- | src/pdfquick/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/pdfquick/PdfPageView.qml | 4 | ||||
-rw-r--r-- | src/pdfquick/PdfStyle.qml | 19 |
5 files changed, 30 insertions, 37 deletions
diff --git a/src/pdfquick/+Material/PdfStyle.qml b/src/pdfquick/+Material/PdfStyle.qml index 6ec0741b4..0d2b9cb1f 100644 --- a/src/pdfquick/+Material/PdfStyle.qml +++ b/src/pdfquick/+Material/PdfStyle.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -36,22 +36,21 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQml 2.14 -import QtQuick.Controls 2.14 -import QtQuick.Controls.Material 2.14 -import QtQuick.Shapes 1.14 +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Shapes QtObject { - property Control prototypeControl: Control { } + property SystemPalette palette: SystemPalette { } function withAlpha(color, alpha) { return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha) } - property color selectionColor: withAlpha(prototypeControl.palette.highlight, 0.5) + property color selectionColor: withAlpha(palette.highlight, 0.5) property color pageSearchResultsColor: withAlpha(Qt.lighter(Material.accentColor, 1.5), 0.5) property color currentSearchResultStrokeColor: Material.accentColor property real currentSearchResultStrokeWidth: 2 - property color linkUnderscoreColor: prototypeControl.palette.link - property real linkUnderscoreStrokeWidth: 1 - property var linkUnderscoreStrokeStyle: ShapePath.DashLine + property color linkUnderscoreColor: palette.link + property real linkUnderscoreStrokeWidth: -1 // no underlines under hyperlinks + property int linkUnderscoreStrokeStyle: ShapePath.DashLine property var linkUnderscoreDashPattern: [ 1, 4 ] } diff --git a/src/pdfquick/+Universal/PdfStyle.qml b/src/pdfquick/+Universal/PdfStyle.qml index 3c322359a..c2d044f1d 100644 --- a/src/pdfquick/+Universal/PdfStyle.qml +++ b/src/pdfquick/+Universal/PdfStyle.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -36,23 +36,21 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQml 2.14 -import QtQuick 2.14 -import QtQuick.Controls 2.14 -import QtQuick.Controls.Universal 2.14 -import QtQuick.Shapes 1.14 +import QtQuick +import QtQuick.Controls.Universal +import QtQuick.Shapes QtObject { - property Control prototypeControl: Control { } + property SystemPalette palette: SystemPalette { } function withAlpha(color, alpha) { return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha) } - property color selectionColor: withAlpha(prototypeControl.palette.highlight, 0.5) + property color selectionColor: withAlpha(palette.highlight, 0.5) property color pageSearchResultsColor: withAlpha(Qt.lighter(Universal.accent, 1.5), 0.5) property color currentSearchResultStrokeColor: Universal.accent property real currentSearchResultStrokeWidth: 2 - property color linkUnderscoreColor: prototypeControl.palette.link - property real linkUnderscoreStrokeWidth: 1 - property var linkUnderscoreStrokeStyle: ShapePath.DashLine + property color linkUnderscoreColor: palette.link + property real linkUnderscoreStrokeWidth: -1 // no underlines under hyperlinks + property int linkUnderscoreStrokeStyle: ShapePath.DashLine property var linkUnderscoreDashPattern: [ 1, 4 ] } diff --git a/src/pdfquick/CMakeLists.txt b/src/pdfquick/CMakeLists.txt index 71ad29ed9..b29f57aeb 100644 --- a/src/pdfquick/CMakeLists.txt +++ b/src/pdfquick/CMakeLists.txt @@ -1,9 +1,8 @@ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Qml Quick) set(qml_files -# TODO: -# "+Material/PdfStyle.qml" -# "+Universal/PdfStyle.qml" + "+Material/PdfStyle.qml" + "+Universal/PdfStyle.qml" "PdfMultiPageView.qml" "PdfPageView.qml" "PdfScrollablePageView.qml" diff --git a/src/pdfquick/PdfPageView.qml b/src/pdfquick/PdfPageView.qml index 39fb896fb..91c71f1d3 100644 --- a/src/pdfquick/PdfPageView.qml +++ b/src/pdfquick/PdfPageView.qml @@ -217,9 +217,7 @@ Rectangle { document: root.document page: navigationStack.currentPage } - delegate: Rectangle { - color: "transparent" - border.color: "lightgrey" + delegate: Item { x: rect.x * image.pageScale y: rect.y * image.pageScale width: rect.width * image.pageScale diff --git a/src/pdfquick/PdfStyle.qml b/src/pdfquick/PdfStyle.qml index 55e9ca3c9..5ce2d436c 100644 --- a/src/pdfquick/PdfStyle.qml +++ b/src/pdfquick/PdfStyle.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -36,22 +36,21 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQml 2.14 -import QtQuick 2.14 -import QtQuick.Controls 2.14 -import QtQuick.Shapes 1.14 +import QtQuick +import QtQuick.Controls +import QtQuick.Shapes QtObject { - property Control prototypeControl: Control { } + property SystemPalette palette: SystemPalette { } function withAlpha(color, alpha) { return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha) } - property color selectionColor: withAlpha(prototypeControl.palette.highlight, 0.5) + property color selectionColor: withAlpha(palette.highlight, 0.5) property color pageSearchResultsColor: "#80B0C4DE" property color currentSearchResultStrokeColor: "cyan" property real currentSearchResultStrokeWidth: 2 - property color linkUnderscoreColor: prototypeControl.palette.link - property real linkUnderscoreStrokeWidth: 1 - property var linkUnderscoreStrokeStyle: ShapePath.DashLine + property color linkUnderscoreColor: palette.link + property real linkUnderscoreStrokeWidth: -1 // no underlines under hyperlinks + property int linkUnderscoreStrokeStyle: ShapePath.DashLine property var linkUnderscoreDashPattern: [ 1, 4 ] } |