From f6b58ed804b70a953888f3c009c9fd351fb4c913 Mon Sep 17 00:00:00 2001 From: Gerd Wachsmuth Date: Thu, 1 Apr 2021 13:22:10 +0200 Subject: [PATCH 1/2] Fix bug: select browse tool after trim select --- autotests/parttest.cpp | 16 ++++++++++++++-- part/pageview.cpp | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/autotests/parttest.cpp b/autotests/parttest.cpp index 2722a265a..a527ca0d8 100644 --- a/autotests/parttest.cpp +++ b/autotests/parttest.cpp @@ -2129,11 +2129,20 @@ void PartTest::testLinkWithCrop() // wait for pixmap QTRY_VERIFY(part.m_document->page(0)->hasPixmap(part.m_pageView)); + const int width = part.m_pageView->viewport()->width(); + const int height = part.m_pageView->viewport()->height(); + + // Move to a location without a link + QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.1, width * 0.1)); + + // The cursor should be normal + QCOMPARE(part.m_pageView->cursor().shape(), Qt::CursorShape(Qt::OpenHandCursor)); + // Activate "Trim Margins" cropAction->trigger(); - const int width = part.m_pageView->viewport()->width(); - const int height = part.m_pageView->viewport()->height(); + // The cursor should be a cross-hair + QCOMPARE(part.m_pageView->cursor().shape(), Qt::CursorShape(Qt::CrossCursor)); const int mouseStartY = height * 0.2; const int mouseEndY = height * 0.8; @@ -2143,6 +2152,9 @@ void PartTest::testLinkWithCrop() // Trim the page simulateMouseSelection(mouseStartX, mouseStartY, mouseEndX, mouseEndY, part.m_pageView->viewport()); + // The cursor should be normal again + QCOMPARE(part.m_pageView->cursor().shape(), Qt::CursorShape(Qt::OpenHandCursor)); + // Click a link const QPoint click(width * 0.2, height * 0.2); QTest::mouseMove(part.m_pageView->viewport(), click); diff --git a/part/pageview.cpp b/part/pageview.cpp index 88e28a46d..1e6c79f09 100644 --- a/part/pageview.cpp +++ b/part/pageview.cpp @@ -4961,7 +4961,10 @@ void PageView::slotTrimToSelectionToggled(bool on) if (on) { // Turn off any other Trim modes updateTrimMode(d->aTrimToSelection->data().toInt()); + // Change the mouse mode d->mouseMode = Okular::Settings::EnumMouseMode::TrimSelect; + d->aMouseNormal->setChecked(false); + // change the text in messageWindow (and show it if hidden) d->messageWindow->display(i18n("Draw a rectangle around the page area you wish to keep visible"), QString(), PageViewMessage::Info, -1); // force an update of the cursor From 72658e0ec389338baccd78af97183427e247636a Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 6 May 2021 23:07:57 +0200 Subject: [PATCH 2/2] Fix saving signed revisions of a signature We don't need a QDataStream to assign a QByteArray to a QByteArray, and it was adding some noise at the beginning which is clearly not what we want --- core/document.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/document.cpp b/core/document.cpp index 9fb5bce1b..4370ac7a2 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -4921,9 +4921,7 @@ QByteArray Document::requestSignedRevisionData(const Okular::SignatureInfo &info const QList byteRange = info.signedRangeBounds(); f.seek(byteRange.first()); - QByteArray data; - QDataStream stream(&data, QIODevice::WriteOnly); - stream << f.read(byteRange.last() - byteRange.first()); + QByteArray data = f.read(byteRange.last() - byteRange.first()); f.close(); return data;