gui: PreviewGeneratorPdf: Only highlight whole words
Only highlight whole words, which is less confusing
This commit is contained in:
parent
11b070ed42
commit
e6a0c0daee
@ -1,5 +1,6 @@
|
|||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include "previewgeneratorpdf.h"
|
#include "previewgeneratorpdf.h"
|
||||||
|
|
||||||
static QMutex cacheMutex;
|
static QMutex cacheMutex;
|
||||||
@ -17,6 +18,7 @@ Poppler::Document *PreviewGeneratorPdf::document(QString path)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
result->setRenderHint(Poppler::Document::TextAntialiasing);
|
result->setRenderHint(Poppler::Document::TextAntialiasing);
|
||||||
|
|
||||||
QMutexLocker locker(&cacheMutex);
|
QMutexLocker locker(&cacheMutex);
|
||||||
documentcache.insert(path, result);
|
documentcache.insert(path, result);
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
@ -45,7 +47,8 @@ QSharedPointer<PreviewResult> PreviewGeneratorPdf::generate(RenderConfig config,
|
|||||||
QImage img = pdfPage->renderToImage(config.scaleX, config.scaleY);
|
QImage img = pdfPage->renderToImage(config.scaleX, config.scaleY);
|
||||||
for(QString &word : config.wordsToHighlight)
|
for(QString &word : config.wordsToHighlight)
|
||||||
{
|
{
|
||||||
QList<QRectF> rects = pdfPage->search(word, Poppler::Page::SearchFlag::IgnoreCase);
|
QList<QRectF> rects =
|
||||||
|
pdfPage->search(word, Poppler::Page::SearchFlag::IgnoreCase | Poppler::Page::SearchFlag::WholeWords);
|
||||||
for(QRectF &rect : rects)
|
for(QRectF &rect : rects)
|
||||||
{
|
{
|
||||||
QPainter painter(&img);
|
QPainter painter(&img);
|
||||||
|
Loading…
Reference in New Issue
Block a user