aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2018-03-17 17:39:09 -0400
committerZackaryWelch <welch.zackary@gmail.com>2018-03-17 17:39:09 -0400
commitd585d64718941d54b004daa0ece491783ef78ad8 (patch)
treedf70886b64fad4a22d3243c93806524ecadbcead /src-qt5
parentOverhaul of MuPDF rendering. Fixed bugs and improved the find highlight syste... (diff)
downloadlumina-d585d64718941d54b004daa0ece491783ef78ad8.tar.gz
lumina-d585d64718941d54b004daa0ece491783ef78ad8.tar.bz2
lumina-d585d64718941d54b004daa0ece491783ef78ad8.zip
Replaced tabs with spaces and removed some unneeded comments
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PresentationLabel.h18
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp354
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.h226
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp306
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp54
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/Renderer.h52
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.cpp48
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.h128
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/propDialog.cpp1
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/propDialog.h5
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/textData.h40
11 files changed, 614 insertions, 618 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/PresentationLabel.h b/src-qt5/desktop-utils/lumina-pdf/PresentationLabel.h
index c5b552a6..e838c46a 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PresentationLabel.h
+++ b/src-qt5/desktop-utils/lumina-pdf/PresentationLabel.h
@@ -15,21 +15,21 @@
#include <QDebug>
class PresentationLabel : public QLabel{
- Q_OBJECT
+ Q_OBJECT
signals:
- void nextSlide();
+ void nextSlide();
public:
- PresentationLabel() : QLabel(0, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint){
- this->setContextMenuPolicy(Qt::CustomContextMenu);
- }
+ PresentationLabel() : QLabel(0, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint){
+ this->setContextMenuPolicy(Qt::CustomContextMenu);
+ }
protected:
- void mousePressEvent(QMouseEvent *ev){
- QLabel::mousePressEvent(ev);
- if(ev->button()==Qt::LeftButton){ emit nextSlide(); }
- }
+ void mousePressEvent(QMouseEvent *ev){
+ QLabel::mousePressEvent(ev);
+ if(ev->button()==Qt::LeftButton){ emit nextSlide(); }
+ }
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
index 4ccae28c..9515e719 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
@@ -1,8 +1,8 @@
#include "PrintWidget.h"
PrintWidget::PrintWidget(Renderer *backend, QWidget *parent) :
- QGraphicsView(parent), scene(0), curPage(1), viewMode(SinglePageView),
- zoomMode(FitInView), zoomFactor(1), initialized(false), fitting(true), BACKEND(backend) {
+ QGraphicsView(parent), scene(0), curPage(1), viewMode(SinglePageView),
+ zoomMode(FitInView), zoomFactor(1), initialized(false), fitting(true), BACKEND(backend) {
this->setMouseTracking(true);
QList<QWidget*> children = this->findChildren<QWidget*>("",Qt::FindChildrenRecursively);
@@ -10,24 +10,24 @@ PrintWidget::PrintWidget(Renderer *backend, QWidget *parent) :
children[i]->setContextMenuPolicy(Qt::CustomContextMenu);
connect(children[i], SIGNAL(customContextMenuRequested(const QPoint&)), this, SIGNAL(customContextMenuRequested(const QPoint&)) );
}
- this->setInteractive(false);
- this->setDragMode(QGraphicsView::ScrollHandDrag);
- this->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
+ this->setInteractive(false);
+ this->setDragMode(QGraphicsView::ScrollHandDrag);
+ this->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
this->setFocusPolicy(Qt::NoFocus);
- QObject::connect(this->verticalScrollBar(), SIGNAL(valueChanged(int)),
- this, SLOT(updateCurrentPage()));
- QObject::connect(this, SIGNAL(resized()), this, SLOT(fit()));
+ QObject::connect(this->verticalScrollBar(), SIGNAL(valueChanged(int)),
+ this, SLOT(updateCurrentPage()));
+ QObject::connect(this, SIGNAL(resized()), this, SLOT(fit()));
- scene = new QGraphicsScene(this);
- scene->setBackgroundBrush(Qt::gray);
- this->setScene(scene);
+ scene = new QGraphicsScene(this);
+ scene->setBackgroundBrush(Qt::gray);
+ this->setScene(scene);
this->degrees = 0;
this->rotMatrix = QMatrix(1, 0, 0, 1, 0 ,0);
- /*QVBoxLayout *layout = new QVBoxLayout;
- setLayout(layout);
- layout->setContentsMargins(0, 0, 0, 0);
- layout->addWidget(this);*/
+ /*QVBoxLayout *layout = new QVBoxLayout;
+ setLayout(layout);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(this);*/
}
PrintWidget::~PrintWidget() {
@@ -49,8 +49,8 @@ void PrintWidget::fitToWidth() {
void PrintWidget::setZoomMode(ZoomMode mode) {
zoomMode = mode;
- fitting = true;
- fit(true);
+ fitting = true;
+ fit(true);
}
void PrintWidget::setAllPagesViewMode() {
@@ -66,31 +66,31 @@ void PrintWidget::setFacingPagesViewMode() {
}
void PrintWidget::setViewMode(ViewMode mode) {
- viewMode = mode;
- layoutPages();
- if (viewMode == AllPagesView) {
- this->fitInView(scene->itemsBoundingRect(), Qt::KeepAspectRatio);
- fitting = false;
- zoomMode = CustomZoom;
- //zoomFactor = this->transform().m11() * (double(printer->logicalDpiY()) / logicalDpiY());
- } else {
- fitting = true;
- fit();
- }
+ viewMode = mode;
+ layoutPages();
+ if (viewMode == AllPagesView) {
+ this->fitInView(scene->itemsBoundingRect(), Qt::KeepAspectRatio);
+ fitting = false;
+ zoomMode = CustomZoom;
+ //zoomFactor = this->transform().m11() * (double(printer->logicalDpiY()) / logicalDpiY());
+ } else {
+ fitting = true;
+ fit();
+ }
}
void PrintWidget::zoomIn(double factor) {
- fitting = false;
- zoomMode = CustomZoom;
- zoomFactor *= factor;
- this->scale(factor, factor);
+ fitting = false;
+ zoomMode = CustomZoom;
+ zoomFactor *= factor;
+ this->scale(factor, factor);
}
void PrintWidget::zoomOut(double factor) {
- fitting = false;
- zoomMode = CustomZoom;
- zoomFactor *= factor;
- this->scale(1/factor, 1/factor);
+ fitting = false;
+ zoomMode = CustomZoom;
+ zoomFactor *= factor;
+ this->scale(1/factor, 1/factor);
}
void PrintWidget::updatePreview() {
@@ -100,31 +100,31 @@ void PrintWidget::updatePreview() {
}
void PrintWidget::setVisible(bool visible) {
- if(visible and !initialized)
- updatePreview();
- QGraphicsView::setVisible(visible);
+ if(visible and !initialized)
+ updatePreview();
+ QGraphicsView::setVisible(visible);
}
void PrintWidget::setCurrentPage(int pageNumber) {
- if(pageNumber < 0 || pageNumber > (pages.count()+1) ){ return; }
- publicPageNum = pageNumber; //publicly requested page number (+/- 1 from actual page range)
- emit currentPageChanged();
- if(pageNumber < 1 || pageNumber > pages.count())
- return;
- int lastPage = curPage;
- curPage = pageNumber;
-
- if (lastPage != curPage && lastPage > 0 && lastPage <= pages.count()) {
- if (zoomMode != FitInView) {
- QScrollBar *hsc = this->horizontalScrollBar();
- QScrollBar *vsc = this->verticalScrollBar();
- QPointF pt = this->transform().map(pages.at(curPage-1)->pos());
- vsc->setValue(int(pt.y()) - 10);
- hsc->setValue(int(pt.x()) - 10);
- } else {
- this->centerOn(pages.at(curPage-1));
- }
- }
+ if(pageNumber < 0 || pageNumber > (pages.count()+1) ){ return; }
+ publicPageNum = pageNumber; //publicly requested page number (+/- 1 from actual page range)
+ emit currentPageChanged();
+ if(pageNumber < 1 || pageNumber > pages.count())
+ return;
+ int lastPage = curPage;
+ curPage = pageNumber;
+
+ if (lastPage != curPage && lastPage > 0 && lastPage <= pages.count()) {
+ if (zoomMode != FitInView) {
+ QScrollBar *hsc = this->horizontalScrollBar();
+ QScrollBar *vsc = this->verticalScrollBar();
+ QPointF pt = this->transform().map(pages.at(curPage-1)->pos());
+ vsc->setValue(int(pt.y()) - 10);
+ hsc->setValue(int(pt.x()) - 10);
+ } else {
+ this->centerOn(pages.at(curPage-1));
+ }
+ }
}
void PrintWidget::highlightText(TextData *text) {
@@ -132,19 +132,19 @@ void PrintWidget::highlightText(TextData *text) {
if(!text->highlighted()) {
double pageHeight = pages.at(text->page()-1)->boundingRect().height();
QRectF rect = text->loc();
- if(degrees != 0) {
- QSize center = BACKEND->imageHash(text->page()-1).size()/2;
- //Rotates the rectangle by the page's center
- double cx = center.width(), cy = center.height();
- rect.adjust(-cx, -cy, -cx, -cy);
- rect = rotMatrix.mapRect(rect);
- if(degrees == 180)
- rect.adjust(cx, cy, cx, cy);
- else
- rect.adjust(cy, cx, cy, cx);
- }
- //Moves the rectangle onto the right page
- rect.moveTop(rect.y() + pageHeight*(text->page()-1));
+ if(degrees != 0) {
+ QSize center = BACKEND->imageHash(text->page()-1).size()/2;
+ //Rotates the rectangle by the page's center
+ double cx = center.width(), cy = center.height();
+ rect.adjust(-cx, -cy, -cx, -cy);
+ rect = rotMatrix.mapRect(rect);
+ if(degrees == 180)
+ rect.adjust(cx, cy, cx, cy);
+ else
+ rect.adjust(cy, cx, cy, cx);
+ }
+ //Moves the rectangle onto the right page
+ rect.moveTop(rect.y() + pageHeight*(text->page()-1));
QBrush highlightFill(QColor(255, 255, 177, 100));
QPen highlightOutline(QColor(255, 255, 100, 125));
scene->addRect(rect, highlightOutline, highlightFill);
@@ -155,24 +155,24 @@ void PrintWidget::highlightText(TextData *text) {
//Private functions
void PrintWidget::generatePreview() {
- qDebug() << "Generating Preview";
- populateScene(); // i.e. setPreviewPrintedPictures() e.l.
- layoutPages();
- curPage = qBound(1, curPage, pages.count());
- publicPageNum = curPage;
- emit currentPageChanged();
- if (fitting){ fit(); }
+ qDebug() << "Generating Preview";
+ populateScene(); // i.e. setPreviewPrintedPictures() e.l.
+ layoutPages();
+ curPage = qBound(1, curPage, pages.count());
+ publicPageNum = curPage;
+ emit currentPageChanged();
+ if (fitting){ fit(); }
}
void PrintWidget::layoutPages() {
- int numPages = pages.count();
- if (numPages < 1)
- return;
-
- int numPagePlaces = numPages;
- int cols = 1; // singleMode and default
- QSize pageSize = BACKEND->imageHash(0).size();
- if (viewMode == AllPagesView) {
+ int numPages = pages.count();
+ if (numPages < 1)
+ return;
+
+ int numPagePlaces = numPages;
+ int cols = 1; // singleMode and default
+ QSize pageSize = BACKEND->imageHash(0).size();
+ if (viewMode == AllPagesView) {
cols = pageSize.width() > pageSize.height() ? qFloor(qSqrt(numPages)) : qCeil(qSqrt(numPages));
cols += cols % 2; // Nicer with an even number of cols
} else if (viewMode == FacingPagesView) {
@@ -191,16 +191,16 @@ void PrintWidget::layoutPages() {
pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
pageNum++;
}
- }
- }
- scene->setSceneRect(scene->itemsBoundingRect());
- qDebug() << "Finished Page Layout";
+ }
+ }
+ scene->setSceneRect(scene->itemsBoundingRect());
+ qDebug() << "Finished Page Layout";
}
void PrintWidget::populateScene()
{
for (int i = 0; i < pages.size(); i++){
- scene->removeItem(pages.at(i));
+ scene->removeItem(pages.at(i));
}
qDeleteAll(pages);
pages.clear();
@@ -210,13 +210,13 @@ void PrintWidget::populateScene()
for (int i = 0; i < numPages; i++) {
QImage pagePicture = BACKEND->imageHash(i);
- //qDebug() << "Loading Image:" << i;
+ //qDebug() << "Loading Image:" << i;
- QSize paperSize = BACKEND->imageHash(i).size();
+ QSize paperSize = BACKEND->imageHash(i).size();
- //Changes the paper orientation if rotated by 90 or 270 degrees
- if(degrees == 90 or degrees == 270)
- paperSize.transpose();
+ //Changes the paper orientation if rotated by 90 or 270 degrees
+ if(degrees == 90 or degrees == 270)
+ paperSize.transpose();
if(degrees != 0) {
pagePicture = pagePicture.transformed(rotMatrix, Qt::SmoothTransformation);
@@ -226,102 +226,102 @@ void PrintWidget::populateScene()
qDebug() << "NULL IMAGE ON PAGE " << i;
continue;
}
- PageItem* item = new PageItem(i+1, pagePicture, paperSize);
- scene->addItem(item);
- pages.append(item);
+ PageItem* item = new PageItem(i+1, pagePicture, paperSize);
+ scene->addItem(item);
+ pages.append(item);
}
}
//Private Slots
void PrintWidget::updateCurrentPage() {
- if (viewMode == AllPagesView)
- return;
-
- int newPage = calcCurrentPage();
- if (newPage != curPage) {
- curPage = newPage;
- publicPageNum = curPage;
- emit currentPageChanged();
- }
+ if (viewMode == AllPagesView)
+ return;
+
+ int newPage = calcCurrentPage();
+ if (newPage != curPage) {
+ curPage = newPage;
+ publicPageNum = curPage;
+ emit currentPageChanged();
+ }
}
int PrintWidget::calcCurrentPage() {
- int maxArea = 0;
- int newPage = curPage;
- QRect viewRect = this->viewport()->rect();
- QList<QGraphicsItem*> items = this->items(viewRect);
- for (int i=0; i<items.size(); ++i) {
- PageItem* pg = static_cast<PageItem*>(items.at(i));
- QRect overlap = this->mapFromScene(pg->sceneBoundingRect()).boundingRect() & viewRect;
- int area = overlap.width() * overlap.height();
- if (area > maxArea) {
- maxArea = area;
- newPage = pg->pageNumber();
- } else if (area == maxArea && pg->pageNumber() < newPage) {
- newPage = pg->pageNumber();
- }
- }
- return newPage;
+ int maxArea = 0;
+ int newPage = curPage;
+ QRect viewRect = this->viewport()->rect();
+ QList<QGraphicsItem*> items = this->items(viewRect);
+ for (int i=0; i<items.size(); ++i) {
+ PageItem* pg = static_cast<PageItem*>(items.at(i));
+ QRect overlap = this->mapFromScene(pg->sceneBoundingRect()).boundingRect() & viewRect;
+ int area = overlap.width() * overlap.height();
+ if (area > maxArea) {
+ maxArea = area;
+ newPage = pg->pageNumber();
+ } else if (area == maxArea && pg->pageNumber() < newPage) {
+ newPage = pg->pageNumber();
+ }
+ }
+ return newPage;
}
void PrintWidget::fit(bool doFitting) {
- if (curPage < 1 || curPage > pages.count())
- return;
- if (!doFitting && !fitting)
- return;
-
- if (doFitting && fitting) {
- QRect viewRect = this->viewport()->rect();
- if (zoomMode == FitInView) {
- QList<QGraphicsItem*> containedItems = this->items(viewRect, Qt::ContainsItemBoundingRect);
- foreach(QGraphicsItem* item, containedItems) {
- PageItem* pg = static_cast<PageItem*>(item);
- if (pg->pageNumber() == curPage)
- return;
- }
- }
-
- int newPage = calcCurrentPage();
- if (newPage != curPage)
- curPage = newPage;
- }
-
- QRectF target = pages.at(curPage-1)->sceneBoundingRect();
- if (viewMode == FacingPagesView) {
- if (curPage % 2)
- target.setLeft(target.left() - target.width());
- else
- target.setRight(target.right() + target.width());
- } else if (viewMode == AllPagesView) {
- target = scene->itemsBoundingRect();
- }
-
- if (zoomMode == FitToWidth) {
- QTransform t;
- qreal scale = this->viewport()->width() / target.width();
- t.scale(scale, scale);
- this->setTransform(t);
- if (doFitting && fitting) {
- QRectF viewSceneRect = this->viewportTransform().mapRect(this->viewport()->rect());
- viewSceneRect.moveTop(target.top());
- this->ensureVisible(viewSceneRect); // Nah...
- }
- } else {
- this->fitInView(target, Qt::KeepAspectRatio);
- if (zoomMode == FitInView) {
- int step = qRound(this->matrix().mapRect(target).height());
- this->verticalScrollBar()->setSingleStep(step);
- this->verticalScrollBar()->setPageStep(step);
- }
- }
-
- //zoomFactor = this->transform().m11() * (float(printer->logicalDpiY()) / this->logicalDpiY());
+ if (curPage < 1 || curPage > pages.count())
+ return;
+ if (!doFitting && !fitting)
+ return;
+
+ if (doFitting && fitting) {
+ QRect viewRect = this->viewport()->rect();
+ if (zoomMode == FitInView) {
+ QList<QGraphicsItem*> containedItems = this->items(viewRect, Qt::ContainsItemBoundingRect);
+ foreach(QGraphicsItem* item, containedItems) {
+ PageItem* pg = static_cast<PageItem*>(item);
+ if (pg->pageNumber() == curPage)
+ return;
+ }
+ }
+
+ int newPage = calcCurrentPage();
+ if (newPage != curPage)
+ curPage = newPage;
+ }
+
+ QRectF target = pages.at(curPage-1)->sceneBoundingRect();
+ if (viewMode == FacingPagesView) {
+ if (curPage % 2)
+ target.setLeft(target.left() - target.width());
+ else
+ target.setRight(target.right() + target.width());
+ } else if (viewMode == AllPagesView) {
+ target = scene->itemsBoundingRect();
+ }
+
+ if (zoomMode == FitToWidth) {
+ QTransform t;
+ qreal scale = this->viewport()->width() / target.width();
+ t.scale(scale, scale);
+ this->setTransform(t);
+ if (doFitting && fitting) {
+ QRectF viewSceneRect = this->viewportTransform().mapRect(this->viewport()->rect());
+ viewSceneRect.moveTop(target.top());
+ this->ensureVisible(viewSceneRect); // Nah...
+ }
+ } else {
+ this->fitInView(target, Qt::KeepAspectRatio);
+ if (zoomMode == FitInView) {
+ int step = qRound(this->matrix().mapRect(target).height());
+ this->verticalScrollBar()->setSingleStep(step);
+ this->verticalScrollBar()->setPageStep(step);
+ }
+ }
+
+ //zoomFactor = this->transform().m11() * (float(printer->logicalDpiY()) / this->logicalDpiY());
}
//Makes sure degrees is between 0 and 360 then rotates the matrix and
void PrintWidget::setDegrees(int degrees) {
//Mods by 360, but adds and remods because of how C++ treats negative mods
this->degrees = ( ( ( this->degrees + degrees ) % 360 ) + 360 ) % 360;
- rotMatrix.rotate(degrees);
- this->updatePreview();
+ rotMatrix.rotate(degrees);
+ this->updatePreview();
}
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
index b66428e8..476ef596 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
@@ -25,54 +25,54 @@
class PageItem : public QGraphicsItem {
public:
- PageItem(int _pageNum, QImage _pagePicture, QSize _paperSize)
+ PageItem(int _pageNum, QImage _pagePicture, QSize _paperSize)
: pageNum(_pageNum), pagePicture(_pagePicture), paperSize(_paperSize)
- {
- brect = QRectF(QPointF(-25, -25),
- QSizeF(paperSize)+QSizeF(50, 50));
- setCacheMode(DeviceCoordinateCache);
- }
-
- QRectF boundingRect() const Q_DECL_OVERRIDE
- { return brect; }
-
- inline int pageNumber() const
- { return pageNum; }
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE
- {
- Q_UNUSED(widget);
- //Ensure all the antialiasing/smoothing options are turned on
- painter->setRenderHint(QPainter::Antialiasing);
- painter->setRenderHint(QPainter::TextAntialiasing);
- painter->setRenderHint(QPainter::SmoothPixmapTransform);
-
- QRectF paperRect(0,0, paperSize.width(), paperSize.height());
- // Draw shadow
- painter->setClipRect(option->exposedRect);
- qreal shWidth = paperRect.width()/100;
- QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
- paperRect.bottomRight() + QPointF(shWidth, 0));
- QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
- rgrad.setColorAt(0.0, QColor(0,0,0,255));
- rgrad.setColorAt(1.0, QColor(0,0,0,0));
- painter->fillRect(rshadow, QBrush(rgrad));
- QRectF bshadow(paperRect.bottomLeft() + QPointF(shWidth, 0),
- paperRect.bottomRight() + QPointF(0, shWidth));
- QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
- bgrad.setColorAt(0.0, QColor(0,0,0,255));
- bgrad.setColorAt(1.0, QColor(0,0,0,0));
- painter->fillRect(bshadow, QBrush(bgrad));
- QRectF cshadow(paperRect.bottomRight(),
- paperRect.bottomRight() + QPointF(shWidth, shWidth));
- QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
- cgrad.setColorAt(0.0, QColor(0,0,0,255));
- cgrad.setColorAt(1.0, QColor(0,0,0,0));
- painter->fillRect(cshadow, QBrush(cgrad));
- painter->setClipRect(paperRect & option->exposedRect);
- painter->fillRect(paperRect, Qt::white);
- painter->drawImage(QPoint(0,0), pagePicture);
- }
+ {
+ brect = QRectF(QPointF(-25, -25),
+ QSizeF(paperSize)+QSizeF(50, 50));
+ setCacheMode(DeviceCoordinateCache);
+ }
+
+ QRectF boundingRect() const Q_DECL_OVERRIDE
+ { return brect; }
+
+ inline int pageNumber() const
+ { return pageNum; }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE
+ {
+ Q_UNUSED(widget);
+ //Ensure all the antialiasing/smoothing options are turned on
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setRenderHint(QPainter::TextAntialiasing);
+ painter->setRenderHint(QPainter::SmoothPixmapTransform);
+
+ QRectF paperRect(0,0, paperSize.width(), paperSize.height());
+ // Draw shadow
+ painter->setClipRect(option->exposedRect);
+ qreal shWidth = paperRect.width()/100;
+ QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
+ paperRect.bottomRight() + QPointF(shWidth, 0));
+ QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
+ rgrad.setColorAt(0.0, QColor(0,0,0,255));
+ rgrad.setColorAt(1.0, QColor(0,0,0,0));
+ painter->fillRect(rshadow, QBrush(rgrad));
+ QRectF bshadow(paperRect.bottomLeft() + QPointF(shWidth, 0),
+ paperRect.bottomRight() + QPointF(0, shWidth));
+ QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
+ bgrad.setColorAt(0.0, QColor(0,0,0,255));
+ bgrad.setColorAt(1.0, QColor(0,0,0,0));
+ painter->fillRect(bshadow, QBrush(bgrad));
+ QRectF cshadow(paperRect.bottomRight(),
+ paperRect.bottomRight() + QPointF(shWidth, shWidth));
+ QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
+ cgrad.setColorAt(0.0, QColor(0,0,0,255));
+ cgrad.setColorAt(1.0, QColor(0,0,0,0));
+ painter->fillRect(cshadow, QBrush(cgrad));
+ painter->setClipRect(paperRect & option->exposedRect);
+ painter->fillRect(paperRect, Qt::white);
+ painter->drawImage(QPoint(0,0), pagePicture);
+ }
private:
int pageNum;
@@ -84,85 +84,85 @@ private:
class PrintWidget : public QGraphicsView
{
- Q_OBJECT
+ Q_OBJECT
public:
- enum ViewMode {
- SinglePageView,
- FacingPagesView,
- AllPagesView
- };
-
- enum ZoomMode {
- CustomZoom,
- FitToWidth,
- FitInView
- };
+ enum ViewMode {
+ SinglePageView,
+ FacingPagesView,
+ AllPagesView
+ };
+
+ enum ZoomMode {
+ CustomZoom,
+ FitToWidth,
+ FitInView
+ };
private:
- void generatePreview();
- void layoutPages();
- void populateScene();
- void setViewMode(ViewMode);
- void setZoomMode(ZoomMode);
-
- QGraphicsScene *scene;
- QMatrix rotMatrix;
- int curPage, publicPageNum;
- ViewMode viewMode;
- ZoomMode zoomMode;
- QPageLayout::Orientation orientation;
- double zoomFactor;
- bool initialized, fitting;
- QList<QGraphicsItem*> pages;
- int degrees;
- Renderer *BACKEND;
+ void generatePreview();
+ void layoutPages();
+ void populateScene();
+ void setViewMode(ViewMode);
+ void setZoomMode(ZoomMode);
+
+ QGraphicsScene *scene;
+ QMatrix rotMatrix;
+ int curPage, publicPageNum;
+ ViewMode viewMode;
+ ZoomMode zoomMode;
+ QPageLayout::Orientation orientation;
+ double zoomFactor;
+ bool initialized, fitting;
+ QList<QGraphicsItem*> pages;
+ int degrees;
+ Renderer *BACKEND;
public:
- PrintWidget(Renderer *backend, QWidget *parent = 0);
- ~PrintWidget();
+ PrintWidget(Renderer *backend, QWidget *parent = 0);
+ ~PrintWidget();
- double getZoomFactor() const { return this->zoomFactor; };
- ZoomMode getZoomMode() const { return this->zoomMode; };
- int currentPage() const { return publicPageNum; };
+ double getZoomFactor() const { return this->zoomFactor; };
+ ZoomMode getZoomMode() const { return this->zoomMode; };
+ int currentPage() const { return publicPageNum; };
signals:
- void resized();
- void customContextMenuRequested(const QPoint&);
- void currentPageChanged();
+ void resized();
+ void customContextMenuRequested(const QPoint&);
+ void currentPageChanged();
public slots:
- void zoomIn(double factor=1.2);
- void zoomOut(double factor=1.2);
- void setCurrentPage(int);
- void setVisible(bool) Q_DECL_OVERRIDE;
- void highlightText(TextData*);
- void setDegrees(int);
-
- void updatePreview();
- void fitView();
- void fitToWidth();
- void setAllPagesViewMode();
- void setSinglePageViewMode();
- void setFacingPagesViewMode();
+ void zoomIn(double factor=1.2);
+ void zoomOut(double factor=1.2);
+ void setCurrentPage(int);
+ void setVisible(bool) Q_DECL_OVERRIDE;
+ void highlightText(TextData*);
+ void setDegrees(int);
+
+ void updatePreview();
+ void fitView();
+ void fitToWidth();
+ void setAllPagesViewMode();
+ void setSinglePageViewMode();
+ void setFacingPagesViewMode();
private slots:
- void updateCurrentPage();
- int calcCurrentPage();
- void fit(bool doFitting=false);
+ void updateCurrentPage();
+ int calcCurrentPage();
+ void fit(bool doFitting=false);
protected:
- void resizeEvent(QResizeEvent* e) Q_DECL_OVERRIDE {
- /*{
- const QSignalBlocker blocker(verticalScrollBar()); // Don't change page, QTBUG-14517
- QGraphicsView::resizeEvent(e);
- }*/
- QGraphicsView::resizeEvent(e);
- emit resized();
- }
-
- void showEvent(QShowEvent* e) Q_DECL_OVERRIDE {
- QGraphicsView::showEvent(e);
- emit resized();
- }
+ void resizeEvent(QResizeEvent* e) Q_DECL_OVERRIDE {
+ /*{
+ const QSignalBlocker blocker(verticalScrollBar()); // Don't change page, QTBUG-14517
+ QGraphicsView::resizeEvent(e);
+ }*/
+ QGraphicsView::resizeEvent(e);
+ emit resized();
+ }
+
+ void showEvent(QShowEvent* e) Q_DECL_OVERRIDE {
+ QGraphicsView::showEvent(e);
+ emit resized();
+ }
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp
index a9c79971..48c67b0e 100644
--- a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp
@@ -6,28 +6,28 @@
#include <QtConcurrent>
class Data {
- public:
- Data(int _pagenum, fz_context *_ctx, fz_display_list *_list, fz_rect _bbox, fz_pixmap *_pix, fz_matrix _ctm, double _sf) :
- pagenumber(_pagenum),
- ctx(_ctx),
- list(_list),
- bbox(_bbox),
- pix(_pix),
- ctm(_ctm),
- sf(_sf)
- { }
-
- ~Data() { }
-
- int pagenumber;
- fz_context *ctx;
- fz_display_list *list;
- fz_rect bbox;
- fz_pixmap *pix;
- fz_matrix ctm;
- QImage img;
- QFuture<void> renderThread;
- double sf;
+ public:
+ Data(int _pagenum, fz_context *_ctx, fz_display_list *_list, fz_rect _bbox, fz_pixmap *_pix, fz_matrix _ctm, double _sf) :
+ pagenumber(_pagenum),
+ ctx(_ctx),
+ list(_list),
+ bbox(_bbox),
+ pix(_pix),
+ ctm(_ctm),
+ sf(_sf)
+ { }
+
+ ~Data() { }
+
+ int pagenumber;
+ fz_context *ctx;
+ fz_display_list *list;
+ fz_rect bbox;
+ fz_pixmap *pix;
+ fz_matrix ctm;
+ QImage img;
+ QFuture<void> renderThread;
+ double sf;
};
fz_document *DOC;
@@ -37,167 +37,167 @@ QMutex mutex[FZ_LOCK_MAX];
fz_locks_context locks;
inline QString getTextInfo(QString str) {
- char infoBuff[1000];
- int size = DOC->lookup_metadata(CTX, DOC, ("info:"+str).toLocal8Bit().data(), infoBuff, 1000);
+ char infoBuff[1000];
+ int size = DOC->lookup_metadata(CTX, DOC, ("info:"+str).toLocal8Bit().data(), infoBuff, 1000);
if(size != -1){ return QString::fromLatin1(infoBuff); }
return "";
}
void lock_mutex(void *user, int lock) {
- QMutex *mutex = (QMutex*) user;
- mutex[lock].lock();
+ QMutex *mutex = (QMutex*) user;
+ mutex[lock].lock();
}
void unlock_mutex(void *user, int lock) {
- QMutex *mutex = (QMutex*) user;
- mutex[lock].unlock();
+ QMutex *mutex = (QMutex*) user;
+ mutex[lock].unlock();
}
Renderer::Renderer(){
- locks.user = mutex;
- locks.lock = lock_mutex;
- locks.unlock = unlock_mutex;
+ locks.user = mutex;
+ locks.lock = lock_mutex;
+ locks.unlock = unlock_mutex;
DOC = 0;
- qDebug() << "Creating Context";
+ qDebug() << "Creating Context";
CTX = fz_new_context(NULL, &locks, FZ_STORE_UNLIMITED);
needpass = false;
}
Renderer::~Renderer(){
- qDebug() << "Calling destructor";
- qDeleteAll(dataHash);
- dataHash.clear();
- fz_drop_document(CTX, DOC);
- DOC = NULL;
- fz_drop_context(CTX);
- CTX = NULL;
+ qDebug() << "Calling destructor";
+ qDeleteAll(dataHash);
+ dataHash.clear();
+ fz_drop_document(CTX, DOC);
+ DOC = NULL;
+ fz_drop_context(CTX);
+ CTX = NULL;
}
bool Renderer::loadMultiThread(){ return false; }
void Renderer::cleanup() {
- /*for(int i = 0; i < dataHash.size(); i++) {
- fz_drop_pixmap(CTX, dataHash[i]->pix);
- fz_drop_display_list(CTX, dataHash[i]->list);
- }
- fz_drop_document(CTX, DOC);
- fz_drop_context(CTX);*/
+ /*for(int i = 0; i < dataHash.size(); i++) {
+ fz_drop_pixmap(CTX, dataHash[i]->pix);
+ fz_drop_display_list(CTX, dataHash[i]->list);
+ }
+ fz_drop_document(CTX, DOC);
+ fz_drop_context(CTX);*/
}
bool Renderer::loadDocument(QString path, QString password){
- //first time through
- if(path != docpath) {
- if(DOC != 0) {
- qDebug() << "New document";
- fz_drop_document(CTX, DOC);
- DOC = NULL;
- needpass = false;
- docpath = path;
- }else if(DOC==0){
- fz_register_document_handlers(CTX);
- qDebug() << "Document handlers registered";
- }
-
- DOC = fz_open_document(CTX, path.toLocal8Bit().data());
- docpath = path;
- qDebug() << "File opened" << DOC;
- if(DOC==0){
- qDebug() << "Could not open file:" << path;
- return false;
- }
- needpass = (fz_needs_password(CTX, DOC) != 0);
-
- if(needpass && password.isEmpty()){
- return false;
- }else if(needpass){
- needpass = !fz_authenticate_password(CTX, DOC, password.toLocal8Bit());
- if(needpass){ return false; } //incorrect password
- }
-
- //qDebug() << "Password Check cleared";
- pnum = fz_count_pages(CTX, DOC);
- qDebug() << "Page count: " << pnum;
-
- doctitle.clear();
- //qDebug() << "Opening File:" << path;
- jobj.insert("title", getTextInfo("Title") );
- jobj.insert("subject", getTextInfo("Subject") );
- jobj.insert("author", getTextInfo("Author") );
- jobj.insert("creator", getTextInfo("Creator") );
- jobj.insert("producer", getTextInfo("Producer") );
- jobj.insert("keywords", getTextInfo("Keywords") );
- jobj.insert("dt_created", QDateTime::fromString( getTextInfo("CreationDate").left(16), "'D:'yyyyMMddHHmmss").toString() );
- jobj.insert("dt_modified", QDateTime::fromString( getTextInfo("ModDate").left(16), "'D:'yyyyMMddHHmmss").toString() );
-
- if(!jobj["title"].isNull())
- doctitle = jobj["title"].toString();
- else
- doctitle = path.section("/",-1);
-
- qDebug() << "Page Loaded";
- //Possibly check Page orientation
- return true;
- }
- return false;
+ //first time through
+ if(path != docpath) {
+ if(DOC != 0) {
+ qDebug() << "New document";
+ fz_drop_document(CTX, DOC);
+ DOC = NULL;
+ needpass = false;
+ docpath = path;
+ }else if(DOC==0){
+ fz_register_document_handlers(CTX);
+ qDebug() << "Document handlers registered";
+ }
+
+ DOC = fz_open_document(CTX, path.toLocal8Bit().data());
+ docpath = path;
+ qDebug() << "File opened" << DOC;
+ if(DOC==0){
+ qDebug() << "Could not open file:" << path;
+ return false;
+ }
+ needpass = (fz_needs_password(CTX, DOC) != 0);
+
+ if(needpass && password.isEmpty()){
+ return false;
+ }else if(needpass){
+ needpass = !fz_authenticate_password(CTX, DOC, password.toLocal8Bit());
+ if(needpass){ return false; } //incorrect password
+ }
+
+ //qDebug() << "Password Check cleared";
+ pnum = fz_count_pages(CTX, DOC);
+ qDebug() << "Page count: " << pnum;
+
+ doctitle.clear();
+ //qDebug() << "Opening File:" << path;
+ jobj.insert("title", getTextInfo("Title") );
+ jobj.insert("subject", getTextInfo("Subject") );
+ jobj.insert("author", getTextInfo("Author") );
+ jobj.insert("creator", getTextInfo("Creator") );
+ jobj.insert("producer", getTextInfo("Producer") );
+ jobj.insert("keywords", getTextInfo("Keywords") );
+ jobj.insert("dt_created", QDateTime::fromString( getTextInfo("CreationDate").left(16), "'D:'yyyyMMddHHmmss").toString() );
+ jobj.insert("dt_modified", QDateTime::fromString( getTextInfo("ModDate").left(16), "'D:'yyyyMMddHHmmss").toString() );
+
+ if(!jobj["title"].isNull())
+ doctitle = jobj["title"].toString();
+ else
+ doctitle = path.section("/",-1);
+
+ qDebug() << "Page Loaded";
+ //Possibly check Page orientation
+ return true;
+ }
+ return false;
}
void renderer(Data *data, Renderer *obj)
{
- int pagenum = data->pagenumber;
- fz_context *ctx = data->ctx;
- fz_display_list *list = data->list;
- fz_rect bbox = data->bbox;
- fz_pixmap *pixmap = data->pix;
- fz_matrix ctm = data->ctm;
- fz_device *dev;
-
- ctx = fz_clone_context(ctx);
- dev = fz_new_draw_device(ctx, &fz_identity, pixmap);
- fz_run_display_list(ctx, list, dev, &ctm, &bbox, NULL);
-
- data->img = QImage(pixmap->samples, pixmap->w, pixmap->h, pixmap->stride, QImage::Format_RGB888);
- fz_close_device(ctx, dev);
- fz_drop_device(ctx, dev);
-
- fz_drop_context(ctx);
-
- dataHash.insert(pagenum, data);
- emit obj->PageLoaded(pagenum);
+ int pagenum = data->pagenumber;
+ fz_context *ctx = data->ctx;
+ fz_display_list *list = data->list;
+ fz_rect bbox = data->bbox;
+ fz_pixmap *pixmap = data->pix;
+ fz_matrix ctm = data->ctm;
+ fz_device *dev;
+
+ ctx = fz_clone_context(ctx);
+ dev = fz_new_draw_device(ctx, &fz_identity, pixmap);
+ fz_run_display_list(ctx, list, dev, &ctm, &bbox, NULL);
+
+ data->img = QImage(pixmap->samples, pixmap->w, pixmap->h, pixmap->stride, QImage::Format_RGB888);
+ fz_close_device(ctx, dev);
+ fz_drop_device(ctx, dev);
+
+ fz_drop_context(ctx);
+
+ dataHash.insert(pagenum, data);
+ emit obj->PageLoaded(pagenum);
}
//Consider rendering through a display list
void Renderer::renderPage(int pagenum, QSize DPI){
- //qDebug() << "- Rendering Page:" << pagenum;
- fz_matrix matrix;
- fz_rect bbox;
- fz_irect rbox;
- fz_pixmap *pixmap;
- fz_display_list *list;
-
- double pageDPI = 96.0;
- double sf = DPI.width() / pageDPI;
- fz_scale(&matrix, DPI.width()/pageDPI, DPI.height()/pageDPI);
-
- fz_page *PAGE = fz_load_page(CTX, DOC, pagenum);
- fz_bound_page(CTX, PAGE, &bbox);
- emit OrigSize(QSizeF(bbox.x1 - bbox.x0, bbox.y1 - bbox.y0));
-
- fz_transform_rect(&bbox, &matrix);
- list = fz_new_display_list(CTX, &bbox);
- fz_device *dev = fz_new_list_device(CTX, list);
- fz_run_page(CTX, PAGE, dev, &fz_identity, NULL);
-
- fz_close_device(CTX, dev);
- fz_drop_device(CTX, dev);
- fz_drop_page(CTX, PAGE);
-
- pixmap = fz_new_pixmap_with_bbox(CTX, fz_device_rgb(CTX), fz_round_rect(&rbox, &bbox), NULL, 0);
- fz_clear_pixmap_with_value(CTX, pixmap, 0xff);
-
- //pixmap = fz_new_pixmap_from_page_number(CTX, DOC, pagenum, &matrix, fz_device_rgb(CTX), 0);
- Data *data = new Data(pagenum, CTX, list, bbox, pixmap, matrix, sf);
- data->renderThread = QtConcurrent::run(&renderer, data, this);
+ //qDebug() << "- Rendering Page:" << pagenum;
+ fz_matrix matrix;
+ fz_rect bbox;
+ fz_irect rbox;
+ fz_pixmap *pixmap;
+ fz_display_list *list;
+
+ double pageDPI = 96.0;
+ double sf = DPI.width() / pageDPI;
+ fz_scale(&matrix, DPI.width()/pageDPI, DPI.height()/pageDPI);
+
+ fz_page *PAGE = fz_load_page(CTX, DOC, pagenum);
+ fz_bound_page(CTX, PAGE, &bbox);
+ emit OrigSize(QSizeF(bbox.x1 - bbox.x0, bbox.y1 - bbox.y0));
+
+ fz_transform_rect(&bbox, &matrix);
+ list = fz_new_display_list(CTX, &bbox);
+ fz_device *dev = fz_new_list_device(CTX, list);
+ fz_run_page(CTX, PAGE, dev, &fz_identity, NULL);
+
+ fz_close_device(CTX, dev);
+ fz_drop_device(CTX, dev);
+ fz_drop_page(CTX, PAGE);
+
+ pixmap = fz_new_pixmap_with_bbox(CTX, fz_device_rgb(CTX), fz_round_rect(&rbox, &bbox), NULL, 0);
+ fz_clear_pixmap_with_value(CTX, pixmap, 0xff);
+
+ //pixmap = fz_new_pixmap_from_page_number(CTX, DOC, pagenum, &matrix, fz_device_rgb(CTX), 0);
+ Data *data = new Data(pagenum, CTX, list, bbox, pixmap, matrix, sf);
+ data->renderThread = QtConcurrent::run(&renderer, data, this);
}
QList<TextData*> Renderer::searchDocument(QString text, bool matchCase){
@@ -207,7 +207,7 @@ QList<TextData*> Renderer::searchDocument(QString text, bool matchCase){
int count = fz_search_display_list(CTX, dataHash[i]->list, text.toLatin1().data(), rectBuffer, 1000);
//qDebug() << "Page " << i+1 << ": Count, " << count;
for(int j = 0; j < count; j++) {
- double sf = dataHash[i]->sf;
+ double sf = dataHash[i]->sf;
QRectF rect(rectBuffer[j].x0*sf, rectBuffer[j].y0*sf, (rectBuffer[j].x1-rectBuffer[j].x0)*sf, (rectBuffer[j].y1 - rectBuffer[j].y0)*sf);
TextData *t = new TextData(rect, i+1, text);
//MuPDF search does not match case, so retrieve the exact text at the location found and determine whether or not it matches the case of the search text if the user selected to match case
@@ -224,13 +224,13 @@ QList<TextData*> Renderer::searchDocument(QString text, bool matchCase){
}
QImage Renderer::imageHash(int pagenum) {
- return dataHash[pagenum]->img;
+ return dataHash[pagenum]->img;
}
int Renderer::hashSize() {
- return dataHash.size();
+ return dataHash.size();
}
void Renderer::clearHash() {
- dataHash.clear();
+ dataHash.clear();
}
diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp
index 9ad29eba..e37d715d 100644
--- a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp
@@ -12,8 +12,8 @@ Renderer::Renderer(){
}
Renderer::~Renderer(){
- //qDeleteAll(loadingHash);
- loadingHash.clear();
+ //qDeleteAll(loadingHash);
+ loadingHash.clear();
}
bool Renderer::loadMultiThread(){ return true; }
@@ -30,13 +30,13 @@ bool Renderer::loadDocument(QString path, QString password){
DOC=0;
needpass = false;
pnum=0;
- docpath = path;
+ docpath = path;
}
//Load the Document (if needed);
if(DOC==0){
//qDebug() << "Loading Document";
DOC = Poppler::Document::load(path);
- docpath = path;
+ docpath = path;
}
if(DOC==0){
@@ -73,45 +73,45 @@ void Renderer::cleanup() {}
void Renderer::renderPage(int pagenum, QSize DPI){
//qDebug() << "Render Page:" << pagenum << DPI;
if(DOC!=0){
- Poppler::Page *PAGE = DOC->page(pagenum);
- QImage img;
- if(PAGE!=0){
- //qDebug() << "Render Page:" << pagenum;
- img = PAGE->renderToImage(DPI.width(),DPI.height());
- loadingHash.insert(pagenum, img);
- //qDebug() << "Image after creation:" << img.isNull();
- delete PAGE;
- }
- //qDebug() << "Done Render Page:" << pagenum << img.size();
- }else{
- loadingHash.insert(pagenum, QImage());
- }
- emit PageLoaded(pagenum);
+ Poppler::Page *PAGE = DOC->page(pagenum);
+ QImage img;
+ if(PAGE!=0){
+ //qDebug() << "Render Page:" << pagenum;
+ img = PAGE->renderToImage(DPI.width(),DPI.height());
+ loadingHash.insert(pagenum, img);
+ //qDebug() << "Image after creation:" << img.isNull();
+ delete PAGE;
+ }
+ //qDebug() << "Done Render Page:" << pagenum << img.size();
+ }else{
+ loadingHash.insert(pagenum, QImage());
+ }
+ emit PageLoaded(pagenum);
}
QList<TextData*> Renderer::searchDocument(QString text, bool matchCase){
QList<TextData*> results;
for(int i = 0; i < pnum; i++) {
- QList<Poppler::TextBox*> textList = DOC->page(i)->textList();
+ QList<Poppler::TextBox*> textList = DOC->page(i)->textList();
for(int j = 0; j < textList.size(); j++) {
- if(textList[j]->text().contains(text,
- (matchCase) ? Qt::CaseSensitive : Qt::CaseInsensitive)) {
- TextData *t = new TextData(textList[j]->boundingBox(), i+1, text);
- results.append(t);
- }
+ if(textList[j]->text().contains(text,
+ (matchCase) ? Qt::CaseSensitive : Qt::CaseInsensitive)) {
+ TextData *t = new TextData(textList[j]->boundingBox(), i+1, text);
+ results.append(t);
+ }
}
}
return results;
}
QImage Renderer::imageHash(int pagenum) {
- return loadingHash[pagenum];
+ return loadingHash[pagenum];
}
int Renderer::hashSize() {
- return loadingHash.keys().length();
+ return loadingHash.keys().length();
}
void Renderer::clearHash() {
- loadingHash.clear();
+ loadingHash.clear();
}
diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer.h b/src-qt5/desktop-utils/lumina-pdf/Renderer.h
index 60db25ef..b983d14b 100644
--- a/src-qt5/desktop-utils/lumina-pdf/Renderer.h
+++ b/src-qt5/desktop-utils/lumina-pdf/Renderer.h
@@ -17,36 +17,36 @@ class Renderer : public QObject {
Q_OBJECT
private:
- int pnum; //number of pages - set on loading document
- bool needpass;
- QString docpath; //save the path for the currently-loaded document
- QString doctitle;
- QJsonObject jobj;
+ int pnum; //number of pages - set on loading document
+ bool needpass;
+ QString docpath; //save the path for the currently-loaded document
+ QString doctitle;
+ QJsonObject jobj;
public:
- Renderer();
- ~Renderer();
- bool loadMultiThread();
-
- //Information functions (usually needs to be loaded first)
- int numPages(){ return pnum; }
- bool needPassword(){ return needpass; }
- QString title(){ return doctitle; }
- QJsonObject properties() { return jobj; }
-
- //Main access functions
- bool loadDocument(QString path, QString password);
- void renderPage(int pagenum, QSize DPI);
- QList<TextData*> searchDocument(QString text, bool matchCase);
- void cleanup();
-
- QImage imageHash(int pagenum);
- int hashSize();
- void clearHash();
+ Renderer();
+ ~Renderer();
+ bool loadMultiThread();
+
+ //Information functions (usually needs to be loaded first)
+ int numPages(){ return pnum; }
+ bool needPassword(){ return needpass; }
+ QString title(){ return doctitle; }
+ QJsonObject properties() { return jobj; }
+
+ //Main access functions
+ bool loadDocument(QString path, QString password);
+ void renderPage(int pagenum, QSize DPI);
+ QList<TextData*> searchDocument(QString text, bool matchCase);
+ void cleanup();
+
+ QImage imageHash(int pagenum);
+ int hashSize();
+ void clearHash();
signals:
- void PageLoaded(int);
- void OrigSize(QSizeF);
+ void PageLoaded(int);
+ void OrigSize(QSizeF);
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
index 936243d2..e056b0b2 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
@@ -36,7 +36,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
WIDGET->setVisible(false);
WIDGET->setContextMenuPolicy(Qt::CustomContextMenu);
WIDGET->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- loadingQueue.clear();
+ loadingQueue.clear();
clockTimer = new QTimer(this);
clockTimer->setInterval(1000); //1-second updates to clock
connect(clockTimer, SIGNAL(timeout()), this, SLOT(updateClock()) );
@@ -241,8 +241,8 @@ void MainUI::loadFile(QString path){
}
//Clear the current display
- WIDGET->setVisible(false);
- BACKEND->clearHash();
+ WIDGET->setVisible(false);
+ BACKEND->clearHash();
QTimer::singleShot(10, WIDGET, SLOT(updatePreview()));
//Load the new document info
this->setWindowTitle( BACKEND->title());
@@ -254,7 +254,7 @@ void MainUI::loadFile(QString path){
void MainUI::loadPage(int num, MainUI *obj, QSize dpi){
//qDebug() << " - Render Page:" << num;
BACKEND->renderPage(num, dpi);
- //qDebug() << "Image at" << num << "accessed outside:" << BACKEND->imageHash(num).isNull();
+ //qDebug() << "Image at" << num << "accessed outside:" << BACKEND->imageHash(num).isNull();
}
QScreen* MainUI::getScreen(bool current, bool &cancelled){
@@ -367,7 +367,7 @@ void MainUI::endPresentation(){
void MainUI::startLoadingPages(){
//qDebug() <<"Start Loading Pages";
if(BACKEND->hashSize() != 0) { return; } //currently loaded[ing]
- loadingQueue.clear();
+ loadingQueue.clear();
//qDebug() << "Update Progress Bar";
progress->setRange(0, BACKEND->numPages());
progress->setValue(0);
@@ -387,24 +387,24 @@ void MainUI::startLoadingPages(){
}
for(int i=0; i<BACKEND->numPages(); i++){
//qDebug() << " - Kickoff page load:" << i;
- if(BACKEND->loadMultiThread()) {
- QtConcurrent::run(this, &MainUI::loadPage, i, this, DPI);
- }else{
- BACKEND->renderPage(i, DPI);
- }
+ if(BACKEND->loadMultiThread()) {
+ QtConcurrent::run(this, &MainUI::loadPage, i, this, DPI);
+ }else{
+ BACKEND->renderPage(i, DPI);
+ }
}
//qDebug() << "Finish page loading kickoff";
}
void MainUI::slotPageLoaded(int page){
- loadingQueue.push_back(page);
+ loadingQueue.push_back(page);
int finished = loadingQueue.size();
//qDebug() << "Page Loaded:" << page << finished;
if(finished == BACKEND->numPages()){
- BACKEND->cleanup();
- //qDebug() << " - finished:" << finished;
+ BACKEND->cleanup();
+ //qDebug() << " - finished:" << finished;
progAct->setVisible(false);
- WIDGET->setVisible(true);
+ WIDGET->setVisible(true);
WIDGET->setCurrentPage(1);
PROPDIALOG = new PropDialog(BACKEND);
PROPDIALOG->setSize(pageSize);
@@ -426,7 +426,7 @@ void MainUI::paintToPrinter(QPrinter *PRINTER){
int firstpage = 0;
int copies = PRINTER->copyCount();
bool collate = PRINTER->collateCopies();
- bool reverse = (PRINTER->pageOrder()==QPrinter::LastPageFirst);
+ bool reverse = (PRINTER->pageOrder()==QPrinter::LastPageFirst);
qDebug() << "PRINTER DPI:" << PRINTER->resolution() << PRINTER->supportedResolutions();
if(PRINTER->resolution() < 300){
//Try to get 300 DPI resolution at least
@@ -447,11 +447,11 @@ void MainUI::paintToPrinter(QPrinter *PRINTER){
//Make sure even/odd pages are not selected as desired
//Qt 5.7.1 does not seem to have even/odd page selections - 8/11/2017
pageCount << i; //add this page to the list
- //QT 5.9+ : Do not need to manually stack "copies". Already handled internally
+ //QT 5.9+ : Do not need to manually stack "copies". Already handled internally
//for(int c=1; c<copies && !collate; c++){ pageCount << i; } //add any copies of this page as needed
}
//qDebug() << "Got Page Range:" << pageCount;
- //QT 5.9+ : Do not need to manually reverse the pages (already handled internally)
+ //QT 5.9+ : Do not need to manually reverse the pages (already handled internally)
if(reverse) {
//Need to reverse the order of the list
QList<int> tmp = pageCount;
@@ -459,7 +459,7 @@ void MainUI::paintToPrinter(QPrinter *PRINTER){
for(int i=tmp.length()-1; i>=0; i--){ pageCount << tmp[i]; }
//qDebug() << " - reversed:" << pageCount;
}
- //QT 5.9+ : Do not need to manually stack "copies". Already handled internally;
+ //QT 5.9+ : Do not need to manually stack "copies". Already handled internally;
/*if(collate && copies>0){
QList<int> orig = pageCount; //original array of pages
for(int c=1; c<copies; c++){
@@ -485,7 +485,7 @@ void MainUI::paintToPrinter(QPrinter *PRINTER){
progress->setRange(0, pageCount.length()-1);
for(int i=0; i<pageCount.length(); i++){
if(i!=0){ PRINTER->newPage(); }
- //qDebug() << "Printing Page:" << pageCount[i];
+ //qDebug() << "Printing Page:" << pageCount[i];
progress->setValue(i);
QApplication::processEvents();
QImage img = BACKEND->imageHash(pageCount[i]).scaled(sz, Qt::KeepAspectRatio, Qt::SmoothTransformation);
@@ -566,10 +566,10 @@ void MainUI::keyPressEvent(QKeyEvent *event){
QWheelEvent wEvent( WIDGET->mapFromGlobal(QCursor::pos()), QCursor::pos(),QPoint(0,0), QPoint(0,30), 0, Qt::Vertical, Qt::LeftButton, Qt::NoModifier);
QApplication::sendEvent(WIDGET, &wEvent);*/
}else if(event->key() == Qt::Key_Enter) {
- /*if(ui->findGroup->hasFocus()) {
- find(ui->textEdit->text(), true);
- }*/
- }else{
+ /*if(ui->findGroup->hasFocus()) {
+ find(ui->textEdit->text(), true);
+ }*/
+ }else{
QMainWindow::keyPressEvent(event);
}
}
@@ -600,7 +600,7 @@ void MainUI::find(QString text, bool forward) {
delete td;
results.clear();
}
- WIDGET->updatePreview();
+ WIDGET->updatePreview();
ui->resultsLabel->setText("");
//Get the new search results
results = BACKEND->searchDocument(text, matchCase);
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
index af12c33c..89fbed1d 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.h
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
@@ -27,85 +27,85 @@
#include "textData.h"
namespace Ui{
- class MainUI;
+ class MainUI;
};
class MainUI : public QMainWindow{
- Q_OBJECT
+ Q_OBJECT
public:
- MainUI();
- ~MainUI();
+ MainUI();
+ ~MainUI();
- void loadFile(QString path);
+ void loadFile(QString path);
private:
- QSizeF pageSize;
- PrintWidget *WIDGET;
- Ui::MainUI *ui;
- PropDialog *PROPDIALOG;
- QPrintDialog *PrintDLG;
- QString lastdir;
- bool matchCase;
- QList<TextData*> results;
- QList<int> loadingQueue;
- int currentHighlight;
-
- //Other Interface elements
- QProgressBar *progress;
- QAction *progAct; //action associated with the progressbar
- QTimer *clockTimer;
- QMenu *contextMenu;
- //QFrame *frame_presenter;
- QLabel *label_clock, *label_page;
- QAction *clockAct, *pageAct;
-
- //PDF Page Loading cache variables
- Renderer *BACKEND;
-
- void loadPage(int num, MainUI *obj, QSize dpi);
-
- //Functions/variables for the presentation mode
- PresentationLabel *presentationLabel;
- QScreen *getScreen(bool current, bool &cancelled);
- int CurrentPage;
- void startPresentation(bool atStart);
- void ShowPage(int page);
- void endPresentation();
+ QSizeF pageSize;
+ PrintWidget *WIDGET;
+ Ui::MainUI *ui;
+ PropDialog *PROPDIALOG;
+ QPrintDialog *PrintDLG;
+ QString lastdir;
+ bool matchCase;
+ QList<TextData*> results;
+ QList<int> loadingQueue;
+ int currentHighlight;
+
+ //Other Interface elements
+ QProgressBar *progress;
+ QAction *progAct; //action associated with the progressbar
+ QTimer *clockTimer;
+ QMenu *contextMenu;
+ //QFrame *frame_presenter;
+ QLabel *label_clock, *label_page;
+ QAction *clockAct, *pageAct;
+
+ //PDF Page Loading cache variables
+ Renderer *BACKEND;
+
+ void loadPage(int num, MainUI *obj, QSize dpi);
+
+ //Functions/variables for the presentation mode
+ PresentationLabel *presentationLabel;
+ QScreen *getScreen(bool current, bool &cancelled);
+ int CurrentPage;
+ void startPresentation(bool atStart);
+ void ShowPage(int page);
+ void endPresentation();
private slots:
- void startLoadingPages();
- void slotPageLoaded(int);
+ void startLoadingPages();
+ void slotPageLoaded(int);
- //Simplification routines
- void nextPage(){ ShowPage( WIDGET->currentPage()+1 ); } //currentPage() starts at 1 rather than 0
- void prevPage(){ ShowPage( WIDGET->currentPage()-1 ); } //currentPage() starts at 1 rather than 0
- void firstPage(){ ShowPage(1); }
- void lastPage(){ ShowPage(BACKEND->numPages()); }
- void startPresentationHere(){ startPresentation(false); }
- void startPresentationBeginning(){ startPresentation(true); }
- void closePresentation(){ endPresentation(); }
+ //Simplification routines
+ void nextPage(){ ShowPage( WIDGET->currentPage()+1 ); } //currentPage() starts at 1 rather than 0
+ void prevPage(){ ShowPage( WIDGET->currentPage()-1 ); } //currentPage() starts at 1 rather than 0
+ void firstPage(){ ShowPage(1); }
+ void lastPage(){ ShowPage(BACKEND->numPages()); }
+ void startPresentationHere(){ startPresentation(false); }
+ void startPresentationBeginning(){ startPresentation(true); }
+ void closePresentation(){ endPresentation(); }
- void find(QString text, bool forward);
- void showBookmarks();
+ void find(QString text, bool forward);
+ void showBookmarks();
- void paintToPrinter(QPrinter *PRINTER);
+ void paintToPrinter(QPrinter *PRINTER);
- //Button Slots
- void OpenNewFile();
+ //Button Slots
+ void OpenNewFile();
- //Other interface slots
- void updateClock();
- void updatePageNumber();
- void showContextMenu(const QPoint&){ contextMenu->popup(QCursor::pos()); }
- void updateContextMenu();
- //void setScroll(bool);
+ //Other interface slots
+ void updateClock();
+ void updatePageNumber();
+ void showContextMenu(const QPoint&){ contextMenu->popup(QCursor::pos()); }
+ void updateContextMenu();
+ //void setScroll(bool);
protected:
- void keyPressEvent(QKeyEvent*);
- void wheelEvent(QWheelEvent*);
- void closeEvent(QCloseEvent *ev){
- endPresentation();
- QMainWindow::closeEvent(ev);
- }
+ void keyPressEvent(QKeyEvent*);
+ void wheelEvent(QWheelEvent*);
+ void closeEvent(QCloseEvent *ev){
+ endPresentation();
+ QMainWindow::closeEvent(ev);
+ }
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp b/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp
index 6226234d..c721f65f 100644
--- a/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp
@@ -42,7 +42,6 @@ PropDialog::PropDialog(Renderer *Backend) : QDialog(), ui(new Ui::PropDialog()){
ui->createdEntry->setText( info.value("dt_created").toString() );
ui->modifiedEntry->setText( info.value("dt_modified").toString() );
ui->numberL->setText( ui->numberL->text() + QString::number(Backend->numPages()) );
-
}
//Load size from mainUI after pages have loaded
diff --git a/src-qt5/desktop-utils/lumina-pdf/propDialog.h b/src-qt5/desktop-utils/lumina-pdf/propDialog.h
index a09f2563..23b8c877 100644
--- a/src-qt5/desktop-utils/lumina-pdf/propDialog.h
+++ b/src-qt5/desktop-utils/lumina-pdf/propDialog.h
@@ -12,19 +12,16 @@
#include "Renderer.h"
namespace Ui{
- class PropDialog;
+ class PropDialog;
};
class PropDialog : public QDialog {
Q_OBJECT
public:
PropDialog(Renderer *Backend);
-
void setSize(QSizeF);
private:
- //void setInfo(fz_context*, pdf_obj*, QTextEdit*, QString);
-
Ui::PropDialog *ui;
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-pdf/textData.h b/src-qt5/desktop-utils/lumina-pdf/textData.h
index 9ec4c5db..050e04d6 100644
--- a/src-qt5/desktop-utils/lumina-pdf/textData.h
+++ b/src-qt5/desktop-utils/lumina-pdf/textData.h
@@ -4,28 +4,28 @@
#include <QRect>
class TextData {
- private:
- QRectF _loc;
- bool _highlighted=false;
- int _page=0;
- QString _text="";
+ private:
+ QRectF _loc;
+ bool _highlighted=false;
+ int _page=0;
+ QString _text="";
- public:
- TextData(QRectF _loc, int _page, QString _text) {
- this->_loc = _loc;
- this->_page = _page;
- this->_text = _text;
- }
+ public:
+ TextData(QRectF _loc, int _page, QString _text) {
+ this->_loc = _loc;
+ this->_page = _page;
+ this->_text = _text;
+ }
- QRectF loc() { return this->_loc; }
- bool highlighted() { return this->_highlighted; }
- int page() { return this->_page; }
- QString text() { return this->_text; }
-
- void loc(QRect loc) { this->_loc = loc; }
- void highlighted(bool highlighted) { this->_highlighted = highlighted; }
- void page(int page) { this->_page = page; }
- void text(QString text) { this->_text = text; }
+ QRectF loc() { return this->_loc; }
+ bool highlighted() { return this->_highlighted; }
+ int page() { return this->_page; }
+ QString text() { return this->_text; }
+
+ void loc(QRect loc) { this->_loc = loc; }
+ void highlighted(bool highlighted) { this->_highlighted = highlighted; }
+ void page(int page) { this->_page = page; }
+ void text(QString text) { this->_text = text; }
};
#endif
bgstack15