From 8239f07ed001e1da3cf36e859303ddd5f62cb507 Mon Sep 17 00:00:00 2001 From: ZackaryWelch Date: Wed, 21 Mar 2018 16:47:38 -0400 Subject: Improved Bookmarks layout and made MuPDF the default backend --- .gitignore | 1 + src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp | 4 -- src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui | 58 +++++++++++++++------- src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp | 2 - .../desktop-utils/lumina-pdf/Renderer-mupdf.cpp | 2 +- .../desktop-utils/lumina-pdf/Renderer-poppler.cpp | 3 +- src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro | 11 ++-- src-qt5/desktop-utils/lumina-pdf/mainUI.cpp | 29 ++++++----- src-qt5/desktop-utils/lumina-pdf/mainUI.ui | 48 +++++++----------- 9 files changed, 81 insertions(+), 77 deletions(-) diff --git a/.gitignore b/.gitignore index 3d31f346..1ec73fea 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ src-qt5/desktop-utils/lumina-textedit/lumina-textedit src-qt5/desktop-utils/lumina-archiver/lumina-archiver src-qt5/desktop-utils/lumina-calculator/lumina-calculator src-qt5/desktop-utils/lumina-pdf/lumina-pdf +src-qt5/desktop-utils/lumina-pdf/.build/ src-qt5/desktop-utils/lumina-notify/lumina-notify src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/ src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/.build/ diff --git a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp index 0a8dd695..39d4e314 100644 --- a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp @@ -11,12 +11,9 @@ BookmarkMenu::BookmarkMenu(Renderer *Backend, QWidget *parent) : QWidget(parent), ui(new Ui::BookmarkMenu()), BACKEND(Backend){ ui->setupUi(this); - ui->closeButton->setIcon( LXDG::findIcon("dialog-close") ); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close())); connect(ui->bookmarks, &QTreeWidget::itemClicked, this, [=](QTreeWidgetItem *item) { Backend->handleLink(item->data(1, Qt::UserRole).toString()); }); - - ui->bookmarks->setHeaderLabel("Title"); } void BookmarkMenu::loadBookmarks() { @@ -41,7 +38,6 @@ void BookmarkMenu::loadBookmarks() { }else{ item = new QTreeWidgetItem(parent); } - item->setText(0, bm->title); item->setData(1, Qt::UserRole, bm->link); if(!bm->link.isEmpty()) diff --git a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui index de19be66..e9706913 100644 --- a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui +++ b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.ui @@ -6,8 +6,8 @@ 0 0 - 109 - 507 + 156 + 583 @@ -15,27 +15,49 @@ - - - - - - - - - - Bookmarks - - - Qt::AlignCenter - - + + + + + + 0 + 0 + + + + Bookmarks + + + + + + true + + + + + + + + 0 + 0 + + + + Bookmarks + + + + + + 1 + - 1 + Location diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp index 63d25be4..65a71a74 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp @@ -162,7 +162,6 @@ 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()); @@ -211,7 +210,6 @@ void PrintWidget::populateScene() } qDeleteAll(pages); pages.clear(); - qDebug() << "populateScene"; int numPages = BACKEND->numPages(); if(BACKEND->hashSize() < numPages){ return; } //nothing to show yet diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp index 7846e9c1..2349fff3 100644 --- a/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-mupdf.cpp @@ -209,7 +209,7 @@ void Renderer::renderPage(int pagenum, QSize DPI, int degrees){ fz_pixmap *pixmap; fz_display_list *list; - double pageDPI = 150.0; + double pageDPI = 96.0; double sf = DPI.width() / pageDPI; fz_scale(&matrix, sf, sf); fz_pre_rotate(&matrix, degrees); diff --git a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp index 28045539..7f2baa5e 100644 --- a/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/Renderer-poppler.cpp @@ -89,7 +89,7 @@ void Renderer::renderPage(int pagenum, QSize DPI, int degrees){ default: rotation = Poppler::Page::Rotation::Rotate0; } - img = PAGE->renderToImage(DPI.width(),DPI.height(), -1, -1, -1, -1, rotation); + img = PAGE->renderToImage(DPI.width(), DPI.height(), -1, -1, -1, -1, rotation); loadingHash.insert(pagenum, img); delete PAGE; } @@ -127,6 +127,7 @@ void Renderer::clearHash() { loadingHash.clear(); } +//Highlighting found text, bookmarks, and page properties disabled for Poppler bool Renderer::supportsExtraFeatures() { return false; } void Renderer::traverseOutline(void *, int) { } diff --git a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro index 17a76c3a..6ca51b79 100644 --- a/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro +++ b/src-qt5/desktop-utils/lumina-pdf/lumina-pdf.pro @@ -36,15 +36,14 @@ FORMS += mainUI.ui \ PropDialog.ui \ BookmarkMenu.ui -isEmpty(USE_MUPDF){ - message("Using Poppler-Qt5 Backend") - LIBS += -lpoppler-qt5 - SOURCES += Renderer-poppler.cpp -}else{ +isEmpty(USE_POPPLER){ message("Using MuPDF Backend") LIBS += -lmupdf -lmupdfthird SOURCES += Renderer-mupdf.cpp - +}else{ + message("Using Poppler-Qt5 Backend") + LIBS += -lpoppler-qt5 + SOURCES += Renderer-poppler.cpp } TRANSLATIONS = i18n/l-pdf_af.ts \ diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp index 011f8660..b25f61fb 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp @@ -32,11 +32,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ PROPDIALOG = new PropDialog(BACKEND); BOOKMARKS = new BookmarkMenu(BACKEND, this->centralWidget()); BOOKMARKS->setContextMenuPolicy(Qt::CustomContextMenu); - BOOKMARKS->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + //BOOKMARKS->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //Create the interface widgets WIDGET = new PrintWidget(BACKEND, this->centralWidget()); WIDGET->setContextMenuPolicy(Qt::CustomContextMenu); - WIDGET->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + //WIDGET->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); loadingQueue.clear(); clockTimer = new QTimer(this); clockTimer->setInterval(1000); //1-second updates to clock @@ -57,6 +57,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ ui->label_replaceme->setVisible(false); this->centralWidget()->layout()->replaceWidget(ui->label_replaceme2, BOOKMARKS); ui->label_replaceme2->setVisible(false); + QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); + policy.setHorizontalStretch(1); + BOOKMARKS->setSizePolicy(policy); + policy.setHorizontalStretch(4); + WIDGET->setSizePolicy(policy); connect(WIDGET, SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(showContextMenu(const QPoint&)) ); connect(WIDGET, SIGNAL(currentPageChanged()), this, SLOT(updatePageNumber()) ); connect(BACKEND, SIGNAL(PageLoaded(int)), this, SLOT(slotPageLoaded(int)) ); @@ -208,21 +213,12 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ //TESTING features/functionality bool TESTING = BACKEND->supportsExtraFeatures(); - ui->actionSettings->setEnabled(TESTING); - ui->actionSettings->setVisible(TESTING); ui->actionBookmarks->setEnabled(TESTING); ui->actionBookmarks->setVisible(TESTING); - ui->actionScroll_Mode->setEnabled(TESTING); - ui->actionScroll_Mode->setVisible(TESTING); - ui->actionSelect_Mode->setEnabled(TESTING); - ui->actionSelect_Mode->setVisible(TESTING); ui->actionProperties->setEnabled(TESTING); ui->actionProperties->setVisible(TESTING); - ui->menuSettings->setEnabled(TESTING); - ui->menuSettings->setVisible(TESTING); - if(!TESTING){ - ui->menubar->removeAction(ui->menuSettings->menuAction() ); - } + ui->actionClearHighlights->setEnabled(TESTING); + ui->actionClearHighlights->setVisible(TESTING); ui->actionSettings->setEnabled(false); ui->actionSettings->setVisible(false); @@ -385,19 +381,21 @@ void MainUI::startLoadingPages(int degrees){ // 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) - QSize DPI(300,300); //print-quality (some printers even go to 600 DPI nowdays) + QSize DPI(150,150); //print-quality (some printers even go to 600 DPI nowdays) /*qDebug() << "Screen Resolutions:"; QList screens = QApplication::screens(); for(int i=0; iname() << screens[i]->logicalDotsPerInchX() << screens[i]->logicalDotsPerInchY(); }*/ + for(int i=0; inumPages(); i++){ //qDebug() << " - Kickoff page load:" << i; if(BACKEND->loadMultiThread()) { QtConcurrent::run(BACKEND, &Renderer::renderPage, i, DPI, degrees); }else{ BACKEND->renderPage(i, DPI, degrees); + if(i % 50 == 0){ QCoreApplication::processEvents(); } } } //qDebug() << "Finish page loading kickoff"; @@ -634,7 +632,8 @@ void MainUI::find(QString text, bool forward) { //qDebug() << "Jump to page: " << currentText.page; - WIDGET->highlightText(currentText); + if(BACKEND->supportsExtraFeatures()) + WIDGET->highlightText(currentText); }else{ ui->resultsLabel->setText("No results found"); } diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui index 92921057..09a5862d 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui @@ -14,27 +14,28 @@ - - - 4 - - - 4 - - - 4 - - - 4 - - - 4 - + + + + + + 1 + 0 + + + + Bookmarks Area + + + Qt::AlignCenter + + + - 0 + 3 0 @@ -126,19 +127,6 @@ - - - - - 0 - 0 - - - - Bookmarks Area - - - -- cgit