diff options
author | ZackaryWelch <welch.zackary@gmail.com> | 2018-02-16 17:17:56 -0500 |
---|---|---|
committer | ZackaryWelch <welch.zackary@gmail.com> | 2018-02-16 17:17:56 -0500 |
commit | 75418056d8017c75af11d0a332c43befcbbbef65 (patch) | |
tree | fd2b070b38bd573a708bae61ad53cff2b7a60808 /src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp | |
parent | Switched lumina-pdf from Poppler to MuPDF (diff) | |
download | lumina-75418056d8017c75af11d0a332c43befcbbbef65.tar.gz lumina-75418056d8017c75af11d0a332c43befcbbbef65.tar.bz2 lumina-75418056d8017c75af11d0a332c43befcbbbef65.zip |
Added highlighting for search results
Diffstat (limited to 'src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp')
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp index 5fa8e517..790ae2ad 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp @@ -126,10 +126,18 @@ void PrintWidget::setCurrentPage(int pageNumber) { } } -void PrintWidget::highlightText(int pageNum, fz_rect &rect) { - //PageItem *item = static_cast<PageItem*>(pages[pageNum]); - QPainter painter(this); - painter.fillRect(QRectF(QPointF(rect.x0, rect.y0), QPointF(rect.x1, rect.y1)), QColor(255, 255, 177, 128)); +void PrintWidget::highlightText(TextData *text) { + //Creates a rectangle around the text if the text has not already been highlighted + if(!text->highlighted()) { + //qDebug() << "Highlighting text: " << text->text() << "At page: " << text->page(); + fz_rect rect = text->loc(); + double pageHeight = pages.at(0)->boundingRect().height(); + QRectF textRect(QPointF(rect.x0, rect.y0+(pageHeight*(text->page()-1))), QPointF(rect.x1, rect.y1 + (pageHeight*(text->page()-1)))); + QBrush highlightFill(QColor(255, 255, 177, 50)); + QPen highlightOutline(QColor(255, 255, 100, 98)); + scene->addRect(textRect, highlightOutline, highlightFill); + text->highlighted(true); + } } //Private functions @@ -194,7 +202,7 @@ void PrintWidget::populateScene() QImage pagePicture = pictures->value(i); if(degrees != 0) { pagePicture = pagePicture.transformed(rotMatrix, Qt::SmoothTransformation); - qDebug() << "Rotating by: " << degrees << " degrees"; + //qDebug() << "Rotating by: " << degrees << " degrees"; } if(pagePicture.isNull()) { qDebug() << "NULL IMAGE ON PAGE " << i; |