From 8b3dfcb3f4ea97512b5940be69bfad9cc7fe6ac5 Mon Sep 17 00:00:00 2001 From: Mahmoud Khalil Date: Fri, 1 Oct 2021 16:04:50 +0000 Subject: [PATCH] PDF: Add Stamps to the file properly By using Poppler 20.10 new custom image stamps APIs Instead of the incompatible hack we used before that only worked for Okular. This is done by modifying the update function used by PopplerAnnotationProxy in order to load the image in the correct dimensions and send it to the poppler-Qt5 frontend. We temporarily store the stamp annotation appearance when deleting it so that we can set it again when doing an undo undo. --- CMakeLists.txt | 5 ++ core/annotations.cpp | 40 +++++++++++++ core/annotations.h | 9 +++ core/annotations_p.h | 2 + {part/data => core}/stamps.svg | 0 generators/poppler/annots.cpp | 85 +++++++++++++++++++++++++++- generators/poppler/annots.h | 5 ++ generators/poppler/generator_pdf.cpp | 4 ++ generators/poppler/generator_pdf.h | 3 + part/annotationactionhandler.cpp | 3 +- part/annotationwidgets.cpp | 27 +++++---- part/data/CMakeLists.txt | 4 -- part/guiutils.cpp | 56 ------------------ part/guiutils.h | 9 --- part/pagepainter.cpp | 3 +- part/pageviewannotator.cpp | 4 +- 16 files changed, 174 insertions(+), 85 deletions(-) rename {part/data => core}/stamps.svg (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2506c3cfa..aa3150ca6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,6 +313,7 @@ PRIVATE KF5::ThreadWeaver KF5::Bookmarks Phonon::phonon4qt5 + Qt5::Svg ${MATH_LIB} ZLIB::ZLIB PUBLIC # these are included from the installed headers @@ -504,6 +505,10 @@ install(FILES install(EXPORT Okular5Targets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE Okular5Targets.cmake NAMESPACE Okular::) +install(FILES + core/stamps.svg + DESTINATION ${KDE_INSTALL_DATADIR}/okular/pics) + ########### summary ################# feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/core/annotations.cpp b/core/annotations.cpp index a9e8ddfff..e6d781307 100644 --- a/core/annotations.cpp +++ b/core/annotations.cpp @@ -10,6 +10,10 @@ // qt/kde includes #include #include +#include +#include +#include +#include // DBL_MAX #include @@ -156,6 +160,37 @@ QRect AnnotationUtils::annotationGeometry(const Annotation *annotation, double s return rect; } + +QPixmap AnnotationUtils::loadStamp(const QString &nameOrPath, int size, bool keepAspectRatio) +{ + const QString name = nameOrPath.toLower(); + + const QString stampFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/stamps.svg")); + if (!stampFile.isEmpty()) { + QSvgRenderer r(stampFile); + if (r.isValid() && r.elementExists(name)) { + const QSize stampSize = r.boundsOnElement(name).size().toSize(); + const QSize pixmapSize = stampSize.scaled(size, size, keepAspectRatio ? Qt::KeepAspectRatioByExpanding : Qt::IgnoreAspectRatio); + QPixmap pixmap(pixmapSize); + pixmap.fill(Qt::transparent); + QPainter p(&pixmap); + r.render(&p, name); + p.end(); + return pixmap; + } + } + + // _name is a path (do this before loading as icon name to avoid some rare weirdness ) + QPixmap pixmap; + pixmap.load(nameOrPath); + if (!pixmap.isNull()) { + pixmap = pixmap.scaled(size, size, keepAspectRatio ? Qt::KeepAspectRatioByExpanding : Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + return pixmap; + } + + // _name is an icon name + return QIcon::fromTheme(name).pixmap(size); +} // END AnnotationUtils implementation AnnotationProxy::AnnotationProxy() @@ -509,6 +544,11 @@ AnnotationPrivate::~AnnotationPrivate() delete (*it).annotation(); } +AnnotationPrivate *AnnotationPrivate::get(Annotation *a) +{ + return a ? a->d_ptr : nullptr; +} + Annotation::Annotation(AnnotationPrivate &dd) : d_ptr(&dd) { diff --git a/core/annotations.h b/core/annotations.h index 23aa068e9..db3a5254b 100644 --- a/core/annotations.h +++ b/core/annotations.h @@ -74,6 +74,15 @@ public: * @p scaleX and @p scaleY. */ static QRect annotationGeometry(const Annotation *annotation, double scaleX, double scaleY); + + /** + * Returns a pixmap for a stamp symbol + * + * @p name Name of a Okular stamp symbol, icon or path to an image + * @p size Size of the pixmap (ignore aspect ratio). Takes precedence over @p iconSize + * @p iconSize Maximum size of the pixmap (keep aspect ratio) + */ + static QPixmap loadStamp(const QString &nameOrPath, int size, bool keepAspectRatio = true); }; /** diff --git a/core/annotations_p.h b/core/annotations_p.h index 1064f3b6f..1b22a3148 100644 --- a/core/annotations_p.h +++ b/core/annotations_p.h @@ -27,6 +27,8 @@ class AnnotationPrivate public: AnnotationPrivate(); + OKULARCORE_EXPORT static AnnotationPrivate *get(Annotation *a); + virtual ~AnnotationPrivate(); AnnotationPrivate(const AnnotationPrivate &) = delete; diff --git a/part/data/stamps.svg b/core/stamps.svg similarity index 100% rename from part/data/stamps.svg rename to core/stamps.svg diff --git a/generators/poppler/annots.cpp b/generators/poppler/annots.cpp index 51eb5a76e..e93d7cdd0 100644 --- a/generators/poppler/annots.cpp +++ b/generators/poppler/annots.cpp @@ -11,6 +11,7 @@ #include "annots.h" // qt/kde includes +#include #include #include @@ -279,6 +280,19 @@ static void setSharedAnnotationPropertiesToPopplerAnnotation(const Okular::Annot popplerAnnotation->setModificationDate(okularAnnotation->modificationDate()); } +#ifdef HAVE_POPPLER_21_10 +static void setPopplerStampAnnotationCustomImage(const Poppler::Page *page, Poppler::StampAnnotation *pStampAnnotation, const Okular::StampAnnotation *oStampAnnotation) +{ + const QSize size = page->pageSize(); + const QRect rect = Okular::AnnotationUtils::annotationGeometry(oStampAnnotation, size.width(), size.height()); + + QImage image = Okular::AnnotationUtils::loadStamp(oStampAnnotation->stampIconName(), qMax(rect.width(), rect.height())).toImage(); + + if (!image.isNull()) + pStampAnnotation->setStampCustomImage(image); +} +#endif + static void updatePopplerAnnotationFromOkularAnnotation(const Okular::TextAnnotation *oTextAnnotation, Poppler::TextAnnotation *pTextAnnotation) { pTextAnnotation->setTextIcon(oTextAnnotation->textIcon()); @@ -333,10 +347,17 @@ static void updatePopplerAnnotationFromOkularAnnotation(const Okular::HighlightA pHighlightAnnotation->setHighlightQuads(pQuads); } +#ifdef HAVE_POPPLER_21_10 +static void updatePopplerAnnotationFromOkularAnnotation(const Okular::StampAnnotation *oStampAnnotation, Poppler::StampAnnotation *pStampAnnotation, const Poppler::Page *page) +{ + setPopplerStampAnnotationCustomImage(page, pStampAnnotation, oStampAnnotation); +} +#else static void updatePopplerAnnotationFromOkularAnnotation(const Okular::StampAnnotation *oStampAnnotation, Poppler::StampAnnotation *pStampAnnotation) { pStampAnnotation->setStampIconName(oStampAnnotation->stampIconName()); } +#endif static void updatePopplerAnnotationFromOkularAnnotation(const Okular::InkAnnotation *oInkAnnotation, Poppler::InkAnnotation *pInkAnnotation) { @@ -398,6 +419,17 @@ static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(const Ok return pHighlightAnnotation; } +#ifdef HAVE_POPPLER_21_10 +static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(const Okular::StampAnnotation *oStampAnnotation, Poppler::Page *page) +{ + Poppler::StampAnnotation *pStampAnnotation = new Poppler::StampAnnotation(); + + setSharedAnnotationPropertiesToPopplerAnnotation(oStampAnnotation, pStampAnnotation); + updatePopplerAnnotationFromOkularAnnotation(oStampAnnotation, pStampAnnotation, page); + + return pStampAnnotation; +} +#else static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(const Okular::StampAnnotation *oStampAnnotation) { Poppler::StampAnnotation *pStampAnnotation = new Poppler::StampAnnotation(); @@ -407,6 +439,7 @@ static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(const Ok return pStampAnnotation; } +#endif static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(const Okular::InkAnnotation *oInkAnnotation) { @@ -431,6 +464,8 @@ void PopplerAnnotationProxy::notifyAddition(Okular::Annotation *okl_ann, int pag { QMutexLocker ml(mutex); + Poppler::Page *ppl_page = ppl_doc->page(page); + // Create poppler annotation Poppler::Annotation *ppl_ann = nullptr; switch (okl_ann->subType()) { @@ -447,8 +482,26 @@ void PopplerAnnotationProxy::notifyAddition(Okular::Annotation *okl_ann, int pag ppl_ann = createPopplerAnnotationFromOkularAnnotation(static_cast(okl_ann)); break; case Okular::Annotation::AStamp: +#ifdef HAVE_POPPLER_21_10 + { + bool wasDenyWriteEnabled = okl_ann->flags() & Okular::Annotation::DenyWrite; + + if (wasDenyWriteEnabled) + okl_ann->setFlags(okl_ann->flags() & ~Okular::Annotation::DenyWrite); + + ppl_ann = createPopplerAnnotationFromOkularAnnotation(static_cast(okl_ann), ppl_page); + if (deletedStampsAnnotationAppearance.find(static_cast(okl_ann)) != deletedStampsAnnotationAppearance.end()) { + ppl_ann->setAnnotationAppearance(*deletedStampsAnnotationAppearance[static_cast(okl_ann)].get()); + deletedStampsAnnotationAppearance.erase(static_cast(okl_ann)); + + if (wasDenyWriteEnabled) + okl_ann->setFlags(okl_ann->flags() | Okular::Annotation::DenyWrite); + } + } +#else ppl_ann = createPopplerAnnotationFromOkularAnnotation(static_cast(okl_ann)); - break; +#endif + break; case Okular::Annotation::AInk: ppl_ann = createPopplerAnnotationFromOkularAnnotation(static_cast(okl_ann)); break; @@ -460,12 +513,15 @@ void PopplerAnnotationProxy::notifyAddition(Okular::Annotation *okl_ann, int pag return; } +#ifdef HAVE_POPPLER_21_10 + okl_ann->setFlags(okl_ann->flags() | Okular::Annotation::ExternallyDrawn); +#else // Poppler doesn't render StampAnnotations yet if (ppl_ann->subType() != Poppler::Annotation::AStamp) okl_ann->setFlags(okl_ann->flags() | Okular::Annotation::ExternallyDrawn); +#endif // Bind poppler object to page - Poppler::Page *ppl_page = ppl_doc->page(page); ppl_page->addAnnotation(ppl_ann); delete ppl_page; @@ -534,7 +590,13 @@ void PopplerAnnotationProxy::notifyModification(const Okular::Annotation *okl_an case Poppler::Annotation::AStamp: { const Okular::StampAnnotation *okl_stampann = static_cast(okl_ann); Poppler::StampAnnotation *ppl_stampann = static_cast(ppl_ann); +#ifdef HAVE_POPPLER_21_10 + Poppler::Page *ppl_page = ppl_doc->page(page); + updatePopplerAnnotationFromOkularAnnotation(okl_stampann, ppl_stampann, ppl_page); + delete ppl_page; +#else updatePopplerAnnotationFromOkularAnnotation(okl_stampann, ppl_stampann); +#endif break; } case Poppler::Annotation::AInk: { @@ -562,6 +624,10 @@ void PopplerAnnotationProxy::notifyRemoval(Okular::Annotation *okl_ann, int page Poppler::Page *ppl_page = ppl_doc->page(page); annotationsOnOpenHash->remove(okl_ann); +#ifdef HAVE_POPPLER_21_10 + if (okl_ann->subType() == Okular::Annotation::AStamp) + deletedStampsAnnotationAppearance[static_cast(okl_ann)] = std::move(ppl_ann->annotationAppearance()); +#endif ppl_page->removeAnnotation(ppl_ann); // Also destroys ppl_ann delete ppl_page; @@ -997,6 +1063,9 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p break; } case Poppler::Annotation::AStamp: +#ifdef HAVE_POPPLER_21_10 + externallyDrawn = true; +#endif tieToOkularAnn = true; *doDelete = false; okularAnnotation = createAnnotationFromPopplerAnnotation(static_cast(popplerAnnotation)); @@ -1020,6 +1089,18 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p if (externallyDrawn) okularAnnotation->setFlags(okularAnnotation->flags() | Okular::Annotation::ExternallyDrawn); +#ifdef HAVE_POPPLER_21_10 + if (okularAnnotation->subType() == Okular::Annotation::SubType::AStamp) { + Okular::StampAnnotation *oStampAnn = static_cast(okularAnnotation); + Poppler::StampAnnotation *pStampAnn = static_cast(popplerAnnotation); + QFileInfo stampIconFile = oStampAnn->stampIconName(); + if (stampIconFile.exists() && stampIconFile.isFile()) { + setPopplerStampAnnotationCustomImage(&popplerPage, pStampAnn, oStampAnn); + } + + oStampAnn->setFlags(okularAnnotation->flags() | Okular::Annotation::Flag::DenyWrite); + } +#endif // Convert the poppler annotation style to Okular annotation style Okular::Annotation::Style &okularStyle = okularAnnotation->style(); diff --git a/generators/poppler/annots.h b/generators/poppler/annots.h index a25b931bf..1f1b0fb9f 100644 --- a/generators/poppler/annots.h +++ b/generators/poppler/annots.h @@ -15,6 +15,8 @@ #include +#include + #include "config-okular-poppler.h" #include "core/annotations.h" @@ -35,6 +37,9 @@ private: Poppler::Document *ppl_doc; QMutex *mutex; QHash *annotationsOnOpenHash; +#ifdef HAVE_POPPLER_21_10 + std::unordered_map> deletedStampsAnnotationAppearance; +#endif }; #endif diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index edb20c2ff..821bbf0cf 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -1464,7 +1464,11 @@ QVariant PDFGenerator::metaData(const QString &key, const QVariant &option) cons return i18n("Using Poppler %1\n\nBuilt against Poppler %2", Poppler::Version::string(), POPPLER_VERSION); } } else if (key == QLatin1String("ShowStampsWarning")) { +#ifdef HAVE_POPPLER_21_10 + return QStringLiteral("no"); +#else return QStringLiteral("yes"); +#endif } return QVariant(); } diff --git a/generators/poppler/generator_pdf.h b/generators/poppler/generator_pdf.h index 2dba980b5..d5ba864e7 100644 --- a/generators/poppler/generator_pdf.h +++ b/generators/poppler/generator_pdf.h @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,8 @@ #include #include +#include + class PDFOptionsPage; class PopplerAnnotationProxy; diff --git a/part/annotationactionhandler.cpp b/part/annotationactionhandler.cpp index dd246bcdb..7488e97a5 100644 --- a/part/annotationactionhandler.cpp +++ b/part/annotationactionhandler.cpp @@ -27,6 +27,7 @@ // local includes #include "actionbar.h" #include "annotationwidgets.h" +#include "core/annotations.h" #include "guiutils.h" #include "pageview.h" #include "pageviewannotator.h" @@ -453,7 +454,7 @@ const QIcon AnnotationActionHandlerPrivate::widthIcon(double width) const QIcon AnnotationActionHandlerPrivate::stampIcon(const QString &stampIconName) { - QPixmap stampPix = GuiUtils::loadStamp(stampIconName, 32); + QPixmap stampPix = Okular::AnnotationUtils::loadStamp(stampIconName, 32); if (stampPix.width() == stampPix.height()) return QIcon(stampPix); else diff --git a/part/annotationwidgets.cpp b/part/annotationwidgets.cpp index 270d6424f..91f660d59 100644 --- a/part/annotationwidgets.cpp +++ b/part/annotationwidgets.cpp @@ -30,7 +30,11 @@ #include #include +#include "core/annotations.h" +#include "core/annotations_p.h" #include "core/document.h" +#include "core/document_p.h" +#include "core/page_p.h" #include "guiutils.h" #include "pagepainter.h" @@ -136,7 +140,7 @@ void PixmapPreviewSelector::iconComboChanged(const QString &icon) m_icon = icon; } - QPixmap pixmap = GuiUtils::loadStamp(m_icon, m_previewSize); + QPixmap pixmap = Okular::AnnotationUtils::loadStamp(m_icon, m_previewSize); const QRect cr = m_iconLabel->contentsRect(); if (pixmap.width() > cr.width() || pixmap.height() > cr.height()) pixmap = pixmap.scaled(cr.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); @@ -149,7 +153,7 @@ void PixmapPreviewSelector::selectCustomStamp() { const QString customStampFile = QFileDialog::getOpenFileName(this, i18nc("@title:window file chooser", "Select custom stamp symbol"), QString(), i18n("*.ico *.png *.xpm *.svg *.svgz | Icon Files (*.ico *.png *.xpm *.svg *.svgz)")); if (!customStampFile.isEmpty()) { - QPixmap pixmap = GuiUtils::loadStamp(customStampFile, m_previewSize); + QPixmap pixmap = Okular::AnnotationUtils::loadStamp(customStampFile, m_previewSize); if (pixmap.isNull()) { KMessageBox::sorry(this, xi18nc("@info", "Could not load the file %1", customStampFile), i18nc("@title:window", "Invalid file")); } else { @@ -435,14 +439,17 @@ void StampAnnotationWidget::createStyleWidget(QFormLayout *formlayout) { QWidget *widget = qobject_cast(formlayout->parent()); - KMessageWidget *brokenStampSupportWarning = new KMessageWidget(widget); - brokenStampSupportWarning->setText(xi18nc("@info", - "experimental feature." - "Stamps inserted in PDF documents are not visible in PDF readers other than Okular.")); - brokenStampSupportWarning->setMessageType(KMessageWidget::Warning); - brokenStampSupportWarning->setWordWrap(true); - brokenStampSupportWarning->setCloseButtonVisible(false); - formlayout->insertRow(0, brokenStampSupportWarning); + Okular::Document *doc = Okular::AnnotationPrivate::get(m_stampAnn)->m_page->m_doc->m_parent; + if (doc->metaData(QStringLiteral("ShowStampsWarning")).toString() == QLatin1String("yes")) { + KMessageWidget *brokenStampSupportWarning = new KMessageWidget(widget); + brokenStampSupportWarning->setText(xi18nc("@info", + "experimental feature." + "Stamps inserted in PDF documents are not visible in PDF readers other than Okular.")); + brokenStampSupportWarning->setMessageType(KMessageWidget::Warning); + brokenStampSupportWarning->setWordWrap(true); + brokenStampSupportWarning->setCloseButtonVisible(false); + formlayout->insertRow(0, brokenStampSupportWarning); + } addOpacitySpinBox(widget, formlayout); addVerticalSpacer(formlayout); diff --git a/part/data/CMakeLists.txt b/part/data/CMakeLists.txt index 1f7db8c16..edaf76252 100644 --- a/part/data/CMakeLists.txt +++ b/part/data/CMakeLists.txt @@ -42,8 +42,4 @@ install(FILES uparrow.png upleftarrow.png DESTINATION ${KDE_INSTALL_DATADIR}/okular/pics) -# install annotation stamps -install(FILES - stamps.svg - DESTINATION ${KDE_INSTALL_DATADIR}/okular/pics) # install misc images diff --git a/part/guiutils.cpp b/part/guiutils.cpp index 8ea03abba..a486019c6 100644 --- a/part/guiutils.cpp +++ b/part/guiutils.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include // local includes @@ -23,32 +22,6 @@ #include -struct GuiUtilsHelper { - GuiUtilsHelper() - { - } - - QSvgRenderer *svgStamps(); - - std::unique_ptr svgStampFile; -}; - -QSvgRenderer *GuiUtilsHelper::svgStamps() -{ - if (!svgStampFile.get()) { - const QString stampFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/stamps.svg")); - if (!stampFile.isEmpty()) { - svgStampFile = std::make_unique(stampFile); - if (!svgStampFile->isValid()) { - svgStampFile.reset(); - } - } - } - return svgStampFile.get(); -} - -Q_GLOBAL_STATIC(GuiUtilsHelper, s_data) - namespace GuiUtils { QString captionForAnnotation(const Okular::Annotation *ann) @@ -157,35 +130,6 @@ QString prettyToolTip(const Okular::Annotation *ann) return tooltip; } -QPixmap loadStamp(const QString &nameOrPath, int size, bool keepAspectRatio) -{ - const QString name = nameOrPath.toLower(); - - // _name is the name of an Okular stamp symbols ( multiple symbols in a single *.svg file) - QSvgRenderer *r = nullptr; - if ((r = s_data->svgStamps()) && r->elementExists(name)) { - const QSize stampSize = r->boundsOnElement(name).size().toSize(); - const QSize pixmapSize = stampSize.scaled(size, size, keepAspectRatio ? Qt::KeepAspectRatioByExpanding : Qt::IgnoreAspectRatio); - QPixmap pixmap(pixmapSize); - pixmap.fill(Qt::transparent); - QPainter p(&pixmap); - r->render(&p, name); - p.end(); - return pixmap; - } - - // _name is a path (do this before loading as icon name to avoid some rare weirdness ) - QPixmap pixmap; - pixmap.load(nameOrPath); - if (!pixmap.isNull()) { - pixmap = pixmap.scaled(size, size, keepAspectRatio ? Qt::KeepAspectRatioByExpanding : Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - return pixmap; - } - - // _name is an icon name - return QIcon::fromTheme(name).pixmap(size); -} - void saveEmbeddedFile(Okular::EmbeddedFile *ef, QWidget *parent) { const QString caption = i18n("Where do you want to save %1?", ef->name()); diff --git a/part/guiutils.h b/part/guiutils.h index 572c71af2..f5d03c62c 100644 --- a/part/guiutils.h +++ b/part/guiutils.h @@ -37,15 +37,6 @@ QString contentsHtml(const Okular::Annotation *annotation); QString prettyToolTip(const Okular::Annotation *annotation); -/** - * Returns a pixmap for a stamp symbol - * - * @p name Name of a Okular stamp symbol, icon or path to an image - * @p size Size of the pixmap (ignore aspect ratio). Takes precedence over @p iconSize - * @p iconSize Maximum size of the pixmap (keep aspect ratio) - */ -QPixmap loadStamp(const QString &nameOrPath, int size, bool keepAspectRatio = true); - void saveEmbeddedFile(Okular::EmbeddedFile *ef, QWidget *parent); void writeEmbeddedFile(Okular::EmbeddedFile *ef, QWidget *parent, QFile &targetFile); diff --git a/part/pagepainter.cpp b/part/pagepainter.cpp index b2bc95d52..dca79349a 100644 --- a/part/pagepainter.cpp +++ b/part/pagepainter.cpp @@ -22,6 +22,7 @@ #include // local includes +#include "core/annotations.h" #include "core/observer.h" #include "core/page.h" #include "core/page_p.h" @@ -592,7 +593,7 @@ void PagePainter::paintCroppedPageOnPainter(QPainter *destPainter, Okular::StampAnnotation *stamp = (Okular::StampAnnotation *)a; // get pixmap and alpha blend it if needed - QPixmap pixmap = GuiUtils::loadStamp(stamp->stampIconName(), qMax(annotBoundary.width(), annotBoundary.height()) * dpr); + QPixmap pixmap = Okular::AnnotationUtils::loadStamp(stamp->stampIconName(), qMax(annotBoundary.width(), annotBoundary.height()) * dpr); if (!pixmap.isNull()) // should never happen but can happen on huge sizes { QPixmap scaledCroppedPixmap = pixmap.scaled(annotBoundary.width() * dpr, annotBoundary.height() * dpr).copy(dInnerRect.toAlignedRect()); diff --git a/part/pageviewannotator.cpp b/part/pageviewannotator.cpp index 53baaa7e3..34a403688 100644 --- a/part/pageviewannotator.cpp +++ b/part/pageviewannotator.cpp @@ -70,7 +70,7 @@ public: // create engine objects if (!hoverIconName.simplified().isEmpty()) - pixmap = GuiUtils::loadStamp(hoverIconName, size); + pixmap = Okular::AnnotationUtils::loadStamp(hoverIconName, size); } QRect event(EventType type, Button button, Modifiers modifiers, double nX, double nY, double xScale, double yScale, const Okular::Page *page) override @@ -1450,7 +1450,7 @@ QPixmap PageViewAnnotator::makeToolPixmap(const QDomElement &toolElement) p.drawLine(0, 20, 19, 20); p.drawLine(1, 21, 18, 21); } else if (annotType == QLatin1String("stamp")) { - QPixmap stamp = GuiUtils::loadStamp(icon, 16, false /* keepAspectRatio */); + QPixmap stamp = Okular::AnnotationUtils::loadStamp(icon, 16, false /* keepAspectRatio */); p.setRenderHint(QPainter::Antialiasing); p.drawPixmap(16, 14, stamp); } else if (annotType == QLatin1String("straight-line")) {