diff options
author | Ken Moore <ken@ixsystems.com> | 2018-09-06 15:40:30 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2018-09-06 15:40:30 -0400 |
commit | c72934ff962322e6593780052c4af528f3c75974 (patch) | |
tree | e5c60df84fd45461a491f3e1aa567d9220c6d481 /src-qt5/desktop-utils/lumina-pdf | |
parent | iFix a syntax issue with the cpp.json syntax ruleset (diff) | |
parent | When a desktop is resized automatically re-do the wallpaper as well. (diff) | |
download | lumina-c72934ff962322e6593780052c4af528f3c75974.tar.gz lumina-c72934ff962322e6593780052c4af528f3c75974.tar.bz2 lumina-c72934ff962322e6593780052c4af528f3c75974.zip |
Merge branch 'master' of github.com:lumina-desktop/lumina
Diffstat (limited to 'src-qt5/desktop-utils/lumina-pdf')
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp | 15 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/PrintWidget.h | 2 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp | 17 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.cpp | 11 |
4 files changed, 31 insertions, 14 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp index f64106d3..d6597705 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp @@ -129,12 +129,16 @@ void PrintWidget::setCurrentPage(int pageNumber) { this->centerOn(pages.at(curPage-1)); } } + + //qDebug() << "Page Set"; } void PrintWidget::highlightText(TextData *text) { //Creates a rectangle around the text if the text has not already been highlighted + //qDebug() << "Page:" << text->page() << "Loc:" << text->loc(); if(!text->highlighted() && !text->loc().isNull()) { int degrees = BACKEND->rotatedDegrees(); + //qDebug() << "Degrees:" << degrees; //Shows the text's location on a non-rotated page QRectF rect = text->loc(); //Rotates the rectangle by the page's center and gets the right calculation for text's new location @@ -154,12 +158,18 @@ void PrintWidget::highlightText(TextData *text) { else rect.adjust(cy, cx, cy, cx); } + + //qDebug() << "Post Degrees:" << rect; //Moves the rectangle onto the right page double pageHeight = 0; for(int i = 0; i < text->page() - 1; i++) pageHeight += pages.at(i)->boundingRect().height(); + //qDebug() << "PageHeight:" << pageHeight; + rect.moveTop(rect.y() + pageHeight); + + //qDebug() << "Final Rect:" << rect; //Transparent yellow for the highlight box QBrush highlightFill(QColor(255, 255, 177, 100)); QPen highlightOutline(QColor(255, 255, 100, 125)); @@ -388,6 +398,7 @@ void PrintWidget::fit(bool doFitting) { } void PrintWidget::goToPosition(int pagenum, float x, float y) { + //qDebug() << "Page:" << pagenum << "X:" << x << "Y:" << y; setCurrentPage(pagenum); QScrollBar *hsc = this->horizontalScrollBar(); @@ -398,9 +409,13 @@ void PrintWidget::goToPosition(int pagenum, float x, float y) { double realHeight = pages.at(pagenum-1)->boundingRect().height(); double virtualHeight = qAbs(pt2.y() - pt.y()); + //qDebug() << "Real:" << realHeight << "Virtual:" << virtualHeight; + int yConv = int(pt.y() + y*(virtualHeight/realHeight)) - 30; int xConv = int(pt.x() + x*(virtualHeight/realHeight)) - 30; + //qDebug() << "newX:" << xConv << "newY:" << yConv; + if(yConv > vsc->maximum()) vsc->triggerAction(QAbstractSlider::SliderToMaximum); else if(y != 0) diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h index c353cb84..8e365a99 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h @@ -298,7 +298,7 @@ protected: if(PageItem *page = dynamic_cast<PageItem*>(item)) linkList = page->childItems(); - else + else if(item != dynamic_cast<QGraphicsRectItem*>(item)) linkList = item->parentItem()->childItems(); if(LinkItem *link = dynamic_cast<LinkItem*>(item)){ diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp index a52fd5b4..7d5e1f64 100644 --- a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp @@ -65,6 +65,7 @@ class Data { fz_context* getContext() { return ctx; } fz_display_list* getDisplayList() { return list; } QRectF getScaledRect() { return convertRect(bbox, sf); } + QRectF getScaledRect(fz_rect &rect) { return convertRect(rect, sf); } fz_rect getBoundingBox() { return bbox; } fz_matrix getMatrix() { return ctm; } QImage getImage() { return img; } @@ -144,7 +145,7 @@ Renderer::Renderer(){ locks.unlock = unlock_mutex; DOC = 0; - qDebug() << "Creating Context"; + //qDebug() << "Creating Context"; CTX = fz_new_context(NULL, &locks, FZ_STORE_UNLIMITED); needpass = false; degrees = 0; @@ -152,7 +153,7 @@ Renderer::Renderer(){ Renderer::~Renderer(){ //pdf_clean_page_contents - qDebug() << "Dropping Context"; + //qDebug() << "Dropping Context"; clearHash(); fz_drop_document(CTX, DOC); DOC = NULL; @@ -216,7 +217,7 @@ bool Renderer::loadDocument(QString path, QString password){ docpath = path; DOC = fz_open_document(CTX, path.toLocal8Bit().data()); - qDebug() << "File opened" << DOC; + //qDebug() << "File opened" << DOC; if(DOC==0){ qDebug() << "Could not open file:" << path; return false; @@ -230,13 +231,13 @@ bool Renderer::loadDocument(QString path, QString password){ if(needpass){ return false; } //incorrect password } - qDebug() << "Password Check cleared"; + //qDebug() << "Password Check cleared"; pnum = fz_count_pages(CTX, DOC); qDebug() << "Page count: " << pnum; doctitle.clear(); - qDebug() << "Opening File:" << path; + //qDebug() << "Opening File:" << path; jobj.insert("subject", getTextInfo("Subject") ); jobj.insert("author", getTextInfo("Author") ); jobj.insert("creator", getTextInfo("Creator") ); @@ -255,8 +256,8 @@ bool Renderer::loadDocument(QString path, QString password){ fz_outline *outline = fz_load_outline(CTX, DOC); if(outline) traverseOutline(outline, 0); - else - qDebug() << "No Bookmarks"; + //else + //qDebug() << "No Bookmarks"; fz_drop_outline(CTX, outline); @@ -555,7 +556,7 @@ QList<TextData*> Renderer::searchDocument(QString text, bool matchCase){ int count = fz_search_display_list(CTX, dataHash[i]->getDisplayList(), text.toLocal8Bit().data(), rectBuffer, 1000); //qDebug() << "Page " << i+1 << ": Count, " << count; for(int j = 0; j < count; j++) { - TextData *t = new TextData(dataHash[i]->getScaledRect(), i+1, text); + TextData *t = new TextData(dataHash[i]->getScaledRect(rectBuffer[j]), 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 if(matchCase){ fz_stext_page *sPage = fz_new_stext_page_from_display_list(CTX, dataHash[i]->getDisplayList(), NULL); diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp index f0b64948..b44cd8f2 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp @@ -355,7 +355,7 @@ void MainUI::endPresentation(){ } void MainUI::startLoadingPages(int degrees){ - qDebug() <<"Start Loading Pages"; + //qDebug() <<"Start Loading Pages"; //if(BACKEND->hashSize() != 0) { return; } //currently loaded[ing] loadingQueue.clear(); BACKEND->clearHash(); @@ -420,7 +420,7 @@ void MainUI::paintToPrinter(QPrinter *PRINTER){ int copies = PRINTER->copyCount(); bool collate = PRINTER->collateCopies(); bool reverse = (PRINTER->pageOrder()==QPrinter::LastPageFirst); - qDebug() << "PRINTER DPI:" << PRINTER->resolution() << PRINTER->supportedResolutions(); + //qDebug() << "PRINTER DPI:" << PRINTER->resolution() << PRINTER->supportedResolutions(); if(PRINTER->resolution() < 300){ //Try to get 300 DPI resolution at least PRINTER->setResolution(300); @@ -632,10 +632,11 @@ void MainUI::find(QString text, bool forward) { TextData *currentText = results[currentHighlight]; - if(BACKEND->supportsExtraFeatures()) + if(BACKEND->supportsExtraFeatures()) { WIDGET->highlightText(currentText); - }else{ - ui->resultsLabel->setText("No results found"); + }else{ + ui->resultsLabel->setText("No results found"); + } } } } |