aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp36
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.h41
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro2
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.cpp134
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.h23
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/propDialog.cpp57
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/propDialog.h10
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/propDialog.ui82
8 files changed, 217 insertions, 168 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
index 19deabd9..5fa8e517 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
@@ -1,5 +1,4 @@
#include "PrintWidget.h"
-#include <QTimer>
PrintWidget::PrintWidget(QWidget *parent) : QGraphicsView(parent), scene(0), curPage(1),
viewMode(SinglePageView), zoomMode(FitInView), zoomFactor(1), initialized(false), fitting(true) {
@@ -22,6 +21,7 @@ PrintWidget::PrintWidget(QWidget *parent) : QGraphicsView(parent), scene(0), cur
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);
@@ -126,10 +126,10 @@ void PrintWidget::setCurrentPage(int pageNumber) {
}
}
-void PrintWidget::highlightText(int pageNum, QRectF textBox) {
+void PrintWidget::highlightText(int pageNum, fz_rect &rect) {
//PageItem *item = static_cast<PageItem*>(pages[pageNum]);
QPainter painter(this);
- painter.fillRect(textBox, QColor(255, 255, 177, 128));
+ painter.fillRect(QRectF(QPointF(rect.x0, rect.y0), QPointF(rect.x1, rect.y1)), QColor(255, 255, 177, 128));
}
//Private functions
@@ -187,11 +187,20 @@ void PrintWidget::populateScene()
//qDebug() << "Image paperSize" << paperSize;
//Changes the paper orientation if rotated by 90 or 270 degrees
- if(degrees == 90 or degrees == 270)
+ if(degrees == 90 or degrees == 270)
paperSize.transpose();
for (int i = 0; i < numPages; i++) {
- PageItem* item = new PageItem(i+1, (*pictures)[i].scaled( paperSize, Qt::KeepAspectRatio, Qt::SmoothTransformation), paperSize, degrees);
+ QImage pagePicture = pictures->value(i);
+ if(degrees != 0) {
+ pagePicture = pagePicture.transformed(rotMatrix, Qt::SmoothTransformation);
+ qDebug() << "Rotating by: " << degrees << " degrees";
+ }
+ if(pagePicture.isNull()) {
+ qDebug() << "NULL IMAGE ON PAGE " << i;
+ continue;
+ }
+ PageItem* item = new PageItem(i+1, pagePicture, paperSize);
scene->addItem(item);
pages.append(item);
}
@@ -285,11 +294,9 @@ void PrintWidget::fit(bool doFitting) {
void PrintWidget::setPictures(QHash<int, QImage> *hash) {
pictures = hash;
- setCurrentPage(1);
- QTimer::singleShot(0,this, SLOT(updatePreview()));
}
-void PrintWidget::receiveDocument(Poppler::Document *DOC) {
+void PrintWidget::receiveDocument(fz_document *DOC) {
this->doc = DOC;
this->setVisible(true);
}
@@ -298,5 +305,18 @@ void PrintWidget::receiveDocument(Poppler::Document *DOC) {
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;
+ switch(this->degrees) {
+ case 270:
+ rotMatrix = QMatrix(0, -1, 1, 0, 0, 0);
+ break;
+ case 90:
+ rotMatrix = QMatrix(0, 1, -1, 0, 0, 0);
+ break;
+ case 180:
+ rotMatrix = QMatrix(-1, 0, 0, -1, 0, 0);
+ break;
+ default:
+ rotMatrix = QMatrix(1, 0, 0, 1, 0 ,0);
+ }
this->updatePreview();
}
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
index a00200a3..ba432845 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h
@@ -20,12 +20,12 @@
#include <QtMath>
#include <QPageLayout>
-#include <poppler/qt5/poppler-qt5.h>
+#include <mupdf/fitz.h>
class PageItem : public QGraphicsItem {
public:
- PageItem(int _pageNum, QImage _pagePicture, QSize _paperSize, int _degrees)
- : pageNum(_pageNum), pagePicture(_pagePicture), paperSize(_paperSize), degrees(_degrees)
+ PageItem(int _pageNum, QImage _pagePicture, QSize _paperSize)
+ : pageNum(_pageNum), pagePicture(_pagePicture), paperSize(_paperSize)
{
brect = QRectF(QPointF(-25, -25),
QSizeF(paperSize)+QSizeF(50, 50));
@@ -69,33 +69,9 @@ public:
cgrad.setColorAt(0.0, QColor(0,0,0,255));
cgrad.setColorAt(1.0, QColor(0,0,0,0));
painter->fillRect(cshadow, QBrush(cgrad));
-
- QMatrix matrix;
- switch(degrees) {
- case 270:
- matrix = QMatrix(0, -1, 1, 0, 0, 0);
- break;
- case 90:
- matrix = QMatrix(0, 1, -1, 0, 0, 0);
- break;
- case 180:
- matrix = QMatrix(-1, 0, 0, -1, 0, 0);
- break;
- default:
- matrix = QMatrix(1, 0, 0, 1, 0 ,0);
- }
-
painter->setClipRect(paperRect & option->exposedRect);
painter->fillRect(paperRect, Qt::white);
- if (pagePicture.isNull()){
- qDebug() << "NULL";
- return;
- }
-
- if(degrees != 0)
- pagePicture = pagePicture.transformed(matrix, Qt::SmoothTransformation);
-
- painter->drawImage(QPoint(0,0), pagePicture);
+ painter->drawImage(QPoint(0,0), pagePicture);
}
private:
@@ -103,7 +79,6 @@ private:
QImage pagePicture;
QSize paperSize;
QRectF brect;
- int degrees;
};
@@ -131,7 +106,7 @@ private:
void setZoomMode(ZoomMode);
QGraphicsScene *scene;
-
+ QMatrix rotMatrix;
int curPage, publicPageNum;
ViewMode viewMode;
ZoomMode zoomMode;
@@ -140,7 +115,7 @@ private:
bool initialized, fitting;
QList<QGraphicsItem*> pages;
QHash<int, QImage> *pictures;
- Poppler::Document *doc;
+ fz_document *doc;
int degrees;
public:
@@ -162,8 +137,8 @@ public slots:
void zoomOut(double factor=1.2);
void setCurrentPage(int);
void setVisible(bool) Q_DECL_OVERRIDE;
- void highlightText(int, QRectF);
- void receiveDocument(Poppler::Document*);
+ void highlightText(int, fz_rect&);
+ void receiveDocument(fz_document*);
void setDegrees(int);
void updatePreview();
diff --git a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro
index 8ee67d06..c0717d6d 100644
--- a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro
+++ b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro
@@ -30,7 +30,7 @@ HEADERS += mainUI.h \
FORMS += mainUI.ui \
propDialog.ui
-LIBS += -lpoppler-qt5
+LIBS += -lpoppler-qt5 -lmupdf -lmujs
TRANSLATIONS = i18n/l-pdf_af.ts \
i18n/l-pdf_ar.ts \
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
index 51fbdf9d..b64b8902 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
@@ -1,5 +1,4 @@
-//===========================================
-// Lumina Desktop source code
+//=========================================== // Lumina Desktop source code
// Copyright (c) 2017, Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
@@ -17,13 +16,12 @@
#include <QScreen>
#include <QTimer>
#include <iostream>
-
#include <QtConcurrent>
#include <LuminaXDG.h>
#include "PrintWidget.h"
-#define TESTING false
+#define TESTING 0
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
ui->setupUi(this);
@@ -62,8 +60,9 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
connect(WIDGET, SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(showContextMenu(const QPoint&)) );
connect(WIDGET, SIGNAL(currentPageChanged()), this, SLOT(updatePageNumber()) );
DOC = 0;
+ CTX = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED);
connect(this, SIGNAL(PageLoaded(int)), this, SLOT(slotPageLoaded(int)) );
- connect(this, SIGNAL(sendDocument(Poppler::Document*)), WIDGET, SLOT(receiveDocument(Poppler::Document*)));
+ connect(this, SIGNAL(sendDocument(fz_document*)), WIDGET, SLOT(receiveDocument(fz_document*)));
PrintDLG = new QPrintDialog(this);
connect(PrintDLG, SIGNAL(accepted(QPrinter*)), this, SLOT(paintToPrinter(QPrinter*)) );
@@ -117,7 +116,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
connect(ui->actionPrevious_Page, SIGNAL(triggered()), this, SLOT(prevPage()) );
connect(ui->actionNext_Page, SIGNAL(triggered()), this, SLOT(nextPage()) );
connect(ui->actionLast_Page, SIGNAL(triggered()), this, SLOT(lastPage()) );
- connect(ui->actionProperties, SIGNAL(triggered()), this, SLOT(showInformation()));
+ connect(ui->actionProperties, &QAction::triggered, WIDGET, [&] { PROPDIALOG->show(); });
connect(ui->actionFind, &QAction::triggered, this, [&] {
if(ui->findGroup->isVisible()) {
ui->findGroup->setVisible(false);
@@ -211,54 +210,62 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){
ui->findGroup->setVisible(false);
ui->bookmarksFrame->setVisible(false);
- // Disable/Hide all the things currently still being implemented
ui->menuSettings->setEnabled(TESTING);
ui->menuSettings->setVisible(TESTING);
-
- ui->actionBookmarks->setEnabled(TESTING);
- ui->actionRotate_Counterclockwise->setEnabled(TESTING);
- ui->actionRotate_Clockwise->setEnabled(TESTING);
- ui->actionProperties->setEnabled(TESTING);
- ui->actionProperties->setVisible(TESTING);
+ ui->actionBookmarks->setEnabled(TESTING);
+ ui->actionScroll_Mode->setEnabled(TESTING);
+ ui->actionScroll_Mode->setVisible(TESTING);
+ ui->actionSelect_Mode->setEnabled(TESTING);
+ ui->actionSelect_Mode->setVisible(TESTING);
}
MainUI::~MainUI(){
+ //fz_free(CTX, CTX);
}
void MainUI::loadFile(QString path){
if(!QFile::exists(path) || path.isEmpty() ){ return; }
-
- Poppler::Document *TDOC = Poppler::Document::load(path);
+ fz_register_document_handlers(CTX);
+ fz_document *TDOC = fz_open_document(CTX, path.toLocal8Bit().data());
+ PDOC = pdf_open_document(CTX, path.toLocal8Bit().data());
if(TDOC==0){
qDebug() << "Could not open file:" << path;
return;
- }else if(TDOC->isLocked()){
+ }else if(fz_needs_password(CTX, TDOC) != 0){
//Prompt for password to unlock the document
QString pass = "";
bool ok = true; //flag this to go into the loop the first time (if password prompt is cancelled - this becomes false)
- while( (ok ? true : !TDOC->unlock(QByteArray(), pass.toLocal8Bit())) ){ //make sure the unlock function is only called when ok is true
+
+ while( (ok ? true : !fz_authenticate_password(CTX, TDOC, pass.toLocal8Bit())) ){ //make sure the unlock function is only called when ok is true
pass = QInputDialog::getText(this, tr("Unlock PDF"), tr("Password:"), QLineEdit::Password, "", &ok);
}
- if(TDOC->isLocked()){ return; } //Cancelled - still locked
+ if(fz_needs_password(CTX, TDOC) != 0){ return; }
}
//qpdf.processFile(path.toLatin1().data(), pass.toLatin1().data());
if(DOC!=0){
+ //fz_close_document(DOC);
//Clear out the old document first
delete DOC;
DOC=0;
}
//loadingHash.clear(); //clear out this hash
+
numPages = -1;
DOC = TDOC; //Save this for later
qDebug() << "Opening File:" << path;
- this->setWindowTitle(TDOC->title());
+ pdf_obj *info = pdf_dict_gets(CTX, pdf_trailer(CTX, (pdf_document*)DOC), "Info");
+ if(info) {
+ if(pdf_obj *obj = pdf_dict_gets(CTX, info, (char *)"Title"))
+ this->setWindowTitle(pdf_to_utf8(CTX, obj));
+ }
+ qDebug() << this->windowTitle();
if(this->windowTitle().isEmpty()){ this->setWindowTitle(path.section("/",-1)); }
//Setup the Document
//QVector<QPDFObjectHandle> pages = (QVector<QPDFObjectHandle>)pdf.getAllPages();
//QPDFObjectHandle page = pages.at(0);
- Poppler::Page *PAGE = DOC->page(0);
+ fz_page *PAGE = fz_load_page(CTX, TDOC, 0);
if(PAGE!=0){
lastdir = path.section("/",0,-2); //save this for later
/*switch(PAGE->orientation()){
@@ -275,14 +282,24 @@ void MainUI::loadFile(QString path){
}
-void MainUI::loadPage(int num, Poppler::Document *doc, MainUI *obj, QSize dpi, QSizeF page){
+void MainUI::loadPage(int num, fz_document *doc, MainUI *obj, QSize dpi){
//qDebug() << " - Render Page:" << num;
- Poppler::Page *PAGE = doc->page(num);
+ fz_page *PAGE = fz_load_page(CTX, doc, num);
if(PAGE!=0){
- QImage raw = PAGE->renderToImage(dpi.width(),dpi.height()); //make the raw image a bit larger than the end result
- //qDebug() << " - Raw Image Size:" << raw.size();
- loadingHash.insert(num, raw.scaled(page.width(), page.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) );
- raw = QImage(); //clear it
+ fz_matrix matrix;
+
+ //double scaleFactorW = dpi.width()/72.0;
+ //double scaleFactorH = dpi.height()/72.0;
+ //fz_scale(&matrix, scaleFactorW, scaleFactorH);
+ fz_scale(&matrix, 4.0, 4.0);
+ fz_rotate(&matrix, 0.0);
+ fz_pixmap *pixmap = fz_new_pixmap_from_page_number(CTX, doc, num, &matrix, fz_device_rgb(CTX), 0);
+ //unsigned char *samples = fz_pixmap_samples(CTX, pixmap);
+ QImage raw(pixmap->samples, pixmap->w, pixmap->h, QImage::Format_RGB888); //make the raw image a bit larger than the end result
+ //loadingHash.insert(num, raw.scaled(page.width(), page.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) );
+ loadingHash.insert(num, raw);
+ //raw = QImage(); //clear it
+ //fz_drop_pixmap(CTX, pixmap);
/*
QList<Annotation*> anno = PAGE->annotations(Annotations::AText );
QStringList annoS;
@@ -368,7 +385,7 @@ void MainUI::startPresentation(bool atStart){
void MainUI::ShowPage(int page){
//Check for valid document/page
//qDebug() << "Load Page:" << page << "/" << numPages << "Index:" << page;
- if(page<0 || page > numPages+1 || (page==numPages && CurrentPage==page) ){
+ if(page <= 0 || page > numPages || (page==numPages && CurrentPage==page) ){
endPresentation();
return; //invalid - no document loaded or invalid page specified
}
@@ -407,24 +424,21 @@ void MainUI::endPresentation(){
void MainUI::startLoadingPages(){
if(numPages>0){ return; } //currently loaded[ing]
- //qDebug() << " - Start Loading Pages";
loadingHash.clear();
- numPages = DOC->numPages();
- //qDebug() << "numPages:" << numPages;
+ numPages = fz_count_pages(CTX, DOC);
progress->setRange(0,numPages);
progress->setValue(0);
progAct->setVisible(true);
pageAct->setVisible(false);
//PERFORMANCE NOTES:
- // Using Poppler to scale the image (adjust dpi value) helps a bit but you take a larger CPU loading hit (and still quite a lot of pixelization)
+ // Using MuPdf to scale the image (adjust dpi value) helps a bit but you take a larger CPU loading hit (and still quite a lot of pixelization)
// Using Qt to scale the image (adjust page value) smooths out the image quite a bit without a lot of performance loss (but cannot scale up without pixelization)
// The best approach seams to be to increase the DPI a bit, but match that with the same scaling on the page size (smoothing)
- double scalefactor = 2.5;
- QSizeF pageSize = DOC->page(0)->pageSizeF()*scalefactor;
- //QSize DPI(loadingHash[0]->resolution(),loadingHash[0]->resolution());
- //QSize DPI(76,76);
- //DPI = DPI*(scalefactor+1); //need this a bit higher than the page scaling
+ //double scalefactor = 2.5;
+ fz_rect page_rect;
+ fz_bound_page(CTX, fz_load_page(CTX, DOC, 0), &page_rect);
+ pageSize = QSizeF((page_rect.x1 - page_rect.x0)/72.0, (page_rect.y1 - page_rect.y0)/72.0);
QSize DPI(300,300); //print-quality (some printers even go to 600 DPI nowdays)
/*qDebug() << "Screen Resolutions:";
@@ -432,10 +446,10 @@ void MainUI::startLoadingPages(){
for(int i=0; i<screens.length(); i++){
qDebug() << screens[i]->name() << screens[i]->logicalDotsPerInchX() << screens[i]->logicalDotsPerInchY();
}*/
- //qDebug() << "Poppler pageSize: " << pageSize;
for(int i=0; i<numPages; i++){
//qDebug() << " - Kickoff page load:" << i;
- QtConcurrent::run(this, &MainUI::loadPage, i, DOC, this, DPI, pageSize);
+ loadPage(i, DOC, this, DPI);
+ //QtConcurrent::run(this, &MainUI::loadPage, i, DOC, this, DPI, pageSize);
}
}
@@ -448,6 +462,8 @@ void MainUI::slotPageLoaded(int page){
progAct->setVisible(false);
WIDGET->setPictures(&loadingHash);
emit sendDocument(DOC);
+ PROPDIALOG = new PropDialog(CTX, PDOC);
+ PROPDIALOG->setSize(pageSize);
ui->actionStop_Presentation->setEnabled(false);
ui->actionStart_Here->setEnabled(true);
ui->actionStart_Begin->setEnabled(true);
@@ -460,7 +476,7 @@ void MainUI::slotPageLoaded(int page){
void MainUI::paintToPrinter(QPrinter *PRINTER){
if(loadingHash.keys().length() != numPages){ return; }
- int pages = DOC->numPages();
+ int pages = fz_count_pages(CTX, DOC);
int firstpage = 0;
int copies = PRINTER->copyCount();
bool collate = PRINTER->collateCopies();
@@ -607,33 +623,37 @@ void MainUI::wheelEvent(QWheelEvent *event) {
QMainWindow::wheelEvent(event);
}
-void MainUI::showInformation() {
- PROPDIALOG = new PropDialog(DOC);
- PROPDIALOG->show();
-}
-
void MainUI::find(QString text, bool forward) {
if(!text.isEmpty()) {
qDebug() << "Finding Text";
bool newText = results.empty();
bool research = false;
if(!newText)
- research = !results.keys()[0]->text().contains(text);
+ research = !(results[0].text == text);
//Clear results if the user gives a new search string
if(research)
results.clear();
if(research or newText) {
ui->resultsLabel->setText("");
+ fz_rect rectBuffer[1000];
for(int i = 0; i < numPages; i++) {
- 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)) {
- results.insert(textList[j], i);
- }
- }
- }
+ int count = fz_search_page_number(CTX, DOC, i, text.toLatin1().data(), rectBuffer, 1000);
+ qDebug() << count;
+ for(int j = 0; j < count; j++) {
+ textData t;
+ t.loc = rectBuffer[j];
+ t.text = text;
+ t.page = i;
+ /*fz_stext_sheet *sheet = fz_new_stext_sheet(CTX);
+ fz_stext_page *sPage = fz_new_stext_page_from_page_number(CTX, DOC, results.first(), sheet, NULL);
+ if(QString(fz_copy_selection(CTX, sPage, rectBuffer[j])).contains(
+ text, (matchCase) ? Qt::CaseSensitive : Qt::CaseInsensitive)) {*/
+ results.append(t);
+ //}
+ }
+ }
+ qDebug() << results.size();
currentHighlight = (forward) ? -1 : results.size();
}
@@ -654,12 +674,12 @@ void MainUI::find(QString text, bool forward) {
ui->resultsLabel->setText(QString::number(currentHighlight+1) + " of " + QString::number(results.size()) + " results");
- Poppler::TextBox *currentText = results.keys()[currentHighlight];
- WIDGET->setCurrentPage(results.value(currentText)+1);
+ textData currentText = results[currentHighlight];
+ WIDGET->setCurrentPage(currentText.page);
- qDebug() << "Jump to location: " << results.value(currentText);
+ qDebug() << "Jump to location: " << currentText.page;
- WIDGET->highlightText(currentHighlight, currentText->boundingBox());
+ WIDGET->highlightText(currentHighlight, currentText.loc);
//QTimer::singleShot(10, WIDGET, SLOT(updatePreview()));
}else{
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
index 251d42c1..ca602abb 100644
--- a/src-qt5/desktop-utils/lumina-pdf/mainUI.h
+++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.h
@@ -19,7 +19,8 @@
#include <QApplication>
#include <QMenu>
-#include <poppler/qt5/poppler-qt5.h>
+#include <mupdf/fitz.h>
+#include <mupdf/pdf.h>
#include "PresentationLabel.h"
#include "propDialog.h"
#include "PrintWidget.h"
@@ -28,6 +29,12 @@ namespace Ui{
class MainUI;
};
+typedef struct textData {
+ fz_rect loc;
+ int page;
+ QString text;
+}textData;
+
class MainUI : public QMainWindow{
Q_OBJECT
public:
@@ -37,14 +44,17 @@ public:
void loadFile(QString path);
private:
- Poppler::Document *DOC;
+ fz_document *DOC;
+ pdf_document *PDOC;
+ fz_context *CTX;
+ QSizeF pageSize;
PrintWidget *WIDGET;
Ui::MainUI *ui;
PropDialog *PROPDIALOG;
QPrintDialog *PrintDLG;
QString lastdir;
bool matchCase;
- QMap<Poppler::TextBox*, int> results;
+ QList<textData> results;
int currentHighlight;
//Other Interface elements
@@ -60,7 +70,7 @@ private:
QHash<int, QImage> loadingHash;
int numPages;
- void loadPage(int num, Poppler::Document *doc, MainUI *obj, QSize dpi, QSizeF page);
+ void loadPage(int num, fz_document *doc, MainUI *obj, QSize dpi);
//Functions/variables for the presentation mode
PresentationLabel *presentationLabel;
@@ -83,7 +93,6 @@ private slots:
void startPresentationBeginning(){ startPresentation(true); }
void closePresentation(){ endPresentation(); }
- void showInformation();
void find(QString text, bool forward);
void showBookmarks();
@@ -97,11 +106,11 @@ private slots:
void updatePageNumber();
void showContextMenu(const QPoint&){ contextMenu->popup(QCursor::pos()); }
void updateContextMenu();
- //void setScroll(bool);
+ //void setScroll(bool);
signals:
void PageLoaded(int);
- void sendDocument(Poppler::Document*);
+ void sendDocument(fz_document*);
protected:
void keyPressEvent(QKeyEvent*);
diff --git a/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp b/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp
index 0c26af74..d1ef0c49 100644
--- a/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/propDialog.cpp
@@ -10,16 +10,16 @@
#include <LuminaXDG.h>
-PropDialog::PropDialog(Poppler::Document *DOC) : QDialog(), ui(new Ui::PropDialog()){
+void PropDialog::setInfo(fz_context *CTX, pdf_obj *info, QTextEdit *widget, QString str) {
+ pdf_obj *obj = pdf_dict_gets(CTX, info, str.toLatin1().data());
+ if(obj)
+ widget->setText(pdf_to_utf8(CTX, obj));
+}
+
+PropDialog::PropDialog(fz_context *CTX, pdf_document *DOC) : QDialog(), ui(new Ui::PropDialog()){
this->setWindowTitle(tr("PDF Information"));
this->setWindowIcon( LXDG::findIcon("dialog-information","unknown"));
- int verMa, verMi;
- QString version;
- QSize size = DOC->page(0)->pageSize();
-
- //Grab the version
- DOC->getPdfVersion(&verMa, &verMi);
- version = QString::number(verMa)+"."+QString::number(verMi);
+ pdf_obj *info = pdf_dict_gets(CTX, pdf_trailer(CTX, DOC), "Info");
ui->setupUi(this);
@@ -34,23 +34,34 @@ PropDialog::PropDialog(Poppler::Document *DOC) : QDialog(), ui(new Ui::PropDialo
ui->keywordsL->setText(tr("Keywords:"));
ui->createdL->setText(tr("Created:"));
ui->modifiedL->setText(tr("Modified:"));
- ui->versionL->setText(tr("PDF Version:"));
- ui->sizeL->setText(tr("Page Size:"));
- ui->numberL->setText(tr("Number of Pages:"));
+ ui->sizeL->setText(tr("Page Size: "));
+ ui->numberL->setText(tr("Number of Pages: "));
ui->saveButton->setText(tr("Save"));
ui->closeButton->setText(tr("Close"));
//Fill the text boxes with information from the document
- ui->titleE->setText(DOC->title());
- ui->subjectE->setText(DOC->subject());
- ui->authorE->setText(DOC->author());
- ui->creatorE->setText(DOC->creator());
- ui->producerE->setText(DOC->producer());
- ui->keywordE->setText(DOC->keywords());
- ui->createdEntry->setText(DOC->creationDate().toString(Qt::TextDate));
- ui->modifiedEntry->setText(DOC->modificationDate().toString(Qt::TextDate));
- ui->versionL->setText(ui->versionL->text()+version);
- ui->sizeL->setText(ui->sizeL->text()+QString::number(size.height())+
- ", "+QString::number(size.width()));
- ui->numberL->setText(ui->numberL->text()+QString::number(DOC->numPages()));
+ if(info) {
+ setInfo(CTX, info, ui->titleE, "Title");
+ setInfo(CTX, info, ui->subjectE, "Subject");
+ setInfo(CTX, info, ui->authorE, "Author");
+ setInfo(CTX, info, ui->creatorE, "Creator");
+ setInfo(CTX, info, ui->producerE, "Producer");
+ setInfo(CTX, info, ui->keywordE, "Keywords");
+ pdf_obj *obj = pdf_dict_gets(CTX, info, (char *)"CreationDate");
+ char *str = pdf_to_utf8(CTX, obj);
+ if(obj)
+ ui->createdEntry->setText(QDateTime::fromString(QString(str).left(16), "'D:'yyyyMMddHHmmss").toString());
+ //ModDate not displaying when should, possibly broken
+ obj = pdf_dict_gets(CTX, info, (char *)"ModDate");
+ str = pdf_to_utf8(CTX, obj);
+ if(obj)
+ ui->modifiedEntry->setText(QDateTime::fromString(QString(str).left(16), "'D:'yyyyMMddHHmmss").toString());
+ ui->numberL->setText(ui->numberL->text()+QString::number(pdf_count_pages(CTX, DOC)));
+ free(str);
+ }
+}
+
+//Load size from mainUI after pages have loaded
+void PropDialog::setSize(QSizeF pageSize) {
+ ui->sizeL->setText(ui->sizeL->text()+QString::number(pageSize.width())+", "+QString::number(pageSize.height()));
}
diff --git a/src-qt5/desktop-utils/lumina-pdf/propDialog.h b/src-qt5/desktop-utils/lumina-pdf/propDialog.h
index be67ebd3..05d3231a 100644
--- a/src-qt5/desktop-utils/lumina-pdf/propDialog.h
+++ b/src-qt5/desktop-utils/lumina-pdf/propDialog.h
@@ -8,7 +8,9 @@
#define _LUMINA_PDF_VIEWER_PROP_DIALOG_H
#include <QDialog>
-#include <poppler/qt5/poppler-qt5.h>
+#include <QTextEdit>
+#include <mupdf/fitz.h>
+#include <mupdf/pdf.h>
namespace Ui{
class PropDialog;
@@ -17,9 +19,13 @@ namespace Ui{
class PropDialog : public QDialog {
Q_OBJECT
public:
- PropDialog(Poppler::Document*);
+ PropDialog(fz_context*, pdf_document*);
+
+ 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/propDialog.ui b/src-qt5/desktop-utils/lumina-pdf/propDialog.ui
index 6806f81a..0e8ba90b 100644
--- a/src-qt5/desktop-utils/lumina-pdf/propDialog.ui
+++ b/src-qt5/desktop-utils/lumina-pdf/propDialog.ui
@@ -14,6 +14,13 @@
<string>PDF Information</string>
</property>
<layout class="QGridLayout" name="gridLayout">
+ <item row="8" column="0" colspan="3">
+ <widget class="QLabel" name="sizeL">
+ <property name="text">
+ <string>Page Size:</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="0">
<widget class="QLabel" name="titleL">
<property name="text">
@@ -24,7 +31,7 @@
<item row="0" column="1" colspan="2">
<widget class="QTextEdit" name="titleE">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -54,11 +61,14 @@
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="readOnly">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByKeyboard</set>
+ </property>
</widget>
</item>
<item row="1" column="0">
@@ -71,7 +81,7 @@
<item row="1" column="1" colspan="2">
<widget class="QTextEdit" name="subjectE">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -101,11 +111,14 @@
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="readOnly">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByKeyboard</set>
+ </property>
</widget>
</item>
<item row="2" column="0">
@@ -118,7 +131,7 @@
<item row="2" column="1" colspan="2">
<widget class="QTextEdit" name="authorE">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -148,11 +161,14 @@
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="readOnly">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="3" column="0">
@@ -165,7 +181,7 @@
<item row="3" column="1" colspan="2">
<widget class="QTextEdit" name="creatorE">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -194,12 +210,18 @@
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
+ <property name="lineWrapMode">
+ <enum>QTextEdit::WidgetWidth</enum>
+ </property>
<property name="readOnly">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="4" column="0">
@@ -212,7 +234,7 @@
<item row="4" column="1" colspan="2">
<widget class="QTextEdit" name="producerE">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -242,7 +264,7 @@
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="readOnly">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
@@ -262,7 +284,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -301,7 +323,7 @@
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="readOnly">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
@@ -321,7 +343,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -380,7 +402,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -426,35 +448,14 @@
</property>
</widget>
</item>
- <item row="8" column="0" colspan="3">
- <widget class="QLabel" name="versionL">
- <property name="text">
- <string>PDF Version:</string>
- </property>
- </widget>
- </item>
- <item row="9" column="0" colspan="3">
- <widget class="QLabel" name="sizeL">
- <property name="text">
- <string>Page Size:</string>
- </property>
- </widget>
- </item>
- <item row="10" column="0" colspan="3">
- <widget class="QLabel" name="numberL">
- <property name="text">
- <string>Number of Pages:</string>
- </property>
- </widget>
- </item>
- <item row="11" column="1">
+ <item row="10" column="1">
<widget class="QPushButton" name="saveButton">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
- <item row="11" column="2">
+ <item row="10" column="2">
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>Close</string>
@@ -470,6 +471,13 @@
</property>
</widget>
</item>
+ <item row="9" column="0" colspan="3">
+ <widget class="QLabel" name="numberL">
+ <property name="text">
+ <string>Number of Pages:</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
bgstack15